-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add functions for (de)activating local minicran install as repo #89
base: main
Are you sure you want to change the base?
Conversation
Supports activating and deactivating use of the local pypi mirror by pip
Different line endings and path characters were causing issues on Windows
Fixed a missing dev dependency and a cross-OS testing issue. Tests are passing now. |
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.
Thanks @ethanwhite and apologies for the delayed review. Could you add tests for deactivation? The Python pip.conf modifies multiple lines, so that's the one that might be an issue.
|
||
minicran_path = os.path.join("file://", ods_dir.lstrip("/"), "miniCRAN") #lstrip needed because "If any component is an absolute path, all previous path components will be discarded" | ||
rprofile_line = 'local({r <- getOption("repos"); r["CRAN"] <- "%s"; options(repos=r)}) #Added by offlinedatasci\n' % minicran_path | ||
rprofile_path = Path(os.path.join(os.path.expanduser("~"), ".Rprofile")) |
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.
can be shortened to Path("~/.Rprofile").expanduser()
else: | ||
activated = False | ||
for line in pip_config_list: | ||
if line.strip() == pip_config_line.strip(): |
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.
Unlike the R case, multiple lines are in pip_config_line
, so any particular line will never match the whole of pip_config_line
For advanced users installing from a local repo mirror is fairly easy, but for novices and even a lot of experienced coders this would involve learning a lot of details they probably don't care about. For workshops with Raspberry PI style servers this would be handled via instruction, but for folks using
offlinedatasci
locally it might be a bit confusing.This PR adds the ability to run
offlinedatasci activate /path/to/ods
, which will add lines to both~/.Rprofile
and~/.config/pip/pip.conf
that will causeinstall.packages()
andpip install
to use the associated offlinedatasci local mirrors.offlinedatasci deactivate
will remove all such lines to return these files to their previous state and behavior to normal.I'm definitely interested in reviews of this since it's messing with users conf files.
Should we prompt the user to confirm this change? Is it a bad idea in general? Other thoughts?