-
Notifications
You must be signed in to change notification settings - Fork 181
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
Install python into a venv #718
Conversation
Created this draft mostly to see what CI says! |
Discovered while working on #718
07af31c
to
484342f
Compare
ok, this is ready for a first round of review :) |
- Continues to use python and venv from Ubuntu LTS repositories, so they are supported as with everything else that is gotten from apt (see rocker-org#670 (comment)) - Doesn't currently change any permissions, so present behavior is preserved. However, in the future, we should probably change ownership so end users can install packages in there at runtime (see rocker-org#670 (comment)) - Sets the VIRTUAL_ENV environment variable to path of the venv we create. This is what the `source activate` script does, and Reticulate also looks for this to discover which python to use (see point 4 of https://rstudio.github.io/reticulate/articles/versions.html#order-of-discovery) - Sets up PATH appropriately, so python and python3 refer to what is in our venv. This, along with the previous step, ensures same behavior as users typing `source ${VIRTUAL_ENV}/bin/activate` without actually having to do that, preserving end user behavioral semantics. - Remove the explicit symlink of python3 -> python, as venv handles this automatically. Decisions to be made: - Where do we set the appropriate env variables (VIRTUAL_ENV and PATH)? They need to be set for `install_python.sh` to work correctly. I've set them in the binder image for now, but it should probably be set on a more base image. This is a no-op if `install-python.sh` is not called anywhere. Ref rocker-org#670
So it sets PATH appropriately
What is the current status of this? |
Thanks @yuvipanda ! Yup, I think the main thing is considering changing the permissions on A second more minor issue is that under this setup, the default |
Hmm, since there should be a |
Making |
- Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@eitsupi ok just tested and this looks ready to merge to me! |
Yay that's awesome, thank you @cboettig! |
scripts/install_python.sh
Outdated
fi | ||
# Make the venv owned by the staff group, so users can install packages | ||
# without having to be root | ||
chown -R rstudio:staff /opt/venv |
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.
Don't hard-code the username. There is no guarantee that the user exists.
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.
@eitsupi in install_texlive.sh
I see:
NON_ROOT_USER=$(getent passwd "1000" | cut -d: -f1)
and this is used as username. Should I do that?
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.
Is there a bad reason not to be the root user?
If so, please do so.
However, in that case, I don't think it will work if the uid is anything other than 1000
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.
Ok, given I was trying to replicate what happens in R, I've set this to match what is done to $R_HOME/site-library
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.
The tests seem passed. Thanks!
Could you update the NEWS file? |
I always seem to struggle with updating NEWS but gave it a shot! |
Looks good. The CI failure is notthing to do with changes in this PR, so merging. |
Awesome! Thanks a lot, @eitsupi! Will this trigger a rebuild of the images? |
Sorry, my review was not thorough enough (i.e. this should not have been merged yet), the fix for the stack file is completely incomplete here. |
source activate
script does, and Reticulate also looks for this to discover which python to use (see point 4 of https://rstudio.github.io/reticulate/articles/versions.html#order-of-discovery)source ${VIRTUAL_ENV}/bin/activate
without actually having to do that, preserving end user behavioral semantics. See Using pip without venv or conda env will stop working soon #670 (comment)PATH
andVIRTUAL_ENV
, using the same pattern asinstall_texlive.sh
install_python.sh
now needs to besource
d, following same pattern asinstall_texlive.sh
Decisions to be made:
install_python.sh
to work correctly. I've set them in the binder image for now, but it should probably be set on a more base image. This is a no-op ifinstall-python.sh
is not called anywhere.TODO:
NEWS
(can be done once everything else is finalized)Ref #670