Skip to content

Commit 9aea3ba

Browse files
pavoljuhasmhucka
andauthored
Enable installation and testing with Python 3.14 (#7761)
Partially implements #7832 --------- Co-authored-by: Michael Hucka <mhucka@caltech.edu>
1 parent 449a1ea commit 9aea3ba

File tree

16 files changed

+32
-52
lines changed

16 files changed

+32
-52
lines changed

.github/workflows/ci-daily.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Pytest Ubuntu
2222
strategy:
2323
matrix:
24-
python-version: ['3.11', '3.12', '3.13']
24+
python-version: ['3.11', '3.12', '3.13', '3.14']
2525
runs-on: ubuntu-22.04
2626
steps:
2727
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -47,7 +47,7 @@ jobs:
4747
name: Pytest Windows
4848
strategy:
4949
matrix:
50-
python-version: ['3.11', '3.12', '3.13']
50+
python-version: ['3.11', '3.12', '3.13', '3.14']
5151
runs-on: windows-2022
5252
steps:
5353
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -73,6 +73,7 @@ jobs:
7373
name: Pytest MacOS
7474
strategy:
7575
matrix:
76+
# TODO: #7832 - enable '3.14' once qiskit-aer provides binary wheels
7677
python-version: ['3.11', '3.12', '3.13']
7778
runs-on: macos-15
7879
steps:

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
name: Pytest Ubuntu
194194
strategy:
195195
matrix:
196-
python-version: ['3.11', '3.12', '3.13']
196+
python-version: ['3.11', '3.12', '3.13', '3.14']
197197
runs-on: ubuntu-22.04-x64-8-core
198198
steps:
199199
- name: Check out source repository
@@ -296,7 +296,7 @@ jobs:
296296
name: Pytest Windows
297297
strategy:
298298
matrix:
299-
python-version: ['3.11', '3.12', '3.13']
299+
python-version: ['3.11', '3.12', '3.13', '3.14']
300300
runs-on: windows-2022-x64-8-core
301301
steps:
302302
- name: Check out source repository
@@ -324,6 +324,7 @@ jobs:
324324
name: Pytest MacOS
325325
strategy:
326326
matrix:
327+
# TODO: #7832 - enable '3.14' once qiskit-aer provides binary wheels
327328
python-version: ['3.11', '3.12', '3.13']
328329
# macos-15-large is Intel; macos-15-xlarge is ARM and the one we want.
329330
runs-on: macos-15-xlarge

cirq-aqt/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"Programming Language :: Python :: 3.11",
6767
"Programming Language :: Python :: 3.12",
6868
"Programming Language :: Python :: 3.13",
69+
"Programming Language :: Python :: 3.14",
6970
"Topic :: Scientific/Engineering :: Quantum Computing",
7071
"Topic :: Software Development :: Libraries :: Python Modules",
7172
"Typing :: Typed",

cirq-core/cirq/circuits/frozen_circuit_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ def test_immutable() -> None:
8585
q = cirq.LineQubit(0)
8686
c = cirq.FrozenCircuit(cirq.X(q), cirq.H(q))
8787

88-
# Match one of two strings. The second one is message returned since python 3.11.
8988
with pytest.raises(
90-
AttributeError,
91-
match="(can't set attribute)|(property 'moments' of 'FrozenCircuit' object has no setter)",
89+
AttributeError, match="property 'moments' of 'FrozenCircuit' object has no setter"
9290
):
9391
c.moments = (cirq.Moment(cirq.H(q)), cirq.Moment(cirq.X(q))) # type: ignore[misc]
9492

cirq-core/cirq/devices/grid_qubit_test.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,38 +354,24 @@ def test_to_json() -> None:
354354

355355

356356
def test_immutable() -> None:
357-
# Match one of two strings. The second one is message returned since python 3.11.
358-
with pytest.raises(
359-
AttributeError,
360-
match="(can't set attribute)|(property 'col' of 'GridQubit' object has no setter)",
361-
):
357+
with pytest.raises(AttributeError, match="property 'col' of 'GridQubit' object has no setter"):
362358
q = cirq.GridQubit(1, 2)
363359
q.col = 3 # type: ignore[misc]
364360

365-
with pytest.raises(
366-
AttributeError,
367-
match="(can't set attribute)|(property 'row' of 'GridQubit' object has no setter)",
368-
):
361+
with pytest.raises(AttributeError, match="property 'row' of 'GridQubit' object has no setter"):
369362
q = cirq.GridQubit(1, 2)
370363
q.row = 3 # type: ignore[misc]
371364

372-
with pytest.raises(
373-
AttributeError,
374-
match="(can't set attribute)|(property 'col' of 'GridQid' object has no setter)",
375-
):
365+
with pytest.raises(AttributeError, match="property 'col' of 'GridQid' object has no setter"):
376366
qid = cirq.GridQid(1, 2, dimension=3)
377367
qid.col = 3 # type: ignore[misc]
378368

379-
with pytest.raises(
380-
AttributeError,
381-
match="(can't set attribute)|(property 'row' of 'GridQid' object has no setter)",
382-
):
369+
with pytest.raises(AttributeError, match="property 'row' of 'GridQid' object has no setter"):
383370
qid = cirq.GridQid(1, 2, dimension=3)
384371
qid.row = 3 # type: ignore[misc]
385372

386373
with pytest.raises(
387-
AttributeError,
388-
match="(can't set attribute)|(property 'dimension' of 'GridQid' object has no setter)",
374+
AttributeError, match="property 'dimension' of 'GridQid' object has no setter"
389375
):
390376
qid = cirq.GridQid(1, 2, dimension=3)
391377
qid.dimension = 3 # type: ignore[misc]

cirq-core/cirq/devices/line_qubit_test.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,11 @@ def _qid_shape_(self):
264264

265265

266266
def test_immutable() -> None:
267-
# Match one of two strings. The second one is message returned since python 3.11.
268-
with pytest.raises(
269-
AttributeError,
270-
match="(can't set attribute)|(property 'x' of 'LineQubit' object has no setter)",
271-
):
267+
with pytest.raises(AttributeError, match="property 'x' of 'LineQubit' object has no setter"):
272268
q = cirq.LineQubit(5)
273269
q.x = 6 # type: ignore[misc]
274270

275-
with pytest.raises(
276-
AttributeError,
277-
match="(can't set attribute)|(property 'x' of 'LineQid' object has no setter)",
278-
):
271+
with pytest.raises(AttributeError, match="property 'x' of 'LineQid' object has no setter"):
279272
qid = cirq.LineQid(5, dimension=4)
280273
qid.x = 6 # type: ignore[misc]
281274

cirq-core/cirq/ops/gate_operation_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,15 @@ def test_immutable() -> None:
4545
a, b = cirq.LineQubit.range(2)
4646
op = cirq.X(a)
4747

48-
# Match one of two strings. The second one is message returned since python 3.11.
4948
with pytest.raises(
5049
AttributeError,
51-
match="(can't set attribute)|"
52-
"(property 'gate' of 'SingleQubitPauliStringGateOperation' object has no setter)",
50+
match="property 'gate' of 'SingleQubitPauliStringGateOperation' object has no setter",
5351
):
5452
op.gate = cirq.Y
5553

5654
with pytest.raises(
5755
AttributeError,
58-
match="(can't set attribute)|"
59-
"(property 'qubits' of 'SingleQubitPauliStringGateOperation' object has no setter)",
56+
match="property 'qubits' of 'SingleQubitPauliStringGateOperation' object has no setter",
6057
):
6158
op.qubits = [b]
6259

cirq-core/cirq/ops/gateset_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,16 @@ def test_invalid_gate_family() -> None:
121121

122122
def test_gate_family_immutable() -> None:
123123
g = cirq.GateFamily(CustomX)
124-
# Match one of two strings. The second one is message returned since python 3.11.
125124
with pytest.raises(
126-
AttributeError,
127-
match="(can't set attribute)|(property 'gate' of 'GateFamily' object has no setter)",
125+
AttributeError, match="property 'gate' of 'GateFamily' object has no setter"
128126
):
129127
g.gate = CustomXPowGate # type: ignore[misc]
130128
with pytest.raises(
131-
AttributeError,
132-
match="(can't set attribute)|(property 'name' of 'GateFamily' object has no setter)",
129+
AttributeError, match="property 'name' of 'GateFamily' object has no setter"
133130
):
134131
g.name = 'new name' # type: ignore[misc]
135132
with pytest.raises(
136-
AttributeError,
137-
match="(can't set attribute)|(property 'description' of 'GateFamily' object has no setter)",
133+
AttributeError, match="property 'description' of 'GateFamily' object has no setter"
138134
):
139135
g.description = 'new description' # type: ignore[misc]
140136

cirq-core/cirq/ops/linear_combinations_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,11 @@ def test_from_boolean_expression(boolean_expr, expected_pauli_sum) -> None:
12471247
boolean = sympy_parser.parse_expr(boolean_expr)
12481248
qubit_map = {name: cirq.NamedQubit(name) for name in sorted(cirq.parameter_names(boolean))}
12491249
actual = cirq.PauliSum.from_boolean_expression(boolean, qubit_map)
1250-
# Instead of calling str() directly, first make sure that the items are sorted. This is to make
1251-
# the unit test more robut in case Sympy would result in a different parsing order. By sorting
1252-
# the individual items, we would have a canonical representation.
1253-
actual_items = list(sorted(str(pauli_string) for pauli_string in actual))
1250+
# Instead of calling str() directly, first make sure that the items are sorted and their
1251+
# coefficients normalized to have "+0j" imaginary component (instead of "-0j") as in the
1252+
# expected_pauli_sum. This is to make the unit test more robust should Sympy change its
1253+
# parsing order.
1254+
actual_items = sorted(str(pauli_string).replace('-0j', '+0j') for pauli_string in actual)
12541255
assert expected_pauli_sum == actual_items
12551256

12561257

cirq-core/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"Programming Language :: Python :: 3.11",
7575
"Programming Language :: Python :: 3.12",
7676
"Programming Language :: Python :: 3.13",
77+
"Programming Language :: Python :: 3.14",
7778
"Topic :: Scientific/Engineering :: Quantum Computing",
7879
"Topic :: Software Development :: Libraries :: Python Modules",
7980
"Typing :: Typed",

0 commit comments

Comments
 (0)