Switch rustup_wrapper to Rust implementation

For better Windows portability
This commit is contained in:
topjohnwu
2024-05-09 02:19:07 -07:00
parent 3f2264f2c7
commit f61827cbec
6 changed files with 155 additions and 44 deletions

View File

@ -638,10 +638,16 @@ def setup_rustup(args):
for src in cargo_bin.iterdir():
tgt = wrapper_dir / src.name
tgt.symlink_to(src)
# Replace rustup with python script
wrapper = wrapper_dir / "rustup"
wrapper.unlink()
cp(Path("scripts", "rustup_wrapper.py"), wrapper)
# Build rustup_wrapper
wrapper_src = Path("tools", "rustup_wrapper")
cargo_toml = wrapper_src / "Cargo.toml"
execv([cargo, "build", "--release", f"--manifest-path={cargo_toml}"])
# Replace rustup with wrapper
wrapper = wrapper_dir / (f"rustup{EXE_EXT}")
wrapper.unlink(missing_ok=True)
cp(wrapper_src / "target" / "release" / (f"rustup_wrapper{EXE_EXT}"), wrapper)
wrapper.chmod(0o755)