Skip to content

Commit 9c727ee

Browse files
committed
handle uninstalled pkg in __version__ assignment
1 parent 0e8739f commit 9c727ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ To use setuptools_scm just modify your project's setup.py file like this:
3737

3838
.. code:: python
3939
40-
import pkg_resources
41-
__version__ = pkg_resources.get_distribution(__name__).version
40+
from pkg_resources import get_distribution, DistributionNotFound
41+
try:
42+
__version__ = get_distribution(__name__).version
43+
except DistributionNotFound:
44+
# package is not installed
45+
pass
4246
4347
4448
Programmatic usage

0 commit comments

Comments
 (0)