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

Feature/pipignore #4900

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2195.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add supporte for a `PIP_IGNORE` environment setting, which, when pointing to a valid file, causes `pip install` to ignore all file patterns listed in there. This can speed up installations from large source trees.
14 changes: 13 additions & 1 deletion src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,23 @@ def unpack_file_url(link, location, download_dir=None, hashes=None):
"""
link_path = url_to_path(link.url_without_fragment)

# if a .pipignore' file location is set and exists, '#' style
# comments are stripped. All other strings (space limited) are interpreted
# as glob-style pattersn to be passed to `shutil.copytree`, and are thus
# excluded from the file cloning operation.
ignored = list()
pipignore = os.environ.get('PIP_IGNORE')
if pipignore and os.path.isfile(pipignore):
with open(pipignore, 'r') as fin:
for line in fin.readlines():
ignored.extend(line.split('#')[0].strip().split())

# If it's a url to a local directory
if is_dir_url(link):
if os.path.isdir(location):
rmtree(location)
shutil.copytree(link_path, location, symlinks=True)
shutil.copytree(link_path, location, symlinks=True,
ignore=shutil.ignore_patterns(*ignored))
if download_dir:
logger.info('Link is a directory, ignoring download_dir')
return
Expand Down