-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore: clean up runtime code for python setup #26042
base: main
Are you sure you want to change the base?
Conversation
3911d3d
to
a4be1b8
Compare
143a880
to
87ae90e
Compare
@jacksonrnewhouse - rebased on main and retested on linux/amd64. This is ready to review for the approach. If you're generally happy with it, I'll do full testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
fn get_python_version() -> Result<(u8, u8), std::io::Error> { | ||
// Find the python installation location (not virtual env). | ||
// XXX: use build flag? | ||
fn find_python_install() -> PathBuf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have this return an Option<PathBuf>
rather than an empty PathBuf.
@jacksonrnewhouse - thanks for the review! In doing further testing and looking at #26050, I need followup commits (which may end up fixing #26050 in the process). UPDATE: I'm going to mark this as DRAFT just to be sure that it doesn't get committed before I have those ready. |
Since you approved, I'll take that to mean that you like the approach. When I have the follow-up commits ready, I'll do full testing and list it in this issue, then undraft. |
ccd5d22 introduced working but temporary code for setting up the python runtime environment. This cleans that up: * refactor various find_python() functionality into virtualenv.rs * refactor PYTHONHOME calculation to virtualenv.rs:find_python_install() * adjust init_pyo3() to temporarily set PYTHONHOME based on virtualenv.rs:find_python_install() as this is the only place it is needed (indeed, venv activation scripts try to remove it) Importantly, virtualenv.rs:find_python_install() tries to find the python build standalone runtime based on a few heuristics. This function could be improved in the fullness of time to, eg, be configured via a build parameter. Also, virtualenv.rs:find_python() can be used pre and post venv activation. Before entering the venv, it will use find_python_install() which is useful for things like setting up the initial venv. After entering the venv, it will honor VIRTUAL_ENV (as set by virtualenv.rs:initialize_venv()) to find python, which is important for install packages with pip and having them installed into the venv.
87ae90e
to
c5c542d
Compare
ccd5d22 introduced working but temporary code for setting up the python runtime environment. This cleans that up:
Importantly, virtualenv.rs:find_python_install() tries to find the python build standalone runtime based on a few heuristics. This function could be improved in the fullness of time to, eg, be configured via a build parameter.
Also, virtualenv.rs:find_python() can be used pre and post venv activation. Before entering the venv, it will use find_python_install() which is useful for things like setting up the initial venv. After entering the venv, it will honor VIRTUAL_ENV (as set by virtualenv.rs:initialize_venv()) to find python, which is important for install packages with pip and having them installed into the venv.
Testing: this has been lightly tested (linux/amd64 and windows/amd64). If @jacksonrnewhouse is happy with the approach, I'll take in feedback and do a full round of testing.
Helps with #26012