Skip to content

Commit

Permalink
use importlib_metadata backport on PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfeickert committed Aug 16, 2023
1 parent e37fc3f commit 9ada877
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies = [
"scipy>=1.2.0", # requires numpy, which is required by pyhf and tensorflow
"tqdm>=4.56.0", # for readxml
"typing_extensions>=3.7.4.3; python_version == '3.7'", # for SupportsIndex
"importlib-metadata>=0.1; python_version == '3.7'", # for importlib.metadata.version
"numpy", # compatible versions controlled through scipy
]

Expand Down
8 changes: 2 additions & 6 deletions src/pyhf/tensor/jax_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
# v0.7.x backport hack
try:
from importlib.metadata import version

_jax__version__ = version("jax")
except ModuleNotFoundError:
# importlib.metadata added in Python 3.8
import jax
from importlib_metadata import version

_jax__version__ = jax.__version__
_jax__version__ = tuple(map(int, (_jax__version__.split("."))))
_old_jax_version = _jax__version__ < (0, 4, 1)
_old_jax_version = tuple(map(int, (version("jax").split(".")))) < (0, 4, 1)

if not _old_jax_version:
from jax import Array
Expand Down
1 change: 1 addition & 0 deletions tests/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jsonpatch==1.15
pyyaml==5.1
importlib_resources==1.4.0 # c.f. PR #1979
typing-extensions==3.7.4.3 # c.f. PR #1961, #1940
importlib-metadata==0.1 # c.f. PR #2280
# xmlio
uproot==4.1.1
# minuit
Expand Down

0 comments on commit 9ada877

Please sign in to comment.