Skip to content

Commit 88ebf91

Browse files
authored
Rollup merge of #148636 - xSetech:boostrap/set-python-on-macos, r=jieyouxu
bootstrap: respect `build.python` on macOS The `python()` method was hardcoded to return `/usr/bin/python3` on macOS, ignoring the `build.python` config option. This change respects the config while maintaining the system Python as the default.
2 parents 460d729 + 191a3e3 commit 88ebf91

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,9 @@ Please disable assertions with `rust.debug-assertions = false`.
20752075
cmd.arg("--target-rustcflags").arg(flag);
20762076
}
20772077

2078-
cmd.arg("--python").arg(builder.python());
2078+
cmd.arg("--python").arg(
2079+
builder.config.python.as_ref().expect("python is required for running rustdoc tests"),
2080+
);
20792081

20802082
// FIXME(#148099): Currently we set these Android-related flags in all
20812083
// modes, even though they should only be needed in "debuginfo" mode,
@@ -3359,7 +3361,9 @@ impl Step for BootstrapPy {
33593361
}
33603362

33613363
fn run(self, builder: &Builder<'_>) -> Self::Output {
3362-
let mut check_bootstrap = command(builder.python());
3364+
let mut check_bootstrap = command(
3365+
builder.config.python.as_ref().expect("python is required for running bootstrap tests"),
3366+
);
33633367
check_bootstrap
33643368
.args(["-m", "unittest", "bootstrap_test.py"])
33653369
// Forward command-line args after `--` to unittest, for filtering etc.

src/bootstrap/src/core/sanity.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
//! Sanity checking performed by bootstrap before actually executing anything.
1+
//! Sanity checking and tool selection performed by bootstrap.
22
//!
3-
//! This module contains the implementation of ensuring that the build
4-
//! environment looks reasonable before progressing. This will verify that
5-
//! various programs like git and python exist, along with ensuring that all C
6-
//! compilers for cross-compiling are found.
3+
//! This module ensures that the build environment is correctly set up before
4+
//! executing any build tasks. It verifies required programs exist (like git and
5+
//! cmake when needed), selects some tools based on the environment (like the
6+
//! Python interpreter), and validates that C compilers for cross-compiling are
7+
//! available.
78
//!
89
//! In theory if we get past this phase it's a bug if a build fails, but in
910
//! practice that's likely not true!

src/bootstrap/src/lib.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,21 +1522,6 @@ impl Build {
15221522
self.config.target_config.get(&target).and_then(|t| t.qemu_rootfs.as_ref()).map(|p| &**p)
15231523
}
15241524

1525-
/// Path to the python interpreter to use
1526-
fn python(&self) -> &Path {
1527-
if self.config.host_target.ends_with("apple-darwin") {
1528-
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1529-
// LLDB plugin's compiled module which only works with the system python
1530-
// (namely not Homebrew-installed python)
1531-
Path::new("/usr/bin/python3")
1532-
} else {
1533-
self.config
1534-
.python
1535-
.as_ref()
1536-
.expect("python is required for running LLDB or rustdoc tests")
1537-
}
1538-
}
1539-
15401525
/// Temporary directory that extended error information is emitted to.
15411526
fn extended_error_dir(&self) -> PathBuf {
15421527
self.out.join("tmp/extended-error-metadata")

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
576576
severity: ChangeSeverity::Info,
577577
summary: "`llvm.enzyme` now works with `download-ci-llvm=true`.",
578578
},
579+
ChangeInfo {
580+
change_id: 148636,
581+
severity: ChangeSeverity::Info,
582+
summary: "The `build.python` option is now respected on macOS (previously ignored and forced to be /usr/bin/python3).",
583+
},
579584
];

0 commit comments

Comments
 (0)