From fb9e4d769db37d7cfecea5c8a634b47f2b6413ee Mon Sep 17 00:00:00 2001 From: Yeison Vargas Date: Thu, 24 Nov 2022 00:48:31 -0500 Subject: [PATCH] Get packages for `pipenv check` from the target venv. --- pipenv/core.py | 12 ++++++++++++ tests/integration/test_cli.py | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index acebcc20..882f2eea 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2959,6 +2959,16 @@ def do_check( if safety_project: options.append(f"--project={safety_project}") + target_venv_packages = run_command( + _cmd + ["-m", "pip", "list", "--format=freeze"], is_verbose=project.s.is_verbose() + ) + + temp_requirements = tempfile.NamedTemporaryFile(prefix=f"{project.virtualenv_name}_") + temp_requirements.write(target_venv_packages.stdout.strip().encode("utf-8")) + temp_requirements.seek(0) + + options.extend(["--file", temp_requirements.name]) + cmd = _cmd + [safety_path, "check"] + options if db: @@ -3044,6 +3054,8 @@ def do_check( cli(prog_name="pipenv") + temp_requirements.close() + def do_graph(project, bare=False, json=False, json_tree=False, reverse=False): import json as jsonlib diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py index f086cdfe..b6009d85 100644 --- a/tests/integration/test_cli.py +++ b/tests/integration/test_cli.py @@ -140,7 +140,6 @@ def test_pipenv_graph_reverse(pipenv_instance_private_pypi): @pytest.mark.cli @pytest.mark.needs_internet(reason='required by check') -@pytest.mark.skip("Safety 2 ends up scanning the project virtualenv and not the instance created by this test.") def test_pipenv_check(pipenv_instance_private_pypi): with pipenv_instance_private_pypi() as p: c = p.pipenv('install pyyaml')