We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 556c938 commit 1bf73b7Copy full SHA for 1bf73b7
setup.py
@@ -72,8 +72,18 @@ def list2cmdline(cmd_list):
72
73
pkg_root_init_file = package_dir / "__init__.py"
74
for line in pkg_root_init_file.read_text().split("\n"):
75
- if line.startswith("__version__ = "):
76
- package["version"] = eval(line.split("=", 1)[1])
+ if line.startswith('__version__ = "') and line.endswith('" # DO NOT MODIFY'):
+ 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
+ )
87
break
88
else:
89
print(f"No version found in {pkg_root_init_file}")
0 commit comments