Skip to content

Commit

Permalink
Raise minimum python version to 3.9 (#12910)
Browse files Browse the repository at this point in the history
* Raise minimum python version to 3.9

Qiskit 1.2.0 was the final minor version release of qiskit with Python
3.8 support. As Python 3.8 is going EoL before the next Qiskit minor
release 1.3.0 we can drop support for running with 3.8 on the main
branch now. This commit makes that change and updates everything using
python 3.8 currently to use our new minimum instead.

* Pin dependency versions when installing historical versions

Now that we're running Python 3.9 as the base version we are
encountering compatibility issues with some of our dependencies because
3.9 supports newer versions of things like numpy than older Qiskit
releases were compatible with. The only way to work around this is to
pin the versions when installing historical versions. To start this sets
a single constraints version since we can get away with using the same
version for everything. In the future though it is possible that we'll
need separate files for different historical releases.

* Update reference images

* Drop 3.8 support in asv too

* Remove deprecation warning for 3.8
  • Loading branch information
mtreinish authored Sep 10, 2024
1 parent 86a1b49 commit dd145b5
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.11'

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/randomized_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Normally we test min and max version but we can't run python 3.8 or
# Normally we test min and max version but we can't run python
# 3.9 on arm64 until actions/setup-python#808 is resolved
python-version: ["3.10", "3.12"]
steps:
Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,6 @@ jobs:
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}
build_wheels_macos_arm_py38:
name: Build wheels on macOS arm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-12]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_BUILD: cp38-macosx_universal2 cp38-macosx_arm64
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-arm
build_wheels_32bit:
name: Build wheels 32bit
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -100,7 +71,7 @@ jobs:
environment: release
permissions:
id-token: write
needs: ["build_wheels", "build_wheels_32bit", "build_wheels_macos_arm_py38"]
needs: ["build_wheels", "build_wheels_32bit"]
steps:
- uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rayon = "1.10"
# distributions). We only activate that feature when building the C extension module; we still need
# it disabled for Rust-only tests to avoid linker errors with it not being loaded. See
# https://pyo3.rs/main/features#extension-module for more.
pyo3 = { version = "0.21.2", features = ["abi3-py38"] }
pyo3 = { version = "0.21.2", features = ["abi3-py39"] }

# These are our own crates.
qiskit-accelerate = { path = "crates/accelerate" }
Expand Down
2 changes: 1 addition & 1 deletion asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dvcs": "git",
"environment_type": "virtualenv",
"show_commit_url": "http://github.com/Qiskit/qiskit/commit/",
"pythons": ["3.8", "3.9", "3.10", "3.11", "3.12"],
"pythons": ["3.9", "3.10", "3.11", "3.12"],
"benchmark_dir": "test/benchmarks",
"env_dir": ".asv/env",
"results_dir": ".asv/results"
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ parameters:
- name: "supportedPythonVersions"
displayName: "All supported versions of Python"
type: object
default: ["3.8", "3.9", "3.10", "3.11", "3.12"]
default: ["3.9", "3.10", "3.11", "3.12"]

- name: "minimumPythonVersion"
displayName: "Minimum supported version of Python"
type: string
default: "3.8"
default: "3.9"

- name: "maximumPythonVersion"
displayName: "Maximum supported version of Python"
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "qiskit"
description = "An open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives."
requires-python = ">=3.8"
requires-python = ">=3.9"
license = {text = "Apache 2.0"}
authors = [
{ name = "Qiskit Development Team", email = "qiskit@us.ibm.com" },
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -140,12 +139,12 @@ include = ["qiskit", "qiskit.*"]

[tool.black]
line-length = 100
target-version = ['py38', 'py39', 'py310', 'py311']
target-version = ['py39', 'py310', 'py311']

[tool.cibuildwheel]
manylinux-x86_64-image = "manylinux2014"
manylinux-i686-image = "manylinux2014"
skip = "pp* cp36-* cp37-* *musllinux* *win32 *i686 cp38-macosx_arm64"
skip = "pp* cp36-* cp37-* cp38-* *musllinux* *win32 *i686 cp38-macosx_arm64"
test-skip = "*win32 *linux_i686"
test-command = "python {project}/examples/python/stochastic_swap.py"
# We need to use pre-built versions of Numpy and Scipy in the tests; they have a
Expand Down Expand Up @@ -197,7 +196,7 @@ extension-pkg-allow-list = [
"tweedledum",
]
load-plugins = ["pylint.extensions.docparams", "pylint.extensions.docstyle"]
py-version = "3.8" # update it when bumping minimum supported python version
py-version = "3.9" # update it when bumping minimum supported python version

[tool.pylint.basic]
good-names = ["a", "b", "i", "j", "k", "d", "n", "m", "ex", "v", "w", "x", "y", "z", "Run", "_", "logger", "q", "c", "r", "qr", "cr", "qc", "nd", "pi", "op", "b", "ar", "br", "p", "cp", "ax", "dt", "__unittest", "iSwapGate", "mu"]
Expand Down
8 changes: 0 additions & 8 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@
" Qiskit unfortunately cannot enforce this requirement during environment resolution."
" See https://qisk.it/packaging-1-0 for more detail."
)
if sys.version_info < (3, 9):
warnings.warn(
"Using Qiskit with Python 3.8 is deprecated as of the 1.1.0 release. "
"Support for running Qiskit with Python 3.8 will be removed in the "
"1.3.0 release, which coincides with when Python 3.8 goes end of life.",
DeprecationWarning,
)


from . import _accelerate
import qiskit._numpy_compat
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/py3.9-min-now-c9781484a0eb288e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
upgrade:
- |
The minimum supported version of Python is now 3.9, this has been raised
from the previous minimum support version of 3.8. This change was necessary
because the upstream cPython project no longer supports Python 3.8.
12 changes: 8 additions & 4 deletions test/python/circuit/test_circuit_load_from_qpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,11 @@ def test_pre_v12_rejects_standalone_var(self, version):
"""Test that dumping to older QPY versions rejects standalone vars."""
a = expr.Var.new("a", types.Bool())
qc = QuantumCircuit(inputs=[a])
with io.BytesIO() as fptr, self.assertRaisesRegex(
UnsupportedFeatureForVersion, "version 12 is required.*realtime variables"
with (
io.BytesIO() as fptr,
self.assertRaisesRegex(
UnsupportedFeatureForVersion, "version 12 is required.*realtime variables"
),
):
dump(qc, fptr, version=version)

Expand All @@ -1959,8 +1962,9 @@ def test_pre_v12_rejects_index(self, version):
# Be sure to use a register, since standalone vars would be rejected for other reasons.
qc = QuantumCircuit(ClassicalRegister(2, "cr"))
qc.store(expr.index(qc.cregs[0], 0), False)
with io.BytesIO() as fptr, self.assertRaisesRegex(
UnsupportedFeatureForVersion, "version 12 is required.*Index"
with (
io.BytesIO() as fptr,
self.assertRaisesRegex(UnsupportedFeatureForVersion, "version 12 is required.*Index"),
):
dump(qc, fptr, version=version)

Expand Down
9 changes: 6 additions & 3 deletions test/python/circuit/test_control_flow_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3464,9 +3464,12 @@ def test_switch_rejects_entering_case_after_close(self):
def test_switch_rejects_reentering_case(self):
"""It shouldn't be possible to enter a case within another case."""
circuit = QuantumCircuit(1, 1)
with circuit.switch(0) as case, case(0), self.assertRaisesRegex(
CircuitError, r"Cannot enter more than one case at once"
), case(1):
with (
circuit.switch(0) as case,
case(0),
self.assertRaisesRegex(CircuitError, r"Cannot enter more than one case at once"),
case(1),
):
pass

@ddt.data("1", 1.0, None, (1, 2))
Expand Down
4 changes: 2 additions & 2 deletions test/qpy_compat/process_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ if [[ ! -d qpy_$version ]] ; then
echo "Building venv for qiskit-terra $version"
python -m venv $version
if [[ ${parts[0]} -eq 0 ]] ; then
./$version/bin/pip install "qiskit-terra==$version"
./$version/bin/pip install -c qpy_test_constraints.txt "qiskit-terra==$version"
else
./$version/bin/pip install "qiskit==$version"
./$version/bin/pip install -c qpy_test_constraints.txt "qiskit==$version"
fi
mkdir qpy_$version
pushd qpy_$version
Expand Down
2 changes: 2 additions & 0 deletions test/qpy_compat/qpy_test_constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy===1.24.4
scipy===1.10.1
2 changes: 1 addition & 1 deletion test/qpy_compat/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 429
echo "PYTHONHASHSEED=$PYTHONHASHSEED"

python -m venv qiskit_venv
qiskit_venv/bin/pip install ../..
qiskit_venv/bin/pip install -c ../../constraints.txt ../..

parallel bash ./process_version.sh ::: `git tag --sort=-creatordate`

Expand Down
Binary file modified test/visual/mpl/graph/references/bloch_multivector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/mpl/graph/references/state_city.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 4.0
envlist = py38, py39, py310, py311, py312, lint-incr
envlist = py39, py310, py311, py312, lint-incr
isolated_build = true

[testenv]
Expand All @@ -15,7 +15,7 @@ setenv =
QISKIT_SUPRESS_PACKAGING_WARNINGS=Y
QISKIT_TEST_CAPTURE_STREAMS=1
QISKIT_PARALLEL=FALSE
passenv =
passenv =
RUSTUP_TOOLCHAIN
RAYON_NUM_THREADS
OMP_NUM_THREADS
Expand Down

0 comments on commit dd145b5

Please sign in to comment.