diff options
| author | Ran Benita <ran@unusedvar.com> | 2020-08-10 16:49:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-10 15:49:51 +0200 |
| commit | bc8438bda4b33930d9bfa6e56efd74e111900be4 (patch) | |
| tree | 8945d84a9712b52d87c1f85a9651a55c9795cd60 /src | |
| parent | ce79e44d14f151e37316144f66dedb2ace2f37dc (diff) | |
| download | tablib-bc8438bda4b33930d9bfa6e56efd74e111900be4.tar.gz | |
Stop using pkg_resources
tablib imports pkg_resources in order to find its own version. Importing
pkg_resources is very slow (100ms-250ms is common).
Avoid it by letting setuptools-scm generate a file with the version
instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tablib/__init__.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/tablib/__init__.py b/src/tablib/__init__.py index 6e10d78..aecf3a4 100644 --- a/src/tablib/__init__.py +++ b/src/tablib/__init__.py @@ -1,5 +1,12 @@ """ Tablib. """ -from pkg_resources import DistributionNotFound, get_distribution +try: + # Generated by setuptools-scm. + from ._version import version as __version__ +except ImportError: + # Some broken installation. + __version__ = None + + from tablib.core import ( # noqa: F401 Databook, Dataset, @@ -10,9 +17,3 @@ from tablib.core import ( # noqa: F401 import_book, import_set, ) - -try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - # package is not installed - __version__ = None |
