From 3af5ff20ac8cae9eaf6efba6cc4cd24e47cde9b0 Mon Sep 17 00:00:00 2001 From: Matthew Neeley Date: Wed, 25 May 2022 14:51:55 -0700 Subject: [PATCH] Drop support for python 3.6 (#5373) This is a step toward following the numpy python support schedule (https://github.com/quantumlib/Cirq/issues/3347). Note that according to the schedule we should be at 3.8+, but we cannot yet drop support for 3.7 since colab is still at 3.7.13. --- .github/workflows/ci.yml | 5 +---- asv.conf.json | 2 +- cirq-aqt/setup.py | 2 +- cirq-core/cirq/__init__.py | 1 - cirq-core/cirq/_version.py | 8 ++++---- .../cirq/protocols/json_test_data/spec.py | 1 - cirq-core/cirq/sim/simulator.py | 2 +- cirq-core/cirq/value/__init__.py | 2 +- cirq-core/cirq/value/abc_alt.py | 20 ------------------- cirq-core/requirements.txt | 3 --- cirq-core/setup.py | 2 +- cirq-google/cirq_google/_version.py | 8 ++++---- cirq-google/setup.py | 2 +- cirq-ionq/setup.py | 2 +- cirq-pasqal/setup.py | 2 +- cirq-web/setup.py | 2 +- dev_tools/modules_test.py | 2 +- dev_tools/modules_test_data/mod1/setup.py | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 20 files changed, 22 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba931ba312d..747bc1f7f44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,7 +155,7 @@ jobs: name: Pytest Ubuntu strategy: matrix: - python-version: [ '3.6', '3.7', '3.8', '3.9' ] + python-version: [ '3.7', '3.8', '3.9' ] runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -163,9 +163,6 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: 'x64' - - name: Force old pip (3.6 only) - if: matrix.python-version == '3.6' - run: pip install pip==20.2 - uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} diff --git a/asv.conf.json b/asv.conf.json index ce70ad8974a..31ed331fcfc 100644 --- a/asv.conf.json +++ b/asv.conf.json @@ -8,7 +8,7 @@ "dvcs": "git", "environment_type": "virtualenv", "show_commit_url": "https://github.com/quantumlib/Cirq/commit/", - "pythons": ["3.6", "3.7", "3.8"], + "pythons": ["3.7", "3.8"], "benchmark_dir": "benchmarks", "env_dir": ".asv/env", "results_dir": ".asv/results", diff --git a/cirq-aqt/setup.py b/cirq-aqt/setup.py index 18945d85c58..b9ca65763a9 100644 --- a/cirq-aqt/setup.py +++ b/cirq-aqt/setup.py @@ -60,7 +60,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, license='Apache 2', description=description, diff --git a/cirq-core/cirq/__init__.py b/cirq-core/cirq/__init__.py index 76c164ade7c..a82f106526d 100644 --- a/cirq-core/cirq/__init__.py +++ b/cirq-core/cirq/__init__.py @@ -541,7 +541,6 @@ Condition, Duration, DURATION_LIKE, - GenericMetaImplementAnyOneOf, KeyCondition, LinearDict, MEASUREMENT_KEY_SEPARATOR, diff --git a/cirq-core/cirq/_version.py b/cirq-core/cirq/_version.py index d6e08d2fd82..b520aff06ec 100644 --- a/cirq-core/cirq/_version.py +++ b/cirq-core/cirq/_version.py @@ -13,17 +13,17 @@ # limitations under the License. """Define version number here, read it from setup.py automatically, -and warn users that the latest version of cirq uses python 3.6+""" +and warn users that the latest version of cirq uses python 3.7+""" import sys -if sys.version_info < (3, 6, 0): +if sys.version_info < (3, 7, 0): # coverage: ignore raise SystemError( - "You installed the latest version of cirq but aren't on python 3.6+.\n" + "You installed the latest version of cirq but aren't on python 3.7+.\n" 'To fix this error, you need to either:\n' '\n' - 'A) Update to python 3.6 or later.\n' + 'A) Update to python 3.7 or later.\n' '- OR -\n' 'B) Explicitly install an older deprecated-but-compatible version ' 'of cirq (e.g. "python -m pip install cirq==0.5.*")' diff --git a/cirq-core/cirq/protocols/json_test_data/spec.py b/cirq-core/cirq/protocols/json_test_data/spec.py index 54493216049..86bd2ee0ebf 100644 --- a/cirq-core/cirq/protocols/json_test_data/spec.py +++ b/cirq-core/cirq/protocols/json_test_data/spec.py @@ -129,7 +129,6 @@ 'Pauli', 'SingleQubitGate', 'ABCMetaImplementAnyOneOf', - 'GenericMetaImplementAnyOneOf', 'SimulatesAmplitudes', 'SimulatesExpectationValues', 'SimulatesFinalState', diff --git a/cirq-core/cirq/sim/simulator.py b/cirq-core/cirq/sim/simulator.py index 6d5ad00d7e5..f62108bccd0 100644 --- a/cirq-core/cirq/sim/simulator.py +++ b/cirq-core/cirq/sim/simulator.py @@ -452,7 +452,7 @@ def simulate_expectation_values_sweep_iter( class SimulatesFinalState( - Generic[TSimulationTrialResult], metaclass=value.GenericMetaImplementAnyOneOf + Generic[TSimulationTrialResult], metaclass=value.ABCMetaImplementAnyOneOf ): """Simulator that allows access to the simulator's final state. diff --git a/cirq-core/cirq/value/__init__.py b/cirq-core/cirq/value/__init__.py index 423acee7967..a810bf108e9 100644 --- a/cirq-core/cirq/value/__init__.py +++ b/cirq-core/cirq/value/__init__.py @@ -13,7 +13,7 @@ # limitations under the License. """Value conversion utilities and classes for time and quantum states.""" -from cirq.value.abc_alt import ABCMetaImplementAnyOneOf, alternative, GenericMetaImplementAnyOneOf +from cirq.value.abc_alt import ABCMetaImplementAnyOneOf, alternative from cirq.value.angle import ( canonicalize_half_turns, diff --git a/cirq-core/cirq/value/abc_alt.py b/cirq-core/cirq/value/abc_alt.py index a4bc0f99d55..876583fc298 100644 --- a/cirq-core/cirq/value/abc_alt.py +++ b/cirq-core/cirq/value/abc_alt.py @@ -17,15 +17,6 @@ import functools from typing import cast, Callable, Set, TypeVar -# Required due to PEP 560 -try: - # python 3.6 class for generic metaclasses - from typing import GenericMeta # type: ignore -except ImportError: - # In python 3.7, GenericMeta doesn't exist but we don't need it - class GenericMeta(type): # type: ignore - pass - T = TypeVar('T') @@ -154,14 +145,3 @@ def impl_of_abstract(*args, **kwargs): cls.__abstractmethods__ |= abstracts # Add to the set made by ABCMeta cls._implemented_by_ = implemented_by return cls - - -class GenericMetaImplementAnyOneOf(GenericMeta, ABCMetaImplementAnyOneOf): - """Generic version of ABCMetaImplementAnyOneOf. - - Classes which inherit from Generic[T] must use this type instead of - ABCMetaImplementAnyOneOf due to https://github.com/python/typing/issues/449. - - This issue is specific to python3.6; this class can be removed when Cirq - python3.6 support is turned down. - """ diff --git a/cirq-core/requirements.txt b/cirq-core/requirements.txt index 14ed4dff56a..33166c7369b 100644 --- a/cirq-core/requirements.txt +++ b/cirq-core/requirements.txt @@ -1,8 +1,5 @@ # Runtime requirements for the python 3 version of cirq. -# for python 3.6 and below dataclasses needs to be installed -dataclasses; python_version < '3.7' - # functools.cached_property was introduced in python 3.8 backports.cached_property~=1.0.1; python_version < '3.8' diff --git a/cirq-core/setup.py b/cirq-core/setup.py index 9cf0c26f1da..e2f21e8d4f4 100644 --- a/cirq-core/setup.py +++ b/cirq-core/setup.py @@ -63,7 +63,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, extras_require={'contrib': contrib_requirements}, license='Apache 2', diff --git a/cirq-google/cirq_google/_version.py b/cirq-google/cirq_google/_version.py index d6e08d2fd82..b520aff06ec 100644 --- a/cirq-google/cirq_google/_version.py +++ b/cirq-google/cirq_google/_version.py @@ -13,17 +13,17 @@ # limitations under the License. """Define version number here, read it from setup.py automatically, -and warn users that the latest version of cirq uses python 3.6+""" +and warn users that the latest version of cirq uses python 3.7+""" import sys -if sys.version_info < (3, 6, 0): +if sys.version_info < (3, 7, 0): # coverage: ignore raise SystemError( - "You installed the latest version of cirq but aren't on python 3.6+.\n" + "You installed the latest version of cirq but aren't on python 3.7+.\n" 'To fix this error, you need to either:\n' '\n' - 'A) Update to python 3.6 or later.\n' + 'A) Update to python 3.7 or later.\n' '- OR -\n' 'B) Explicitly install an older deprecated-but-compatible version ' 'of cirq (e.g. "python -m pip install cirq==0.5.*")' diff --git a/cirq-google/setup.py b/cirq-google/setup.py index dc16056b9e5..7ca0706fed1 100644 --- a/cirq-google/setup.py +++ b/cirq-google/setup.py @@ -62,7 +62,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, license='Apache 2', description=description, diff --git a/cirq-ionq/setup.py b/cirq-ionq/setup.py index ad7190dc9d2..a6532a40017 100644 --- a/cirq-ionq/setup.py +++ b/cirq-ionq/setup.py @@ -59,7 +59,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, license='Apache 2', description=description, diff --git a/cirq-pasqal/setup.py b/cirq-pasqal/setup.py index 8771de9ef2c..e0e5f6609fc 100644 --- a/cirq-pasqal/setup.py +++ b/cirq-pasqal/setup.py @@ -58,7 +58,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires='>=3.6.0', + python_requires='>=3.7.0', install_requires=requirements, license='Apache 2', description=description, diff --git a/cirq-web/setup.py b/cirq-web/setup.py index 6552565e9a8..a54eb19f2f1 100644 --- a/cirq-web/setup.py +++ b/cirq-web/setup.py @@ -62,7 +62,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, license='Apache 2', description=description, diff --git a/dev_tools/modules_test.py b/dev_tools/modules_test.py index 86802cb5be3..60760c46246 100644 --- a/dev_tools/modules_test.py +++ b/dev_tools/modules_test.py @@ -37,7 +37,7 @@ def test_modules(): 'url': 'http://github.com/quantumlib/cirq', 'author': 'The Cirq Developers', 'author_email': 'cirq-dev@googlegroups.com', - 'python_requires': '>=3.6.0', + 'python_requires': '>=3.7.0', 'install_requires': ['req1', 'req2'], 'license': 'Apache 2', 'packages': ['pack1', 'pack1.sub'], diff --git a/dev_tools/modules_test_data/mod1/setup.py b/dev_tools/modules_test_data/mod1/setup.py index a9b37275c74..c10bcaf525f 100644 --- a/dev_tools/modules_test_data/mod1/setup.py +++ b/dev_tools/modules_test_data/mod1/setup.py @@ -22,7 +22,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires=('>=3.6.0'), + python_requires=('>=3.7.0'), install_requires=requirements, license='Apache 2', packages=pack1_packages, diff --git a/pyproject.toml b/pyproject.toml index 428263ffc1c..ff3728d137b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.black] line-length = 100 -target_version = ['py36', 'py37', 'py38'] +target_version = ['py37', 'py38', 'py39'] skip-string-normalization = true skip-magic-trailing-comma = true diff --git a/setup.py b/setup.py index f74aa69b1ec..59e763db970 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,7 @@ url='http://github.com/quantumlib/cirq', author='The Cirq Developers', author_email='cirq-dev@googlegroups.com', - python_requires='>=3.6.0', + python_requires='>=3.7.0', install_requires=requirements, extras_require={'dev_env': dev_requirements}, license='Apache 2',