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

Always use system python3 on MacOS #95441

Merged
merged 2 commits into from Apr 13, 2022
Merged

Conversation

AlecGoncharow
Copy link
Contributor

This PR includes 2 changes:

  1. Always use the system Python found at /usr/bin/python3 on MacOS
  2. Removes the hard requirement on having python in your system path if you didn't specify alternatives. The proposed change will instead attempt to find and use in order: python -> python3 -> python2. This change isn't strictly necessary but without any change to this check, the original issue inspiring this change will still exist.

Fixes #95204
r? @jyn514

@jyn514
Copy link
Member

jyn514 commented Mar 29, 2022

I no longer have r+ privileges.

r? @Mark-Simulacrum (but I'm happy to own this review and let you just be a rubber stamp if that's what you prefer)

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Walther Can you confirm that this fixes cargo +beta build --bins && cargo +beta run check for you?

Comment on lines +106 to +108
.or_else(|| cmd_finder.maybe_have("python"))
.or_else(|| cmd_finder.maybe_have("python3"))
.or_else(|| cmd_finder.maybe_have("python2"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this also matches what src/tools/x does :)

for dir in env::split_paths(&val) {
if dir.join(PYTHON).exists() {
return PYTHON;
}
python2 |= dir.join(PYTHON2).exists();
python3 |= dir.join(PYTHON3).exists();
}
if python3 {
PYTHON3
} else if python2 {
PYTHON2
} else {
PYTHON
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose a slightly different order, I went with letting whatever the system deems the "One True python" would be safer to go with first. Seems that one goes python3 -> python2 -> python, happy to mimic that order.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, your logic matches what it does: #95443

// (namely not Homebrew-installed python)
Path::new("/usr/bin/python3")
} else {
self.config.python.as_ref().unwrap()
Copy link
Member

@jyn514 jyn514 Mar 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, one comment - this unwrap will fail if no python at all is installed. So it would be nice to give a more helpful error message, something like

Suggested change
self.config.python.as_ref().unwrap()
self.config.python.as_ref().expect("python is required for running LLDB or rustdoc tests")

(I think right now we'll require it unconditionally for anything that uses compiletest, but we can fix that later.)

@Walther
Copy link

Walther commented Mar 29, 2022

@Walther Can you confirm that this fixes cargo +beta build --bins && cargo +beta run check for you?

Can confirm, on commit 03c5f0d2182cc36548b782599412408349b13cbb running cargo +beta build --bins && cargo +beta run check completes successfully 👍 Thanks for the fix ❤️

This was on macOS Monterey 12.3 - I don't have a mac with an older OS installed so I cannot double-check that it works on the older ones. I think python3 should exist on those too, but might be worth double-checking if someone has a device that hasn't been updated to latest yet.

@jyn514
Copy link
Member

jyn514 commented Mar 29, 2022

If the older OS's don't have python3, they would have failed even before this change. No one has complained so far, so I think it's fine not to worry about it.

@jyn514
Copy link
Member

jyn514 commented Apr 13, 2022

@rustbot label +S-waiting-on-review

@AlecGoncharow I'm not actually part of the rust org - can you run r? @Mark-Simulacrum to assign him as the reviewer?

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 13, 2022
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 13, 2022

📌 Commit 03c5f0d has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2022
@Mark-Simulacrum Mark-Simulacrum self-assigned this Apr 13, 2022
} else {
cmd.arg("--lldb-python").arg(builder.python());
}
cmd.arg("--lldb-python").arg(builder.python());
Copy link
Member

@jyn514 jyn514 Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be part of this PR, but it would be nice eventually to just have --python and remove the --lldb-python / --docck-python args from compiletest.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 13, 2022
…rk-Simulacrum

Always use system `python3` on MacOS

This PR includes 2 changes:

1. Always use the system Python found at `/usr/bin/python3` on MacOS
2. Removes the hard requirement on having `python` in your system path if you didn't specify alternatives. The proposed change will instead attempt to find and use in order: `python` -> `python3` -> `python2`. This change isn't strictly necessary but without any change to this check, the original issue inspiring this change will still exist.

Fixes rust-lang#95204
r? `@jyn514`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 13, 2022
…rk-Simulacrum

Always use system `python3` on MacOS

This PR includes 2 changes:

1. Always use the system Python found at `/usr/bin/python3` on MacOS
2. Removes the hard requirement on having `python` in your system path if you didn't specify alternatives. The proposed change will instead attempt to find and use in order: `python` -> `python3` -> `python2`. This change isn't strictly necessary but without any change to this check, the original issue inspiring this change will still exist.

Fixes rust-lang#95204
r? ``@jyn514``
This was referenced Apr 13, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2022
Rollup of 4 pull requests

Successful merges:

 - rust-lang#95441 (Always use system `python3` on MacOS)
 - rust-lang#95954 (Fix broken link in coverage tools docs)
 - rust-lang#95984 (Fix spelling in docs for `can_not_overflow`)
 - rust-lang#95989 (diagnostics: regression test for spurrious "help: store this in the heap")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f6dfbfe into rust-lang:master Apr 13, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On MacOS, bootstrap requires both python and python3
7 participants