Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace pkg_resources with importlib.metadata #935

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Sphinx configuration."""

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)

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions src/braket/devices/local_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

import pkg_resources

from braket.ahs.analog_hamiltonian_simulation import AnalogHamiltonianSimulation
from braket.annealing.problem import Problem
from braket.circuits import Circuit
Expand All @@ -39,9 +38,7 @@
from braket.tasks.local_quantum_task import LocalQuantumTask
from braket.tasks.local_quantum_task_batch import LocalQuantumTaskBatch

_simulator_devices = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for the contribution!

Seems that Python 3.9 has a different behavior for using entry_points

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@math411 thanks for pointing this out. Updated to use a backport for Python 3.9 as recommend by the offical doc (see the "Compatibility Note" part).

entry.name: entry for entry in pkg_resources.iter_entry_points("braket.simulators")
}
_simulator_devices = {entry.name: entry for entry in entry_points(group="braket.simulators")}


class LocalSimulator(Device):
Expand Down
Loading