Skip to content

Commit

Permalink
fix #4775 Consider environment variable PIP_TARGET when calculate dep…
Browse files Browse the repository at this point in the history
…ndancy delta.
  • Loading branch information
cm-iwata committed Aug 27, 2021
1 parent 7de8fe0 commit b20841e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/4775.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If `PIP_TARGET` is set to environment variables, Refer specified directory for calculate delta, instead default directory
2 changes: 1 addition & 1 deletion pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def get_distributions(self):
:rtype: iterator
"""

libdirs = self.base_paths["libdirs"].split(os.pathsep)
libdirs = os.environ.get('PIP_TARGET', self.base_paths["libdirs"].split(os.pathsep))
dists = (pkg_resources.find_distributions(libdir) for libdir in libdirs)
yield from itertools.chain.from_iterable(dists)

Expand Down
27 changes: 27 additions & 0 deletions tests/integration/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,30 @@ def test_sync_sequential_verbose(PipenvInstance):
c = p.pipenv('sync --sequential --verbose')
for package in p.lockfile['default']:
assert f'Successfully installed {package}' in c.stdout


@pytest.mark.sync
def test_sync_consider_pip_target(PipenvInstance):
"""
"""
with PipenvInstance(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
six = "*"
""".strip())

# Perform initial lock.
c = p.pipenv('lock')
assert c.returncode == 0
lockfile_content = p.lockfile
assert lockfile_content
c = p.pipenv('sync')
assert c.returncode == 0

pip_target_dir = 'target_dir'
os.environ['PIP_TARGET'] = pip_target_dir
c = p.pipenv('sync')
assert c.returncode == 0
assert 'six.py' in os.listdir(os.path.join(p.path, pip_target_dir))
os.environ.pop('PIP_TARGET')

0 comments on commit b20841e

Please sign in to comment.