Skip to content

Commit

Permalink
docs: Use importlib.metadata to get version info (#2477)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matthewfeickert authored May 14, 2024
1 parent 5b9c384 commit ecd0613
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 ecd0613

Please sign in to comment.