From afdedd0f4bafca94ade9c2a411e0352f50f20f6e Mon Sep 17 00:00:00 2001 From: Tomoya Iwata Date: Fri, 27 Aug 2021 15:31:06 +0900 Subject: [PATCH] fix #4775 Consider environment variable PIP_TARGET when calculate depndancy delta. --- pipenv/environment.py | 2 +- tests/integration/test_sync.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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')