Skip to content

Commit afdedd0

Browse files
committed
fix pypa#4775 Consider environment variable PIP_TARGET when calculate depndancy delta.
1 parent 7de8fe0 commit afdedd0

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

pipenv/environment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def get_distributions(self):
540540
:rtype: iterator
541541
"""
542542

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

tests/integration/test_sync.py

+27
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,30 @@ def test_sync_sequential_verbose(PipenvInstance):
111111
c = p.pipenv('sync --sequential --verbose')
112112
for package in p.lockfile['default']:
113113
assert f'Successfully installed {package}' in c.stdout
114+
115+
116+
@pytest.mark.sync
117+
def test_sync_consider_pip_target(PipenvInstance):
118+
"""
119+
"""
120+
with PipenvInstance(chdir=True) as p:
121+
with open(p.pipfile_path, 'w') as f:
122+
f.write("""
123+
[packages]
124+
six = "*"
125+
""".strip())
126+
127+
# Perform initial lock.
128+
c = p.pipenv('lock')
129+
assert c.returncode == 0
130+
lockfile_content = p.lockfile
131+
assert lockfile_content
132+
c = p.pipenv('sync')
133+
assert c.returncode == 0
134+
135+
pip_target_dir = 'target_dir'
136+
os.environ['PIP_TARGET'] = pip_target_dir
137+
c = p.pipenv('sync')
138+
assert c.returncode == 0
139+
assert 'six.py' in os.listdir(os.path.join(p.path, pip_target_dir))
140+
os.environ.pop('PIP_TARGET')

0 commit comments

Comments
 (0)