From 8c7110ad6b8cfbfb926376fed4495608199fcf1c Mon Sep 17 00:00:00 2001
From: Li Li
Date: Wed, 3 Apr 2024 16:36:54 +1100
Subject: [PATCH 1/3] fix: Replace pkg_resources with importlib.metadata
---
doc/conf.py | 4 ++--
setup.py | 1 -
src/braket/devices/local_simulator.py | 4 ++--
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index 2a8193e55..4966e18de 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -2,11 +2,11 @@
import datetime
-import pkg_resources
+from importlib.metadata import version
# Sphinx configuration below.
project = "amazon-braket-sdk"
-version = pkg_resources.require(project)[0].version
+version = version(project)
release = version
copyright = "{}, Amazon.com".format(datetime.datetime.now().year)
diff --git a/setup.py b/setup.py
index 6c0a9e984..aff5e1717 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,6 @@
"amazon-braket-schemas>=1.21.0",
"amazon-braket-default-simulator>=1.21.2",
"oqpy~=0.3.5",
- "setuptools",
"backoff",
"boltons",
"boto3>=1.28.53",
diff --git a/src/braket/devices/local_simulator.py b/src/braket/devices/local_simulator.py
index faee13fdf..ef5e42560 100644
--- a/src/braket/devices/local_simulator.py
+++ b/src/braket/devices/local_simulator.py
@@ -19,7 +19,7 @@
from os import cpu_count
from typing import Any, Optional, Union
-import pkg_resources
+from importlib.metadata import entry_points
from braket.ahs.analog_hamiltonian_simulation import AnalogHamiltonianSimulation
from braket.annealing.problem import Problem
@@ -40,7 +40,7 @@
from braket.tasks.local_quantum_task_batch import LocalQuantumTaskBatch
_simulator_devices = {
- entry.name: entry for entry in pkg_resources.iter_entry_points("braket.simulators")
+ entry.name: entry for entry in entry_points(group="braket.simulators")
}
From 73162307d5052903dfdc6aec8deef0805fae5d43 Mon Sep 17 00:00:00 2001
From: Li Li
Date: Wed, 3 Apr 2024 16:48:13 +1100
Subject: [PATCH 2/3] lint
---
doc/conf.py | 1 -
src/braket/devices/local_simulator.py | 7 ++-----
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index 4966e18de..a2548fc65 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -1,7 +1,6 @@
"""Sphinx configuration."""
import datetime
-
from importlib.metadata import version
# Sphinx configuration below.
diff --git a/src/braket/devices/local_simulator.py b/src/braket/devices/local_simulator.py
index ef5e42560..5e518083c 100644
--- a/src/braket/devices/local_simulator.py
+++ b/src/braket/devices/local_simulator.py
@@ -14,13 +14,12 @@
from __future__ import annotations
from functools import singledispatchmethod
+from importlib.metadata import entry_points
from itertools import repeat
from multiprocessing import Pool
from os import cpu_count
from typing import Any, Optional, Union
-from importlib.metadata import entry_points
-
from braket.ahs.analog_hamiltonian_simulation import AnalogHamiltonianSimulation
from braket.annealing.problem import Problem
from braket.circuits import Circuit
@@ -39,9 +38,7 @@
from braket.tasks.local_quantum_task import LocalQuantumTask
from braket.tasks.local_quantum_task_batch import LocalQuantumTaskBatch
-_simulator_devices = {
- entry.name: entry for entry in entry_points(group="braket.simulators")
-}
+_simulator_devices = {entry.name: entry for entry in entry_points(group="braket.simulators")}
class LocalSimulator(Device):
From c00251970e541273d722ad70c33ddcdfc6dd1292 Mon Sep 17 00:00:00 2001
From: Li Li
Date: Thu, 4 Apr 2024 09:25:47 +1100
Subject: [PATCH 3/3] use backport for 3.9
---
setup.py | 1 +
src/braket/devices/local_simulator.py | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index aff5e1717..34d220161 100644
--- a/setup.py
+++ b/setup.py
@@ -40,6 +40,7 @@
"openpulse",
"openqasm3",
"sympy",
+ "backports.entry-points-selectable",
],
extras_require={
"test": [
diff --git a/src/braket/devices/local_simulator.py b/src/braket/devices/local_simulator.py
index 5e518083c..69fcfdaff 100644
--- a/src/braket/devices/local_simulator.py
+++ b/src/braket/devices/local_simulator.py
@@ -13,8 +13,8 @@
from __future__ import annotations
+import sys
from functools import singledispatchmethod
-from importlib.metadata import entry_points
from itertools import repeat
from multiprocessing import Pool
from os import cpu_count
@@ -38,6 +38,11 @@
from braket.tasks.local_quantum_task import LocalQuantumTask
from braket.tasks.local_quantum_task_batch import LocalQuantumTaskBatch
+if sys.version_info.minor == 9:
+ from backports.entry_points_selectable import entry_points
+else:
+ from importlib.metadata import entry_points
+
_simulator_devices = {entry.name: entry for entry in entry_points(group="braket.simulators")}