diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2020-11-23 18:25:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 18:25:24 +0100 |
commit | 303defef04aa1a60dc74a4e52fef0bcf05c3d6be (patch) | |
tree | fba90824a1ccda815e7c0a02bb1abc7358cafba0 | |
parent | e4bef2f2e95f05d9aae0a9de69b7b56ded6c48f2 (diff) | |
parent | 44ad66121daba7d735a8d884ed92929d07801938 (diff) | |
download | setuptools-scm-303defef04aa1a60dc74a4e52fef0bcf05c3d6be.tar.gz |
Merge pull request #490 from jamesbraza/importlib-docs-clarification
importlib.metadata/pkg_resources docs clarifications
-rw-r--r-- | README.rst | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -187,7 +187,7 @@ Retrieving package version at runtime If you have opted not to hardcode the version number inside the package, you can retrieve it at runtime from PEP-0566_ metadata using -``importlib.metadata`` from the standard library +``importlib.metadata`` from the standard library (added in Python 3.8) or the `importlib_metadata`_ backport: .. code:: python @@ -195,7 +195,7 @@ or the `importlib_metadata`_ backport: from importlib.metadata import version, PackageNotFoundError try: - __version__ = version(__name__) + __version__ = version("package-name") except PackageNotFoundError: # package is not installed pass @@ -208,7 +208,7 @@ Alternatively, you can use ``pkg_resources`` which is included in from pkg_resources import get_distribution, DistributionNotFound try: - __version__ = get_distribution(__name__).version + __version__ = get_distribution("package-name").version except DistributionNotFound: # package is not installed pass |