From a7083ed388729140421cc59d882bc7e4811349c1 Mon Sep 17 00:00:00 2001 From: Matt Pate <1699723+mcpate@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:05:12 -0600 Subject: [PATCH 1/3] Fix misspelling --- scripts/generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.py b/scripts/generate.py index d6fd75b7..be1e2fd1 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -248,7 +248,7 @@ def detect_newline(f: TextIO) -> str: def generate_one(variant, mapping, *, console, pip_versions): - # Determing the correct wheel to download + # Determining the correct wheel to download pip_version = determine_latest(pip_versions.keys(), constraint=mapping["pip"]) wheel_url, wheel_hash = pip_versions[pip_version] From b15acd8e685697081258266898316591cca12e7b Mon Sep 17 00:00:00 2001 From: Matt Pate <1699723+mcpate@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:11:51 -0600 Subject: [PATCH 2/3] Update destination to be a directory This will make writing additional files to the directory easier. --- scripts/generate.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/generate.py b/scripts/generate.py index be1e2fd1..874390fe 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -229,11 +229,11 @@ def determine_destination(base: str, variant: str) -> Path: public.mkdir() if variant == "default": - return public / "get-pip.py" + return public - retval = public / variant / "get-pip.py" - if not retval.parent.exists(): - retval.parent.mkdir() + retval = public / variant + if not retval.exists(): + retval.mkdir() return retval @@ -270,10 +270,13 @@ def generate_one(variant, mapping, *, console, pip_versions): wheel_version=mapping["wheel"], minimum_supported_version=mapping["minimum_supported_version"], ) - # Write the script to the correct location + destination = determine_destination("public", variant) - console.log(f" Writing [blue]{destination}") - with destination.open("w", newline=newline) as f: + + # Write the script to the correct location + get_pip = destination / "get-pip.py" + console.log(f" Writing [blue]{get_pip}") + with get_pip.open("w", newline=newline) as f: f.write(rendered_template) From 2d0b977d9c4a7616538894eda531f6467a7f6425 Mon Sep 17 00:00:00 2001 From: Matt Pate <1699723+mcpate@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:36:20 -0600 Subject: [PATCH 3/3] Write a digest for get-pip.py --- scripts/generate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/generate.py b/scripts/generate.py index 874390fe..cb8cad31 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -279,6 +279,12 @@ def generate_one(variant, mapping, *, console, pip_versions): with get_pip.open("w", newline=newline) as f: f.write(rendered_template) + # Write a digest of the script to the correct location + digest = destination / "get-pip.py.sha256" + console.log(f" Writing [blue]{digest}") + with digest.open("w", newline=newline) as f: + f.write(hashlib.sha256(rendered_template.encode("utf-8")).hexdigest()) + def generate_moved(destination: str, *, location: str, console: Console): template = Path("templates") / "moved.py"