Skip to content

Commit

Permalink
Drop support for python 3.6 (quantumlib#5373)
Browse files Browse the repository at this point in the history
This is a step toward following the numpy python support schedule (quantumlib#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.
  • Loading branch information
maffoo authored May 25, 2022
1 parent c0965f0 commit 3af5ff2
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 50 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,14 @@ 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
- uses: actions/setup-python@v1
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 }}
Expand Down
2 changes: 1 addition & 1 deletion asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cirq-aqt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@
Condition,
Duration,
DURATION_LIKE,
GenericMetaImplementAnyOneOf,
KeyCondition,
LinearDict,
MEASUREMENT_KEY_SEPARATOR,
Expand Down
8 changes: 4 additions & 4 deletions cirq-core/cirq/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")'
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/protocols/json_test_data/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
'Pauli',
'SingleQubitGate',
'ABCMetaImplementAnyOneOf',
'GenericMetaImplementAnyOneOf',
'SimulatesAmplitudes',
'SimulatesExpectationValues',
'SimulatesFinalState',
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/sim/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/value/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 0 additions & 20 deletions cirq-core/cirq/value/abc_alt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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.
"""
3 changes: 0 additions & 3 deletions cirq-core/requirements.txt
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion cirq-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
extras_require={'contrib': contrib_requirements},
license='Apache 2',
Expand Down
8 changes: 4 additions & 4 deletions cirq-google/cirq_google/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")'
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-ionq/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-pasqal/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires='>=3.6.0',
python_requires='>=3.7.0',
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-web/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/modules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_modules():
'url': 'http://github.com/quantumlib/cirq',
'author': 'The Cirq Developers',
'author_email': '[email protected]',
'python_requires': '>=3.6.0',
'python_requires': '>=3.7.0',
'install_requires': ['req1', 'req2'],
'license': 'Apache 2',
'packages': ['pack1', 'pack1.sub'],
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/modules_test_data/mod1/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires=('>=3.6.0'),
python_requires=('>=3.7.0'),
install_requires=requirements,
license='Apache 2',
packages=pack1_packages,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='[email protected]',
python_requires='>=3.6.0',
python_requires='>=3.7.0',
install_requires=requirements,
extras_require={'dev_env': dev_requirements},
license='Apache 2',
Expand Down

0 comments on commit 3af5ff2

Please sign in to comment.