Skip to content

Commit

Permalink
Raise minimum python version to 3.9
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtreinish committed Aug 6, 2024
1 parent 1fdd527 commit b0d1d64
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 50 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 @@ -29,7 +29,7 @@ thiserror = "1.0"
# 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
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 @@ -134,12 +133,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 @@ -191,7 +190,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
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 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 b0d1d64

Please sign in to comment.