Skip to content

Commit

Permalink
build: make setup.cfg generator easier to use
Browse files Browse the repository at this point in the history
Now needs just the Python package tag argument.
  • Loading branch information
scop committed Nov 16, 2023
1 parent be3bfa3 commit b6e8f21
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions generate_setup_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
setup_cfg_template = """
[metadata]
name = wrun_py
version = ${pkg_version}
version = ${python_pkg_version}
description = Web executable launcher
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -118,16 +118,19 @@ def process_checksums(url: str) -> dict[str, str]:
return data


def main(pkg_version: str, checksums_txt_url: str) -> None:
def main(python_pkg_tag: str) -> None:
main_tag, _, _ = python_pkg_tag.partition("-")
main_version = main_tag.lstrip("v")
checksums_txt_url = f"https://github.com/scop/wrun/releases/download/{urlquote(main_tag)}/wrun_{urlquote(main_version)}_checksums.txt"
data = process_checksums(checksums_txt_url)
data["pkg_version"] = pkg_version.lstrip("v")
data["python_pkg_version"] = python_pkg_tag.lstrip("v")
st = string.Template(setup_cfg_template.lstrip())
setup_cfg = st.substitute(data)
sys.stdout.write(setup_cfg)


if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"usage: {sys.argv[0]} PKG-VERSION CHECKSUMS-TXT-URL")
if len(sys.argv) != 2:
print(f"usage: {sys.argv[0]} PYTHON-PKG-TAG")
sys.exit(2)
main(sys.argv[1], sys.argv[2])
main(sys.argv[1])

0 comments on commit b6e8f21

Please sign in to comment.