Skip to content

Commit a52fb50

Browse files
committed
Update setup.py to use the importlib module instead of the deprecated imp module to dynamically retrieve version
1 parent 567790a commit a52fb50

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import os
2-
import imp
1+
import importlib
2+
from pathlib import Path
33
from setuptools import setup
44
from setuptools import find_packages
55

6-
VERSION = imp.load_source(
7-
'ivis.version', os.path.join('ivis', 'version.py')).VERSION
6+
def get_ivis_version():
7+
spec = importlib.util.spec_from_file_location(
8+
'ivis.version', str(Path('ivis/version.py')))
9+
module = importlib.util.module_from_spec(spec)
10+
spec.loader.exec_module(module)
11+
return module.VERSION
12+
13+
VERSION = get_ivis_version()
814

915
with open('README.md') as f:
1016
long_description = f.read()

0 commit comments

Comments
 (0)