From f6d75eea9b23153a599f2acca97f1941c36d8a84 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 23 Nov 2023 13:17:14 -0500 Subject: [PATCH] Add support for Python 3.12 (Qiskit/qiskit#11262) * Add support for Python 3.12 Python 3.12.0 was released on 10-02-2023, this commit marks the start of support for Python 3.12 in Qiskit. It adds the supported Pythonv ersion in the package metadata and updates the CI configuration to run test jobs on Python 3.12 and build Python 3.12 wheels on release. Fixes: Qiskit/qiskit#10887 * Add release note * Avoid deprecated `datetime.datetime.utcnow()` usage In Python 3.12 `datetime.datetime.utcnow()` has been deprecated, being replaced by: `datetime.datetime.now(datetime.UTC)`. This commit updates the usage of `utcnow()` to follow the new convention. * Adjust UTC usage to support Python 3.8 The recommended alternative for using utcnow() in the deprecation warnings emitted by Python 3.12 are not compatible with Python 3.8. The datetime.UTC alias was not added to Python until Python 3.11. To ensure that the code is compatible with Python < 3.11 this commit updates all the usage of datetime.UTC to use datetime.timezone.utc instead, which is what datetime.UTC aliases to in Python >=3.11. --- qiskit_ibm_runtime/fake_provider/fake_backend_v2.py | 6 +++--- qiskit_ibm_runtime/fake_provider/fake_mumbai_v2.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qiskit_ibm_runtime/fake_provider/fake_backend_v2.py b/qiskit_ibm_runtime/fake_provider/fake_backend_v2.py index 23b0c58dad..96cd6dff9d 100644 --- a/qiskit_ibm_runtime/fake_provider/fake_backend_v2.py +++ b/qiskit_ibm_runtime/fake_provider/fake_backend_v2.py @@ -42,7 +42,7 @@ def __init__(self): None, name="FakeV2", description="A fake BackendV2 example", - online_date=datetime.datetime.utcnow(), + online_date=datetime.datetime.now(datetime.timezone.utc), backend_version="0.0.1", ) self._qubit_properties = [ @@ -116,7 +116,7 @@ def __init__(self, bidirectional=True): None, name="Fake5QV2", description="A fake BackendV2 example", - online_date=datetime.datetime.utcnow(), + online_date=datetime.datetime.now(datetime.timezone.utc), backend_version="0.0.1", ) qubit_properties = [ @@ -188,7 +188,7 @@ def __init__(self): None, name="FakeSimpleV2", description="A fake simple BackendV2 example", - online_date=datetime.datetime.utcnow(), + online_date=datetime.datetime.now(datetime.timezone.utc), backend_version="0.0.1", ) self._lam = Parameter("lambda") diff --git a/qiskit_ibm_runtime/fake_provider/fake_mumbai_v2.py b/qiskit_ibm_runtime/fake_provider/fake_mumbai_v2.py index 1a5f1c24d4..8474319dfa 100644 --- a/qiskit_ibm_runtime/fake_provider/fake_mumbai_v2.py +++ b/qiskit_ibm_runtime/fake_provider/fake_mumbai_v2.py @@ -39,7 +39,7 @@ def __init__(self): super().__init__( name="FakeMumbaiFractionalCX", description="A fake BackendV2 example based on IBM Mumbai", - online_date=datetime.datetime.utcnow(), + online_date=datetime.datetime.now(datetime.timezone.utc), backend_version="0.0.1", ) dt = 0.2222222222222222e-9