mirror of https://github.com/astral-sh/uv
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:
parent
06f2b6eee2
commit
1509070316
|
|
@ -92,12 +92,14 @@ def sha256_file(path: Path):
|
|||
versions_metadata = json.loads(VERSIONS_METADATA_FILE.read_text())
|
||||
versions = VERSIONS_FILE.read_text().splitlines()
|
||||
|
||||
if INSTALL_DIR.exists():
|
||||
print("Removing existing installations...")
|
||||
shutil.rmtree(INSTALL_DIR)
|
||||
|
||||
# Install each version
|
||||
for version in versions:
|
||||
key = f"{INTERPRETER}-{version}-{PLATFORM_MAP.get(PLATFORM, PLATFORM)}-{ARCH_MAP.get(ARCH, ARCH)}"
|
||||
install_dir = INSTALL_DIR / f"{INTERPRETER}@{version}"
|
||||
already_exists = False
|
||||
print(f"Installing {key}")
|
||||
|
||||
url = versions_metadata[key]["url"]
|
||||
|
|
@ -107,43 +109,39 @@ for version in versions:
|
|||
sys.exit(1)
|
||||
|
||||
filename = url.split("/")[-1]
|
||||
if not install_dir.exists():
|
||||
print(f"Downloading {urllib.parse.unquote(filename)}")
|
||||
download_path = THIS_DIR / filename
|
||||
with urllib.request.urlopen(url) as response:
|
||||
with download_path.open("wb") as download_file:
|
||||
shutil.copyfileobj(response, download_file)
|
||||
print(f"Downloading {urllib.parse.unquote(filename)}")
|
||||
download_path = THIS_DIR / filename
|
||||
with urllib.request.urlopen(url) as response:
|
||||
with download_path.open("wb") as download_file:
|
||||
shutil.copyfileobj(response, download_file)
|
||||
|
||||
sha = versions_metadata[key]["sha256"]
|
||||
if not sha:
|
||||
print(f"WARNING: no checksum for {key}")
|
||||
else:
|
||||
print("Verifying checksum...", end="")
|
||||
if sha256_file(download_path) != sha:
|
||||
print(" FAILED!")
|
||||
sys.exit(1)
|
||||
print(" OK")
|
||||
|
||||
if install_dir.exists():
|
||||
shutil.rmtree(install_dir)
|
||||
print("Extracting to", install_dir)
|
||||
install_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
decompress_file(THIS_DIR / filename, install_dir.with_suffix(".tmp"))
|
||||
|
||||
# Setup the installation
|
||||
(install_dir.with_suffix(".tmp") / "python").rename(install_dir)
|
||||
sha = versions_metadata[key]["sha256"]
|
||||
if not sha:
|
||||
print(f"WARNING: no checksum for {key}")
|
||||
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")
|
||||
print("Verifying checksum...", end="")
|
||||
if sha256_file(download_path) != sha:
|
||||
print(" FAILED!")
|
||||
sys.exit(1)
|
||||
print(" OK")
|
||||
|
||||
if install_dir.exists():
|
||||
shutil.rmtree(install_dir)
|
||||
print("Extracting to", install_dir)
|
||||
install_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
decompress_file(THIS_DIR / filename, install_dir.with_suffix(".tmp"))
|
||||
|
||||
# Setup the installation
|
||||
(install_dir.with_suffix(".tmp") / "python").rename(install_dir)
|
||||
|
||||
if PLATFORM == "win32":
|
||||
executable = install_dir / "install" / "python.exe"
|
||||
else:
|
||||
# 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"]
|
||||
minor = versions_metadata[key]["minor"]
|
||||
|
|
@ -164,10 +162,7 @@ for version in versions:
|
|||
else:
|
||||
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
|
||||
install_dir.with_suffix(".tmp").rmdir()
|
||||
|
|
|
|||
Loading…
Reference in New Issue