Reset the bootstrapped binaries on install (#1317)

There was not much benefit to avoiding the new download (and it was
broken in some Windows compatibility work) and this ensures there are
_only_ the versions we specified
This commit is contained in:
Zanie Blue 2024-02-15 12:08:38 -06:00 committed by GitHub
parent 06f2b6eee2
commit 1509070316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 35 deletions

View File

@ -92,12 +92,14 @@ def sha256_file(path: Path):
versions_metadata = json.loads(VERSIONS_METADATA_FILE.read_text()) versions_metadata = json.loads(VERSIONS_METADATA_FILE.read_text())
versions = VERSIONS_FILE.read_text().splitlines() versions = VERSIONS_FILE.read_text().splitlines()
if INSTALL_DIR.exists():
print("Removing existing installations...")
shutil.rmtree(INSTALL_DIR)
# Install each version # Install each version
for version in versions: for version in versions:
key = f"{INTERPRETER}-{version}-{PLATFORM_MAP.get(PLATFORM, PLATFORM)}-{ARCH_MAP.get(ARCH, ARCH)}" key = f"{INTERPRETER}-{version}-{PLATFORM_MAP.get(PLATFORM, PLATFORM)}-{ARCH_MAP.get(ARCH, ARCH)}"
install_dir = INSTALL_DIR / f"{INTERPRETER}@{version}" install_dir = INSTALL_DIR / f"{INTERPRETER}@{version}"
already_exists = False
print(f"Installing {key}") print(f"Installing {key}")
url = versions_metadata[key]["url"] url = versions_metadata[key]["url"]
@ -107,7 +109,6 @@ for version in versions:
sys.exit(1) sys.exit(1)
filename = url.split("/")[-1] filename = url.split("/")[-1]
if not install_dir.exists():
print(f"Downloading {urllib.parse.unquote(filename)}") print(f"Downloading {urllib.parse.unquote(filename)}")
download_path = THIS_DIR / filename download_path = THIS_DIR / filename
with urllib.request.urlopen(url) as response: with urllib.request.urlopen(url) as response:
@ -133,17 +134,14 @@ for version in versions:
# Setup the installation # Setup the installation
(install_dir.with_suffix(".tmp") / "python").rename(install_dir) (install_dir.with_suffix(".tmp") / "python").rename(install_dir)
else:
# We need to update executables even if the version is already downloaded and extracted
# to ensure that changes to the precedence of versions are respected
already_exists = True
print("Already available, skipping download")
if PLATFORM == "win32": if PLATFORM == "win32":
executable = install_dir / "install" / "python.exe" executable = install_dir / "install" / "python.exe"
else: else:
# Use relative paths for links so if the bin is moved they don't break # Use relative paths for links so if the bin is moved they don't break
executable = "." / install_dir.relative_to(BIN_DIR) / "install" / "bin" / "python3" executable = (
"." / install_dir.relative_to(BIN_DIR) / "install" / "bin" / "python3"
)
major = versions_metadata[key]["major"] major = versions_metadata[key]["major"]
minor = versions_metadata[key]["minor"] minor = versions_metadata[key]["minor"]
@ -164,9 +162,6 @@ for version in versions:
else: else:
target.symlink_to(executable) target.symlink_to(executable)
if already_exists:
print(f"Updated executables for python{version}")
else:
print(f"Installed executables for python{version}") print(f"Installed executables for python{version}")
# Cleanup # Cleanup