Skip to content

Commit

Permalink
Merge pull request #5501 from yeisonvargasf/fix/check-only-pipenv-man…
Browse files Browse the repository at this point in the history
…aged-venv

Get packages for `pipenv check` from the target venv.
  • Loading branch information
matteius authored Nov 24, 2022
2 parents 66153e2 + ce6e56c commit 2923ccf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2959,6 +2959,21 @@ 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(
mode="w+",
prefix=f"{project.virtualenv_name}",
suffix="_requirements.txt",
delete=False,
)
temp_requirements.write(target_venv_packages.stdout.strip())
temp_requirements.close()

options.extend(["--file", temp_requirements.name])

cmd = _cmd + [safety_path, "check"] + options

if db:
Expand Down Expand Up @@ -3044,6 +3059,8 @@ def do_check(

cli(prog_name="pipenv")

temp_requirements.remove()


def do_graph(project, bare=False, json=False, json_tree=False, reverse=False):
import json as jsonlib
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 2923ccf

Please sign in to comment.