Skip to content

Commit 1bf73b7

Browse files
committed
remove eval from setup.py
1 parent 556c938 commit 1bf73b7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

setup.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,18 @@ def list2cmdline(cmd_list):
7272

7373
pkg_root_init_file = package_dir / "__init__.py"
7474
for line in pkg_root_init_file.read_text().split("\n"):
75-
if line.startswith("__version__ = "):
76-
package["version"] = eval(line.split("=", 1)[1])
75+
if line.startswith('__version__ = "') and line.endswith('" # DO NOT MODIFY'):
76+
package["version"] = (
77+
line
78+
# get assignment value
79+
.split("=", 1)[1]
80+
# remove "DO NOT MODIFY" comment
81+
.split("#", 1)[0]
82+
# clean up leading/trailing space
83+
.strip()
84+
# remove the quotes
85+
[1:-1]
86+
)
7787
break
7888
else:
7989
print(f"No version found in {pkg_root_init_file}")

0 commit comments

Comments
 (0)