Skip to content

Commit d30560c

Browse files
author
Muhammad Naufal Andika Natsir Putra
committed
feat: adjust how to get version from version.py
1 parent 098cbd3 commit d30560c

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

engines/pyfunc-ensembler-job/setup.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import setuptools
22
import pathlib
33
import pkg_resources
4-
import importlib.util
5-
import os
64

75
# get version from version.py
8-
spec = importlib.util.spec_from_file_location(
9-
"pyfuncserver.version", os.path.join("version.py")
10-
)
11-
12-
v_module = importlib.util.module_from_spec(spec)
13-
spec.loader.exec_module(v_module)
14-
15-
version = v_module.VERSION
6+
with pathlib.Path("version.py").open() as version_py:
7+
_locals = locals()
8+
exec(version_py.read(), globals(), _locals)
9+
version = _locals["VERSION"]
1610

1711
with pathlib.Path("requirements.txt").open() as requirements_txt:
1812
requirements = [

engines/pyfunc-ensembler-service/setup.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import setuptools
22
import pathlib
33
import pkg_resources
4-
import importlib.util
5-
import os
64

75
# get version from version.py
8-
spec = importlib.util.spec_from_file_location(
9-
"pyfuncserver.version", os.path.join("version.py")
10-
)
11-
12-
v_module = importlib.util.module_from_spec(spec)
13-
spec.loader.exec_module(v_module)
14-
15-
version = v_module.VERSION
6+
with pathlib.Path("version.py").open() as version_py:
7+
_locals = locals()
8+
exec(version_py.read(), globals(), _locals)
9+
version = _locals["VERSION"]
1610

1711
with pathlib.Path("requirements.txt").open() as requirements_txt:
1812
requirements = [

0 commit comments

Comments
 (0)