Skip to content

Commit fd4a24d

Browse files
committed
get version number via importlib in newer versions of Python
1 parent 3826214 commit fd4a24d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

fmrest/const.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
"""fmrest constants"""
22
import os
33
from enum import Enum, unique
4-
from pkg_resources import get_distribution
54
from typing import Dict, Any
65

7-
__version__ = get_distribution('python-fmrest').version
6+
PACKAGE_NAME = 'python-fmrest'
7+
8+
try:
9+
from importlib.metadata import version # Python 3.8+
10+
__version__ = version(PACKAGE_NAME)
11+
except ImportError:
12+
from pkg_resources import get_distribution # Python 3.6-3.7
13+
__version__ = get_distribution(PACKAGE_NAME).version
814

915
PORTAL_PREFIX = 'portal_'
1016
TIMEOUT = int(os.environ.get('fmrest_timeout', 10))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='python-fmrest',
8-
version='1.7.4',
8+
version='1.7.5',
99
python_requires='>=3.6',
1010
author='David Hamann',
1111
author_email='dh@davidhamann.de',

0 commit comments

Comments
 (0)