Skip to content

Commit 4874437

Browse files
authored
Fix: version number in filename for distribution. (opensearch-project#588)
Signed-off-by: dblock <dblock@amazon.com>
1 parent a0e8bd7 commit 4874437

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@
3636
base_dir = abspath(dirname(__file__))
3737

3838
with open(join(base_dir, package_name.replace("-", ""), "_version.py")) as f:
39-
m = re.search(r"__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']", f.read())
39+
data = f.read()
40+
m = re.search(r"^__versionstr__: str\s+=\s+[\"\']([^\"\']+)[\"\']", data, re.M)
4041
if m:
4142
package_version = m.group(1)
43+
else:
44+
raise Exception(f"Invalid version: {data}")
4245

4346
with open(join(base_dir, "README.md")) as f:
4447
long_description = f.read().strip()

utils/build-dists.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def main() -> None:
194194
if m:
195195
version = m.group(1)
196196
else:
197-
raise Exception(f"Invalid version {data}")
197+
raise Exception(f"Invalid version: {data}")
198198

199199
major_version = version.split(".")[0]
200200

@@ -258,8 +258,8 @@ def main() -> None:
258258
with open(version_path) as f:
259259
version_data = f.read()
260260
version_data = re.sub(
261-
r"__versionstr__ = \"[^\"]+\"",
262-
'__versionstr__ = "%s"' % version,
261+
r"__versionstr__: str = \"[^\"]+\"",
262+
'__versionstr__: str = "%s"' % version,
263263
version_data,
264264
)
265265
with open(version_path, "w") as f:

0 commit comments

Comments
 (0)