From 7db7b956811cbca0a3a3cf9a859d25dd46e1e423 Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 15 Nov 2023 14:14:56 -0500 Subject: [PATCH] Fix: version number in filename for distribution. Signed-off-by: dblock --- setup.py | 5 ++++- utils/build-dists.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index dc613280..6a0a5d13 100644 --- a/setup.py +++ b/setup.py @@ -36,9 +36,12 @@ base_dir = abspath(dirname(__file__)) with open(join(base_dir, package_name.replace("-", ""), "_version.py")) as f: - m = re.search(r"__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']", f.read()) + data = f.read() + m = re.search(r"^__versionstr__: str\s+=\s+[\"\']([^\"\']+)[\"\']", data, re.M) if m: package_version = m.group(1) + else: + raise Exception(f"Invalid version: {data}") with open(join(base_dir, "README.md")) as f: long_description = f.read().strip() diff --git a/utils/build-dists.py b/utils/build-dists.py index 569ed7ea..bca9c154 100644 --- a/utils/build-dists.py +++ b/utils/build-dists.py @@ -194,7 +194,7 @@ def main() -> None: if m: version = m.group(1) else: - raise Exception(f"Invalid version {data}") + raise Exception(f"Invalid version: {data}") major_version = version.split(".")[0] @@ -258,8 +258,8 @@ def main() -> None: with open(version_path) as f: version_data = f.read() version_data = re.sub( - r"__versionstr__ = \"[^\"]+\"", - '__versionstr__ = "%s"' % version, + r"__versionstr__: str = \"[^\"]+\"", + '__versionstr__: str = "%s"' % version, version_data, ) with open(version_path, "w") as f: