Skip to content

Commit add8f5b

Browse files
committed
Fix deprecation of pkg_resources, use importlib.metadata instead
1 parent 911e603 commit add8f5b

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

blockfrost/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from enum import Enum
2-
import pkg_resources
3-
2+
try:
3+
from importlib.metadata import version
4+
except ImportError: # for Python<3.8
5+
from importlib_metadata import version
46

57
class ApiUrls(Enum):
68
mainnet = 'https://cardano-mainnet.blockfrost.io/api'
@@ -18,4 +20,5 @@ class ApiUrls(Enum):
1820
ADDRESS_GAP_LIMIT = 20
1921

2022
package_name = 'blockfrost-python'
21-
USER_AGENT = f'{package_name} {pkg_resources.get_distribution(package_name).version}'
23+
version = version(package_name)
24+
USER_AGENT = f'{package_name} {version}'

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
keywords='blockfrost blockchain cardano ipfs',
2222
packages=find_packages(exclude=['tests', 'tests.*']),
2323
python_requires='>=3.7, <4',
24+
requires= [
25+
"importlib_metadata",
26+
],
2427
install_requires=[
2528
"requests",
2629
],

0 commit comments

Comments
 (0)