Skip to content

Commit 8ab0d0d

Browse files
committed
fix: update import handling for package version retrieval in setup.py
1 parent 079fe3d commit 8ab0d0d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ server/tinytuya
133133

134134
# Local issue response archive
135135
issues/
136+
server/.beta_build

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import setuptools
2-
from pkg_resources import DistributionNotFound, get_distribution
2+
try:
3+
from importlib.metadata import version as _pkg_version, PackageNotFoundError as DistributionNotFound
4+
def get_distribution(name):
5+
_pkg_version(name) # raises DistributionNotFound if not installed
6+
return name
7+
except ImportError:
8+
from pkg_resources import DistributionNotFound, get_distribution
39

410
from tinytuya import __version__
511

0 commit comments

Comments
 (0)