Skip to content

Add a digest for each get-pip.py file #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]

Expand All @@ -270,12 +270,21 @@ 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)

# 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"
Expand Down
Loading