-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Hi, it's me again 😅
Just discovered the rustup binary changes behavior according to its filename, like so:
❯ ./rustup
rustup 1.28.2 (e4f3ad6f8 2025-04-28)
The Rust toolchain installer
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
❯ cp rustup rustup-init
❯ ./rustup-init
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
...
1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
It's very interesting to have rustup-init as it creates $CARGO_HOME/bin/* symlinks to a toolchain, while regular rustup can "only" be used to download new targets and toolchains (it doesn't install files where we shall have in PATH)
As wheels doesn't supports symlinks, it can be done with shims.
From what I know, they work by calling os.execv(program, argv) where argv[0] will trick rustup into being another filename. I'll investigate this further tomorrow, maybe multiple [project.scripts] entry points could work
# rustup/__main__.py
from pathlib import Path
import os
def path() -> Path:
# Get .venv/{bin,scripts}/rustup{ext}
...
def rustup_init(*args: str):
rustup: Path = path()
os.execv(rustup, ("rustup-init", *args))
def cargo(*args: str):
rustup: Path = path()
os.execv(rustup, ("cargo", *args))
# ...Metadata
Metadata
Assignees
Labels
No labels