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

Add functions for (de)activating local minicran install as repo #89

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ethanwhite
Copy link
Collaborator

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 cause install.packages() and pip 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?

Different line endings and path characters were causing issues on Windows
@ethanwhite
Copy link
Collaborator Author

Fixed a missing dev dependency and a cross-OS testing issue. Tests are passing now.

Copy link
Contributor

@abhidg abhidg left a 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"))
Copy link
Contributor

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():
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants