summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Braza <james.braza@synthego.com>2020-11-23 09:19:23 -0500
committerJames Braza <james.braza@synthego.com>2020-11-23 11:49:15 -0500
commit44ad66121daba7d735a8d884ed92929d07801938 (patch)
treefba90824a1ccda815e7c0a02bb1abc7358cafba0
parente4bef2f2e95f05d9aae0a9de69b7b56ded6c48f2 (diff)
downloadsetuptools-scm-44ad66121daba7d735a8d884ed92929d07801938.tar.gz
Added added in Python 3.8 and replaced __name__ with package-name str for clarity
-rw-r--r--README.rst6
1 files changed, 3 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index b91ce97..457b1c4 100644
--- a/README.rst
+++ b/README.rst
@@ -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