Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 475d682

Browse files
tacaswelluglide
andauthored
MNT: do not use deprecated load_module method (#218)
The load_module method has been deprecated from py34 and will be removed in py315 [1] (it is already gone on CPython main). The recommended replacement is exec_module, however the documentation [2] suggests to use a simpler approach than using the loaders directly and runpy [3] seemed better than sys.path hacking. Given that this is a one-line file simply reading the file and parsing it 'by hand' is an option. [1] https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module [2] https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly [3] https://docs.python.org/3/library/runpy.html#runpy.run_path Co-authored-by: Igor Malinovskiy <[email protected]>
1 parent 8c2fcc6 commit 475d682

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
from setuptools import setup, Extension
55
except ImportError:
66
from distutils.core import setup, Extension
7-
import importlib
7+
import runpy
88
import glob
99
import io
1010
import sys
1111

1212

1313
def version():
14-
loader = importlib.machinery.SourceFileLoader(
15-
"hiredis.version", "hiredis/version.py")
16-
module = loader.load_module()
17-
return module.__version__
14+
return runpy.run_path("hiredis/version.py")["__version__"]
1815

1916

2017
def get_sources():

0 commit comments

Comments
 (0)