-
-
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
Mount pip_cache_path
in Docker container
#3556
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -449,7 +449,7 @@ def checkout_path(self, version=LATEST): | |
@property | ||
def pip_cache_path(self): | ||
"""Path to pip cache.""" | ||
if getattr(settings, 'GLOBAL_PIP_CACHE', False): | ||
if getattr(settings, 'GLOBAL_PIP_CACHE', False) and settings.DEBUG: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. By default this feature is deactivated. It could be something like:
what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say leave deactivated so our development environments are close to production use. |
||
return settings.GLOBAL_PIP_CACHE | ||
return os.path.join(self.doc_path, '.cache', 'pip') | ||
|
||
|
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.
This is slightly redundant, as the project pip cache path is under
doc_path
already.Also, normally to share a pip cache, we'd set
CACHE_DIR
env variable, or--cache-dir
argument on pip. To use underlying storage like this, but then repeated remount this path to different locations through docker might cause problems if pip stores and metadata that includes the full path. I don't know enough about pip internals to answer this.It seems like the most correct option would be to explicitly set
CACHE_DIR
on the pip commands if using a global cache, and to mount the global cache conditionally on thebinds
argument here ifGLOBAL_PIP_CACHE
isTrue
.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.
Mmm... Yes. This is redundant when the
GLOBAL_PIP_CACHE
is not set. So, maybe we should add this path only when it's set (as you said, conditionally).We are using the
--cache-dir
in the command atpython_environments.py
file, and that dir points to theproject.pip_cache_path
I prefer to use the argument option instead of the env variable (since it's less explicit and more complicated to debug later)
As far as I know, pip doesn't save metadata, but creates a hash of the package downloaded and use it as filename --but use the real one for wheels:
I'd say that mounting conditionally under the binds depending on this setting is the missing piece here and the rest is safe.
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.
This sounds good. I don't think there is any metadata dependent on the path either, so this is most likely safe I'm sure.