Skip to content

pipenv check looks at installed packages, not Pipfile.lock #5600

Description

@jacobfelknor

Use Case

I would like to run pipenv check as a separate job from the build/test job inside a CI pipeline without rebuilding environment. I discovered that I must actually install all packages to a pipenv environment before using pipenv check. Ideally, I should be able to scan the dependencies inside Pipfile.lock without actually installing the whole environment.

I believe its misleading that right now pipenv is just acting as a "proxy" to safety, and by default checks an environment that may not match Pipfile.lock. By using pipenv check the assumption should be that it is checking the environment specified in Pipfile.lock and if you need to check an environment that deviates, you use safety directly.

I've traced the behavior down to these lines:

pipenv/pipenv/core.py

Lines 2900 to 2902 in 8939c86

target_venv_packages = run_command(
_cmd + ["-m", "pip", "list", "--format=freeze"], is_verbose=project.s.is_verbose()
)

Instead of generating the temp requirements.txt file from the current environment using pip list, can we instead generate the temp requirements.txt from Pipfile.lock? Something like

# this command should also respect the wishes of the --dev argument, if provided. Unsure on specifics of implementation
target_venv_packages = run_command(
        _cmd + ["-m", "pipenv", "requirements"], is_verbose=project.s.is_verbose()
    )

Workaround

I'm currently using the following workaround in my CI job, but would like to go through pipenv directly.

pipenv requirements --dev | safety check --stdin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Contributor CandidateThe issue has been identified/triaged and contributions are welcomed/encouraged.Type: Enhancement 💡This is a feature or enhancement request.

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions