Skip to content

Commit

Permalink
Avoid runtime setuptools dependency
Browse files Browse the repository at this point in the history
Using `pkg_resources` meant that setuptools had to be available during
runtime, but this dependency was undeclared. Switch to
importlib.metadata which is in stdlib since Python 3.8.

Fixes: #8
  • Loading branch information
liskin committed Nov 28, 2022
1 parent 08a3136 commit 15930d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install_requires =
click ~= 8.0
click-config-file
click-option-group
importlib-metadata; python_version<'3.8'
platformdirs >= 2.1
requests
requests_oauthlib
Expand Down
11 changes: 7 additions & 4 deletions src/strava_offline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# isort: skip_file
from pkg_resources import get_distribution, DistributionNotFound
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import version, PackageNotFoundError # type: ignore # isort: skip
except ImportError:
from importlib_metadata import version, PackageNotFoundError # type: ignore # isort: skip

try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
pass

0 comments on commit 15930d4

Please sign in to comment.