Skip to content
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

Choose an appropriate python version for x.py at runtime #80585

Closed
wants to merge 1 commit into from

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Jan 1, 2021

Or, how I learned to stop worrying and love the shell.

image

  • Start x.py as a shell script and re-execute the program with the right python interpreter
  • Default to python3 -> python -> python2

Closes #71818.

r? @Mark-Simulacrum

@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jan 1, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 1, 2021
@jyn514 jyn514 force-pushed the python-what-python branch from 8e77d03 to b60bf06 Compare January 1, 2021 17:02
@jyn514
Copy link
Member Author

jyn514 commented Jan 1, 2021

I found that this breaks on CentOS because it doesn't have which available. I'll use command -v instead.

- Default to python3 -> python -> python2
- Start as shell script and re-execute the program with the right python
  interpreter
@jyn514 jyn514 force-pushed the python-what-python branch from b60bf06 to 47980db Compare January 1, 2021 17:27
@jyn514
Copy link
Member Author

jyn514 commented Jan 1, 2021

This breaks in Powershell (probably cmd.exe too, but I don't know how to install that on linux):

ResourceUnavailable: Program 'x.py' failed to run: Exec format errorAt line:1 char:1
+ ./x.py check
+ ~~~~~~~~~~~~.

@jyn514
Copy link
Member Author

jyn514 commented Jan 1, 2021

It looks like servo handles this by having a separate mach.bat bootstrap script, which seems unfortunate :/

@jyn514 jyn514 added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 1, 2021
@nagisa
Copy link
Member

nagisa commented Jan 2, 2021

Are you sure this isn't missing a shebang for shell of some sort?

Running ./x.py on a NixOS system with this PR does not work:

$ git checkout origin/master
$ ./x.py
info: Downloading and building bootstrap before processing --help
      command. See src/bootstrap/README.md for help with common
      commands.
Updating only changed submodules
Updating submodule src/llvm-project
<snip>
$ git checkout origin/pr/80585
$ ./x.py
Failed to execute process './x.py'. Reason:
exec: unknown error (errno was 8)
The file './x.py' is marked as an executable but could not be run by the operating system.

@jyn514
Copy link
Member Author

jyn514 commented Jan 2, 2021

@nagisa most shells will execute files as scripts if they don't have a shebang, what shell are you using?

That said, if this doesn't work even on linux, it's probably not worth pursuing.

@jyn514 jyn514 closed this Jan 2, 2021
@nagisa
Copy link
Member

nagisa commented Jan 2, 2021

I use fish and various non-shell uses would probably break as well.

@jyn514 jyn514 deleted the python-what-python branch January 2, 2021 01:26
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2021
…ulacrum

Choose the version of python at runtime (portable version)

r? `@Mark-Simulacrum`

Fixed version of rust-lang#80585. The goal is to avoid giving 'error: python3 required' when downloading LLVM from CI and instead default to python3 where possible.

This has some minor overhead when you have `python` as python2, but almost nothing compared to actually running the build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust doesn't build without "python" name being available
4 participants