Skip to content

Commit

Permalink
fix: Fix slow loading times from using pkg_resources (fixes #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
skorokithakis committed Nov 8, 2021
1 parent bcd01ce commit 5e6891c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog


## Unreleased
## v1.0.4 (2021-11-08)

### Fixes

Expand Down
8 changes: 5 additions & 3 deletions shortuuid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
import pkg_resources
import importlib.metadata

This comment has been minimized.

Copy link
@ucalyptus2

ucalyptus2 Nov 8, 2021

@skorokithakis this causes an error in google colab.

ModuleNotFoundError: No module named 'importlib.metadata'

This comment has been minimized.

Copy link
@sudodoki

sudodoki Nov 8, 2021

I guess, this one needs adding importlib_metadata as deps, nope, nvm. seeing this same error on Python 3.7.3, 1.0.2 worked just fine


from shortuuid.main import decode
from shortuuid.main import encode
Expand All @@ -9,7 +9,9 @@
from shortuuid.main import ShortUUID
from shortuuid.main import uuid


try:
__version__ = pkg_resources.get_distribution("shortuuid").version
except pkg_resources.DistributionNotFound:
_DISTRIBUTION_METADATA = importlib.metadata.metadata("shortuuid")
__version__ = _DISTRIBUTION_METADATA["Version"]
except Exception:
__version__ = "0.0.0"

0 comments on commit 5e6891c

Please sign in to comment.