diff --git a/pipenv/environment.py b/pipenv/environment.py index b07ef84205..c75e9c123a 100644 --- a/pipenv/environment.py +++ b/pipenv/environment.py @@ -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) diff --git a/tests/integration/test_sync.py b/tests/integration/test_sync.py index 967d3f2e32..93721bc90d 100644 --- a/tests/integration/test_sync.py +++ b/tests/integration/test_sync.py @@ -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')