Skip to content

Commit f6bfb7f

Browse files
authored
NEP-29 - enforce minimum Python version 3.10 (#6591)
- Raise exception if running with Python <= 3.9.x - Clean up checks and notes relevant for old Pythons - Bump up to numpy~=1.22 which is effectively the minimum version that works with Python 3.10. We are a bit more permissive than NEP 29 which suggests numpy-1.23+. Fixes: #6463 Ref: https://numpy.org/neps/nep-0029-deprecation_policy.html
1 parent 46eab2d commit f6bfb7f

File tree

17 files changed

+28
-36
lines changed

17 files changed

+28
-36
lines changed

cirq-aqt/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
url='http://github.com/quantumlib/cirq',
6161
author='The Cirq Developers',
6262
author_email='[email protected]',
63-
python_requires=('>=3.9.0'),
63+
python_requires=('>=3.10.0'),
6464
install_requires=requirements,
6565
license='Apache 2',
6666
description=description,

cirq-core/cirq/_version.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
# limitations under the License.
1414

1515
"""Define version number here, read it from setup.py automatically,
16-
and warn users that the latest version of cirq uses python 3.9+"""
16+
and warn users that the latest version of cirq uses python 3.10+"""
1717

1818
import sys
1919

20-
if sys.version_info < (3, 9, 0): # pragma: no cover
20+
if sys.version_info < (3, 10, 0): # pragma: no cover
2121
raise SystemError(
22-
"You installed the latest version of cirq but aren't on python 3.9+.\n"
22+
"You installed the latest version of cirq but aren't on python 3.10+.\n"
2323
'To fix this error, you need to either:\n'
2424
'\n'
25-
'A) Update to python 3.9 or later.\n'
25+
'A) Update to python 3.10 or later.\n'
2626
'- OR -\n'
2727
'B) Explicitly install an older deprecated-but-compatible version '
2828
'of cirq (e.g. "python -m pip install cirq==1.1.*")'

cirq-core/cirq/ops/qid_util.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def q(*args: Union[int, str]) -> Union['cirq.LineQubit', 'cirq.GridQubit', 'cirq
4141
>>> cirq.q("foo") == cirq.NamedQubit("foo")
4242
True
4343
44-
Note that arguments should be treated as positional only, even
45-
though this is only enforceable in python 3.8 or later.
44+
Note that arguments should be treated as positional only.
4645
4746
Args:
4847
*args: One or two ints, or a single str, as described above.

cirq-core/cirq/protocols/json_serialization_test.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
import contextlib
1516
import dataclasses
1617
import datetime
@@ -19,7 +20,6 @@
1920
import json
2021
import os
2122
import pathlib
22-
import sys
2323
import warnings
2424
from typing import Dict, List, Optional, Tuple, Type
2525
from unittest import mock
@@ -56,12 +56,6 @@ class _ModuleDeprecation:
5656
}
5757

5858

59-
# pyQuil 3.0, necessary for cirq_rigetti module requires
60-
# python >= 3.9
61-
if sys.version_info < (3, 9): # pragma: no cover
62-
del TESTED_MODULES['cirq_rigetti']
63-
64-
6559
def _get_testspecs_for_modules() -> List[ModuleJsonTestSpec]:
6660
modules = []
6761
for m in TESTED_MODULES.keys():

cirq-core/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ attrs
44
duet>=0.2.8
55
matplotlib~=3.0
66
networkx>=2.4
7-
numpy~=1.16
7+
numpy~=1.22
88
pandas
99
sortedcontainers~=2.0
1010
scipy<1.13.0

cirq-core/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
url='http://github.com/quantumlib/cirq',
6464
author='The Cirq Developers',
6565
author_email='[email protected]',
66-
python_requires=('>=3.9.0'),
66+
python_requires=('>=3.10.0'),
6767
install_requires=requirements,
6868
extras_require={'contrib': contrib_requirements},
6969
license='Apache 2',

cirq-ft/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
url='http://github.com/quantumlib/cirq',
6060
author='The Cirq Developers',
6161
author_email='[email protected]',
62-
python_requires='>=3.9.0',
62+
python_requires='>=3.10.0',
6363
install_requires=requirements,
6464
license='Apache 2',
6565
description=description,

cirq-google/cirq_google/_version.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
# limitations under the License.
1414

1515
"""Define version number here, read it from setup.py automatically,
16-
and warn users that the latest version of cirq uses python 3.9+"""
16+
and warn users that the latest version of cirq uses python 3.10+"""
1717

1818
import sys
1919

20-
if sys.version_info < (3, 9, 0): # pragma: no cover
20+
if sys.version_info < (3, 10, 0): # pragma: no cover
2121
raise SystemError(
22-
"You installed the latest version of cirq but aren't on python 3.9+.\n"
22+
"You installed the latest version of cirq but aren't on python 3.10+.\n"
2323
'To fix this error, you need to either:\n'
2424
'\n'
25-
'A) Update to python 3.9 or later.\n'
25+
'A) Update to python 3.10 or later.\n'
2626
'- OR -\n'
2727
'B) Explicitly install an older deprecated-but-compatible version '
2828
'of cirq (e.g. "python -m pip install cirq==1.1.*")'

cirq-google/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
url='http://github.com/quantumlib/cirq',
6363
author='The Cirq Developers',
6464
author_email='[email protected]',
65-
python_requires=('>=3.9.0'),
65+
python_requires=('>=3.10.0'),
6666
install_requires=requirements,
6767
license='Apache 2',
6868
description=description,

cirq-ionq/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
url='http://github.com/quantumlib/cirq',
6060
author='The Cirq Developers',
6161
author_email='[email protected]',
62-
python_requires=('>=3.9.0'),
62+
python_requires=('>=3.10.0'),
6363
install_requires=requirements,
6464
license='Apache 2',
6565
description=description,

cirq-pasqal/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
url='http://github.com/quantumlib/cirq',
5959
author='The Cirq Developers',
6060
author_email='[email protected]',
61-
python_requires='>=3.9.0',
61+
python_requires='>=3.10.0',
6262
install_requires=requirements,
6363
license='Apache 2',
6464
description=description,

cirq-rigetti/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
url='http://github.com/quantumlib/cirq',
6161
author='The Cirq Developers',
6262
author_email='[email protected]',
63-
python_requires='>=3.9.0',
63+
python_requires='>=3.10.0',
6464
install_requires=requirements,
6565
license='Apache 2',
6666
description=description,

cirq-web/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
url='http://github.com/quantumlib/cirq',
6363
author='The Cirq Developers',
6464
author_email='[email protected]',
65-
python_requires='>=3.9.0',
65+
python_requires='>=3.10.0',
6666
install_requires=requirements,
6767
license='Apache 2',
6868
description=description,

dev_tools/modules_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_modules():
3737
'url': 'http://github.com/quantumlib/cirq',
3838
'author': 'The Cirq Developers',
3939
'author_email': '[email protected]',
40-
'python_requires': '>=3.9.0',
40+
'python_requires': '>=3.10.0',
4141
'install_requires': ['req1', 'req2'],
4242
'license': 'Apache 2',
4343
'packages': ['pack1', 'pack1.sub'],

dev_tools/modules_test_data/mod1/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
url='http://github.com/quantumlib/cirq',
2323
author='The Cirq Developers',
2424
author_email='[email protected]',
25-
python_requires=('>=3.9.0'),
25+
python_requires=('>=3.10.0'),
2626
install_requires=requirements,
2727
license='Apache 2',
2828
packages=pack1_packages,

dev_tools/snippets_test.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
where pattern is the regex matching pattern (passed to re.compile) and
5555
substitution is the replacement string.
5656
"""
57+
5758
import inspect
58-
import sys
5959
from typing import Any, Dict, List, Optional, Pattern, Tuple, Iterator
6060

6161
import os
@@ -759,16 +759,15 @@ def test_assert_code_snippet_executes_correctly():
759759
{},
760760
)
761761

762-
if sys.version_info[0] >= 3: # Our print capture only works in python 3.
763-
with pytest.raises(AssertionError):
764-
assert_code_snippet_executes_correctly(
765-
"""
762+
with pytest.raises(AssertionError):
763+
assert_code_snippet_executes_correctly(
764+
"""
766765
print("abc")
767766
# prints
768767
# def
769768
""",
770-
{},
771-
)
769+
{},
770+
)
772771

773772
assert_code_snippet_executes_correctly(
774773
"""

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
url='http://github.com/quantumlib/cirq',
6565
author='The Cirq Developers',
6666
author_email='[email protected]',
67-
python_requires='>=3.9.0',
67+
python_requires='>=3.10.0',
6868
install_requires=requirements,
6969
extras_require={'dev_env': dev_requirements},
7070
license='Apache 2',

0 commit comments

Comments
 (0)