about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-13 05:54:11 +0200
committerGitHub <noreply@github.com>2022-04-13 05:54:11 +0200
commitf6dfbfef01e316c1c374ea36c259963ab0c7f4b4 (patch)
treea1f9e5833bb28ca4c43cd84390c9739c498bed69
parent1491e5cc148391f7679542b8e9b4e6d2430a7b69 (diff)
parent03c5f0d2182cc36548b782599412408349b13cbb (diff)
downloadrust-f6dfbfef01e316c1c374ea36c259963ab0c7f4b4.tar.gz
rust-f6dfbfef01e316c1c374ea36c259963ab0c7f4b4.zip
Rollup merge of #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 #95204
r? ```@jyn514```
-rw-r--r--src/bootstrap/lib.rs12
-rw-r--r--src/bootstrap/sanity.rs4
-rw-r--r--src/bootstrap/test.rs9
3 files changed, 15 insertions, 10 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 7b496e6c669..59102ad9f50 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1176,7 +1176,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.
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index 8c2899c1ac0..c96e6f9a367 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -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"));
 
     build.config.nodejs = build
         .config
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index b88684791bc..f60766bde72 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1402,14 +1402,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());
 
         if let Some(ref gdb) = builder.config.gdb {
             cmd.arg("--gdb").arg(gdb);