Skip to content

Commit

Permalink
fix pypa#4775 Consider environment variable PIP_TARGET when calculate…
Browse files Browse the repository at this point in the history
… depndancy delta.
  • Loading branch information
cm-iwata committed Aug 27, 2021
1 parent 7de8fe0 commit afdedd0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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 afdedd0

Please # to comment.