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

On MacOS, bootstrap requires both python and python3 #95204

Closed
jyn514 opened this issue Mar 22, 2022 · 10 comments · Fixed by #95441
Closed

On MacOS, bootstrap requires both python and python3 #95204

jyn514 opened this issue Mar 22, 2022 · 10 comments · Fixed by #95441
Assignees
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Mar 22, 2022

python: https://github.com/rust-lang/rust/blob/beb480d908f091e7c42c866e13641f26b2ee230b/src/bootstrap/sanity.rs#L100-L106
python3: https://github.com/rust-lang/rust/blob/beb480d908f091e7c42c866e13641f26b2ee230b/src/bootstrap/test.rs#L1382-L1386
It sounds like python3 is strictly required for LLDB, so we should move this check from test.rs to builder.python(), which will only require python3 instead of both commands.

cc @Walther

@rustbot label: +E-easy +E-mentor +E-help-wanted +A-rustbuild +A-contributor-roadblock

@rustbot rustbot added A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Mar 22, 2022
@Mark-Simulacrum
Copy link
Member

But not everyone will want to run lldb, right? We only mention /usr/bin/python3 there, we don't actually run it unless lldb tests are run, which is pretty rare.

This may still be an OK change, of course.

@jyn514
Copy link
Member Author

jyn514 commented Mar 22, 2022

Sure - but in that case, we hardly need python at all, only for rustdoc tests, and it seems ok to use the system python.

@pierwill
Copy link
Member

I would actually support requiring Python 3 in any case.

@jyn514
Copy link
Member Author

jyn514 commented Mar 22, 2022

@pierwill let's please keep discussion about 2 vs 3 in #71818 and not relitigate it on each issue that mentions python.

@AlecGoncharow
Copy link
Contributor

@rustbot claim

@AlecGoncharow
Copy link
Contributor

If I understand the issue here correctly, just moving the check from test.rs to the builder.python() doesn't entirely remove the issue of needing the python name defined on MacOS given the call to cmd_finder.must_have("python") in sanity.rs. To resolve this should the check in sanity.rs include a MacOS specific check for /usr/bin/python3 or an additional check for python3?

@jyn514
Copy link
Member Author

jyn514 commented Mar 24, 2022

To resolve this should the check in sanity.rs include a MacOS specific check for /usr/bin/python3 or an additional check for python3?

The former - it should just use /usr/bin/python3 any time it needs python on MacOS, and remove the existing check for python on that platform.

@AlecGoncharow
Copy link
Contributor

About to raise a PR, but is it even necessary to perform any check in builder.python() if we are always forcing /usr/bin/python3 in sanity.rs? Are there instances where sanity::check won't be called before CompileTest::run?

Also first time using x.py, what would be the correct test to run here?

@jyn514
Copy link
Member Author

jyn514 commented Mar 24, 2022

Is it even necessary to perform any check in builder.python() if we are always forcing /usr/bin/python3 in sanity.rs?

I don't think it's necessary to check in both places, no, you can return /usr/bin/python3 unconditionally in builder.python(). Whether you can remove the check in sanity.rs is a question for @Mark-Simulacrum - I think probably yes, since you can still run the build without python, but it doesn't necessarily need to go in the same change switching to /bin/python3 consistently.

Also first time using x.py, what would be the correct test to run here?

Basically everything runs the check in sanity.rs, but I think it's only relevant when BOOTSTRAP_PYTHON is unset, so probably you'll need cargo run check to make sure the check executes. If you want to check the version of python used works, you can run cargo run test --stage 1 src/test/rustdoc.

@Mark-Simulacrum
Copy link
Member

If we can rely on /usr/bin/python3 always existing on macOS there's no need to check for it, but I would expect that the code in sanity.rs isn't platform-specific and so should continue to look for python in a variety of ways (likely the same ways across all platforms).

It looks like python is currently used for two separate things: lldb tests, and docck. The latter likely works with python 2 and python 3, or at least, so it's likely that we need to leave the discovery and configuration in place. Certainly on e.g. Windows /usr/bin/python3 is not expected to exist, I believe.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 13, 2022
…rk-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`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 13, 2022
…rk-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``
@bors bors closed this as completed in f6dfbfe Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants