Skip to content

Commit

Permalink
docs(backport): Use importlib.metadata to get version info (#2502)
Browse files Browse the repository at this point in the history
* Backport PR #2477
* pkg_resources is deprecated as an API, so stop using it.
   - c.f. https://setuptools.pypa.io/en/latest/pkg_resources.html
* importlib.metadata.version is the recommended way to get package
  version information.
   - c.f. https://docs.python.org/3/library/importlib.metadata.html

Co-authored-by: Matthew Feickert <[email protected]>
  • Loading branch information
meeseeksmachine and matthewfeickert authored May 30, 2024
1 parent 1dec306 commit de3c23c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use Path('../relative_path_to_dir').resolve() to make it absolute, like shown here.

import importlib.metadata
import sys
from pathlib import Path

import jupytext
from pkg_resources import get_distribution

sys.path.insert(0, str(Path('./exts').resolve()))

Expand Down Expand Up @@ -123,7 +123,7 @@ def setup(app):
# |version| and |release|, also used in various other places throughout the
# built documents.
# The full version, including alpha/beta/rc tags.
release = get_distribution('pyhf').version
release = importlib.metadata.version("pyhf")
# for example take major/minor/patch
version = '.'.join(release.split('.')[:3])

Expand Down

0 comments on commit de3c23c

Please sign in to comment.