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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,17 @@ impl Build {

/// Path to the python interpreter to use
fn python(&self) -> &Path {
self.config.python.as_ref().unwrap()
if self.config.build.ends_with("apple-darwin") {
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
// LLDB plugin's compiled module which only works with the system python
// (namely not Homebrew-installed python)
Path::new("/usr/bin/python3")
} else {
self.config
.python
.as_ref()
.expect("python is required for running LLDB or rustdoc tests")
}
}

/// Temporary directory that extended error information is emitted to.
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ pub fn check(build: &mut Build) {
.take()
.map(|p| cmd_finder.must_have(p))
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
.or_else(|| Some(cmd_finder.must_have("python")));
.or_else(|| cmd_finder.maybe_have("python"))
.or_else(|| cmd_finder.maybe_have("python3"))
.or_else(|| cmd_finder.maybe_have("python2"));
Comment on lines +106 to +108
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

@AlecGoncharow AlecGoncharow Mar 29, 2022

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


build.config.nodejs = build
.config
Expand Down
9 changes: 1 addition & 8 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,14 +1403,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the

cmd.arg("--docck-python").arg(builder.python());

if builder.config.build.ends_with("apple-darwin") {
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
// LLDB plugin's compiled module which only works with the system python
// (namely not Homebrew-installed python)
cmd.arg("--lldb-python").arg("/usr/bin/python3");
} 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.


if let Some(ref gdb) = builder.config.gdb {
cmd.arg("--gdb").arg(gdb);
Expand Down