Skip to content

Commit dd145b5

Browse files
authored
Raise minimum python version to 3.9 (#12910)
* 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
1 parent 86a1b49 commit dd145b5

19 files changed

+39
-62
lines changed

.github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/setup-python@v5
2323
name: Install Python
2424
with:
25-
python-version: '3.8'
25+
python-version: '3.11'
2626

2727
- name: Install Rust toolchain
2828
uses: dtolnay/rust-toolchain@stable

.github/workflows/randomized_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/setup-python@v5
1414
name: Install Python
1515
with:
16-
python-version: '3.8'
16+
python-version: '3.11'
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install -U pip setuptools wheel

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
# Normally we test min and max version but we can't run python 3.8 or
21+
# Normally we test min and max version but we can't run python
2222
# 3.9 on arm64 until actions/setup-python#808 is resolved
2323
python-version: ["3.10", "3.12"]
2424
steps:

.github/workflows/wheels.yml

+1-30
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,6 @@ jobs:
4141
with:
4242
path: ./wheelhouse/*.whl
4343
name: wheels-${{ matrix.os }}
44-
build_wheels_macos_arm_py38:
45-
name: Build wheels on macOS arm
46-
runs-on: ${{ matrix.os }}
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
os: [macos-12]
51-
steps:
52-
- uses: actions/checkout@v4
53-
- uses: actions/setup-python@v5
54-
name: Install Python
55-
with:
56-
python-version: '3.10'
57-
- uses: dtolnay/rust-toolchain@stable
58-
with:
59-
components: llvm-tools-preview
60-
- name: Build wheels
61-
uses: pypa/[email protected]
62-
env:
63-
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
64-
CIBW_BUILD: cp38-macosx_universal2 cp38-macosx_arm64
65-
CIBW_ARCHS_MACOS: arm64 universal2
66-
CIBW_ENVIRONMENT: >-
67-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
68-
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]))')"
69-
- uses: actions/upload-artifact@v4
70-
with:
71-
path: ./wheelhouse/*.whl
72-
name: wheels-${{ matrix.os }}-arm
7344
build_wheels_32bit:
7445
name: Build wheels 32bit
7546
runs-on: ${{ matrix.os }}
@@ -100,7 +71,7 @@ jobs:
10071
environment: release
10172
permissions:
10273
id-token: write
103-
needs: ["build_wheels", "build_wheels_32bit", "build_wheels_macos_arm_py38"]
74+
needs: ["build_wheels", "build_wheels_32bit"]
10475
steps:
10576
- uses: actions/download-artifact@v4
10677
with:

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rayon = "1.10"
3434
# distributions). We only activate that feature when building the C extension module; we still need
3535
# it disabled for Rust-only tests to avoid linker errors with it not being loaded. See
3636
# https://pyo3.rs/main/features#extension-module for more.
37-
pyo3 = { version = "0.21.2", features = ["abi3-py38"] }
37+
pyo3 = { version = "0.21.2", features = ["abi3-py39"] }
3838

3939
# These are our own crates.
4040
qiskit-accelerate = { path = "crates/accelerate" }

asv.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"dvcs": "git",
1818
"environment_type": "virtualenv",
1919
"show_commit_url": "http://github.com/Qiskit/qiskit/commit/",
20-
"pythons": ["3.8", "3.9", "3.10", "3.11", "3.12"],
20+
"pythons": ["3.9", "3.10", "3.11", "3.12"],
2121
"benchmark_dir": "test/benchmarks",
2222
"env_dir": ".asv/env",
2323
"results_dir": ".asv/results"

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ parameters:
3737
- name: "supportedPythonVersions"
3838
displayName: "All supported versions of Python"
3939
type: object
40-
default: ["3.8", "3.9", "3.10", "3.11", "3.12"]
40+
default: ["3.9", "3.10", "3.11", "3.12"]
4141

4242
- name: "minimumPythonVersion"
4343
displayName: "Minimum supported version of Python"
4444
type: string
45-
default: "3.8"
45+
default: "3.9"
4646

4747
- name: "maximumPythonVersion"
4848
displayName: "Maximum supported version of Python"

pyproject.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "qiskit"
77
description = "An open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives."
8-
requires-python = ">=3.8"
8+
requires-python = ">=3.9"
99
license = {text = "Apache 2.0"}
1010
authors = [
1111
{ name = "Qiskit Development Team", email = "[email protected]" },
@@ -27,7 +27,6 @@ classifiers = [
2727
"Operating System :: Microsoft :: Windows",
2828
"Operating System :: POSIX :: Linux",
2929
"Programming Language :: Python :: 3 :: Only",
30-
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",
3332
"Programming Language :: Python :: 3.11",
@@ -140,12 +139,12 @@ include = ["qiskit", "qiskit.*"]
140139

141140
[tool.black]
142141
line-length = 100
143-
target-version = ['py38', 'py39', 'py310', 'py311']
142+
target-version = ['py39', 'py310', 'py311']
144143

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

202201
[tool.pylint.basic]
203202
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"]

qiskit/__init__.py

-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@
4343
" Qiskit unfortunately cannot enforce this requirement during environment resolution."
4444
" See https://qisk.it/packaging-1-0 for more detail."
4545
)
46-
if sys.version_info < (3, 9):
47-
warnings.warn(
48-
"Using Qiskit with Python 3.8 is deprecated as of the 1.1.0 release. "
49-
"Support for running Qiskit with Python 3.8 will be removed in the "
50-
"1.3.0 release, which coincides with when Python 3.8 goes end of life.",
51-
DeprecationWarning,
52-
)
53-
5446

5547
from . import _accelerate
5648
import qiskit._numpy_compat
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
upgrade:
3+
- |
4+
The minimum supported version of Python is now 3.9, this has been raised
5+
from the previous minimum support version of 3.8. This change was necessary
6+
because the upstream cPython project no longer supports Python 3.8.

test/python/circuit/test_circuit_load_from_qpy.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1948,8 +1948,11 @@ def test_pre_v12_rejects_standalone_var(self, version):
19481948
"""Test that dumping to older QPY versions rejects standalone vars."""
19491949
a = expr.Var.new("a", types.Bool())
19501950
qc = QuantumCircuit(inputs=[a])
1951-
with io.BytesIO() as fptr, self.assertRaisesRegex(
1952-
UnsupportedFeatureForVersion, "version 12 is required.*realtime variables"
1951+
with (
1952+
io.BytesIO() as fptr,
1953+
self.assertRaisesRegex(
1954+
UnsupportedFeatureForVersion, "version 12 is required.*realtime variables"
1955+
),
19531956
):
19541957
dump(qc, fptr, version=version)
19551958

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

test/python/circuit/test_control_flow_builders.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -3464,9 +3464,12 @@ def test_switch_rejects_entering_case_after_close(self):
34643464
def test_switch_rejects_reentering_case(self):
34653465
"""It shouldn't be possible to enter a case within another case."""
34663466
circuit = QuantumCircuit(1, 1)
3467-
with circuit.switch(0) as case, case(0), self.assertRaisesRegex(
3468-
CircuitError, r"Cannot enter more than one case at once"
3469-
), case(1):
3467+
with (
3468+
circuit.switch(0) as case,
3469+
case(0),
3470+
self.assertRaisesRegex(CircuitError, r"Cannot enter more than one case at once"),
3471+
case(1),
3472+
):
34703473
pass
34713474

34723475
@ddt.data("1", 1.0, None, (1, 2))

test/qpy_compat/process_version.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ if [[ ! -d qpy_$version ]] ; then
4545
echo "Building venv for qiskit-terra $version"
4646
python -m venv $version
4747
if [[ ${parts[0]} -eq 0 ]] ; then
48-
./$version/bin/pip install "qiskit-terra==$version"
48+
./$version/bin/pip install -c qpy_test_constraints.txt "qiskit-terra==$version"
4949
else
50-
./$version/bin/pip install "qiskit==$version"
50+
./$version/bin/pip install -c qpy_test_constraints.txt "qiskit==$version"
5151
fi
5252
mkdir qpy_$version
5353
pushd qpy_$version
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy===1.24.4
2+
scipy===1.10.1

test/qpy_compat/run_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 429
2020
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
2121

2222
python -m venv qiskit_venv
23-
qiskit_venv/bin/pip install ../..
23+
qiskit_venv/bin/pip install -c ../../constraints.txt ../..
2424

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

Loading
Loading
-1.59 KB
Loading

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 4.0
3-
envlist = py38, py39, py310, py311, py312, lint-incr
3+
envlist = py39, py310, py311, py312, lint-incr
44
isolated_build = true
55

66
[testenv]
@@ -15,7 +15,7 @@ setenv =
1515
QISKIT_SUPRESS_PACKAGING_WARNINGS=Y
1616
QISKIT_TEST_CAPTURE_STREAMS=1
1717
QISKIT_PARALLEL=FALSE
18-
passenv =
18+
passenv =
1919
RUSTUP_TOOLCHAIN
2020
RAYON_NUM_THREADS
2121
OMP_NUM_THREADS

0 commit comments

Comments
 (0)