Skip to content

Commit 4085f16

Browse files
authored
Rollup merge of rust-lang#95441 - AlecGoncharow:issue-95204-fix, r=Mark-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`
2 parents 1491e5c + 03c5f0d commit 4085f16

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/bootstrap/lib.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,17 @@ impl Build {
11761176

11771177
/// Path to the python interpreter to use
11781178
fn python(&self) -> &Path {
1179-
self.config.python.as_ref().unwrap()
1179+
if self.config.build.ends_with("apple-darwin") {
1180+
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1181+
// LLDB plugin's compiled module which only works with the system python
1182+
// (namely not Homebrew-installed python)
1183+
Path::new("/usr/bin/python3")
1184+
} else {
1185+
self.config
1186+
.python
1187+
.as_ref()
1188+
.expect("python is required for running LLDB or rustdoc tests")
1189+
}
11801190
}
11811191

11821192
/// Temporary directory that extended error information is emitted to.

src/bootstrap/sanity.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ pub fn check(build: &mut Build) {
103103
.take()
104104
.map(|p| cmd_finder.must_have(p))
105105
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
106-
.or_else(|| Some(cmd_finder.must_have("python")));
106+
.or_else(|| cmd_finder.maybe_have("python"))
107+
.or_else(|| cmd_finder.maybe_have("python3"))
108+
.or_else(|| cmd_finder.maybe_have("python2"));
107109

108110
build.config.nodejs = build
109111
.config

src/bootstrap/test.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1402,14 +1402,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
14021402

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

1405-
if builder.config.build.ends_with("apple-darwin") {
1406-
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1407-
// LLDB plugin's compiled module which only works with the system python
1408-
// (namely not Homebrew-installed python)
1409-
cmd.arg("--lldb-python").arg("/usr/bin/python3");
1410-
} else {
1411-
cmd.arg("--lldb-python").arg(builder.python());
1412-
}
1405+
cmd.arg("--lldb-python").arg(builder.python());
14131406

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

0 commit comments

Comments
 (0)