Skip to content

Commit 3f872b2

Browse files
authored
Rollup merge of rust-lang#58676 - euclio:bootstrap-python, r=alexcrichton
look for python2 symlinks before bootstrap python Before this commit, if you're running x.py directly on a system where `python` is symlinked to Python 3, then the `python` config option will default to a Python 3 interpreter. This causes debuginfo tests to fail with an opaque error message, since they have a hard requirement on Python 2. This commit modifies the Python probe behavior to look for python2.7 and python2 *before* using the interpreter used to execute `x.py`.
2 parents 0c4cb48 + 12d8a7d commit 3f872b2

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
# Python interpreter to use for various tasks throughout the build, notably
165165
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
166166
# Note that Python 2 is currently required.
167+
#
168+
# Defaults to python2.7, then python2. If neither executable can be found, then
169+
# it defaults to the Python interpreter used to execute x.py.
167170
#python = "python2.7"
168171

169172
# Force Cargo to check that Cargo.lock describes the precise dependency

src/bootstrap/sanity.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ impl Finder {
3434

3535
fn maybe_have<S: AsRef<OsStr>>(&mut self, cmd: S) -> Option<PathBuf> {
3636
let cmd: OsString = cmd.as_ref().into();
37-
let path = self.path.clone();
37+
let path = &self.path;
3838
self.cache.entry(cmd.clone()).or_insert_with(|| {
39-
for path in env::split_paths(&path) {
39+
for path in env::split_paths(path) {
4040
let target = path.join(&cmd);
41-
let mut cmd_alt = cmd.clone();
42-
cmd_alt.push(".exe");
43-
if target.is_file() || // some/path/git
44-
target.with_extension("exe").exists() || // some/path/git.exe
45-
target.join(&cmd_alt).exists() { // some/path/git/git.exe
41+
let mut cmd_exe = cmd.clone();
42+
cmd_exe.push(".exe");
43+
44+
if target.is_file() // some/path/git
45+
|| path.join(&cmd_exe).exists() // some/path/git.exe
46+
|| target.join(&cmd_exe).exists() // some/path/git/git.exe
47+
{
4648
return Some(target);
4749
}
4850
}
@@ -107,9 +109,9 @@ pub fn check(build: &mut Build) {
107109
}
108110

109111
build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))
110-
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
111112
.or_else(|| cmd_finder.maybe_have("python2.7"))
112113
.or_else(|| cmd_finder.maybe_have("python2"))
114+
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
113115
.or_else(|| Some(cmd_finder.must_have("python")));
114116

115117
build.config.nodejs = build.config.nodejs.take().map(|p| cmd_finder.must_have(p))

0 commit comments

Comments
 (0)