Skip to content

Pipenv requirements for --dev-only may include packages from other categories #6440

@stekycz

Description

@stekycz

Issue description

Executing pipenv requirements --from-pipfile --dev-only generates the requirements format properly but in some cases includes additional packages from other categories (primarily default).

Expected result

I would expect only packages listed in dev-packages to be listed in the requirements format when using --dev-only option.

Actual result

A package from default category (or generally any category) is included in the list of --dev-only output.

Steps to replicate

  1. Prepare an empty folder with Pipfile with the following content
[packages]
iniconfig = "==2.1.0"

[dev-packages]
pytest = "==8.4.1"
  1. Install
PIPENV_VENV_IN_PROJECT=1 pipenv install
  1. Generate --dev-only requirements
pipenv requirements --from-pipfile --dev-only
  1. Notice the extra iniconfig package listed

I believe the package is listed because it is a sub-dependency (possibly transitively) of pytest but the current logic only cares about the package being explicitly listed in any category in the Pipfile.

I believe each category and the specific dev branch should care about packages listed in their category only:

It can probably apply the other direction as well


$ pipenv --support

Pipenv version: '2025.0.4'

Pipenv location: '/opt/homebrew/Cellar/pipenv/2025.0.4/libexec/lib/python3.13/site-packages/pipenv'

Python location: '/opt/homebrew/Cellar/pipenv/2025.0.4/libexec/bin/python'

OS Name: 'posix'

User pip version: '25.1.1'

user Python installations found:

  • 3.10.14: ~/.pyenv/versions/3.10.14/bin/python3
  • 3.10.14: ~/.pyenv/versions/3.10.14/bin/python
  • 3.9.6: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.13.8',
 'os_name': 'posix',
 'platform_machine': 'arm64',
 'platform_python_implementation': 'CPython',
 'platform_release': '24.6.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:31 PDT '
                     '2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6030',
 'python_full_version': '3.13.8',
 'python_version': '3.13',
 'sys_platform': 'darwin'}

System environment variables:

  • ...

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: ...
  • SHELL: /bin/zsh
  • PWD: ...

Contents of Pipfile ('.../Pipfile'):

[packages]
iniconfig = "==2.1.0"

[dev-packages]
pytest = "==8.4.1"

Contents of Pipfile.lock ('.../Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "5f353a2b2243d20ef357f102ac765af12b1804407af218fae273c0097baa72b7"
        },
        "pipfile-spec": 6,
        "requires": {},
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "iniconfig": {
            "hashes": [
                "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7",
                "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"
            ],
            "index": "pypi",
            "markers": "python_version >= '3.8'",
            "version": "==2.1.0"
        }
    },
    "develop": {
        "iniconfig": {
            "hashes": [
                "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7",
                "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"
            ],
            "index": "pypi",
            "markers": "python_version >= '3.8'",
            "version": "==2.1.0"
        },
        "packaging": {
            "hashes": [
                "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484",
                "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"
            ],
            "markers": "python_version >= '3.8'",
            "version": "==25.0"
        },
        "pluggy": {
            "hashes": [
                "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3",
                "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"
            ],
            "markers": "python_version >= '3.9'",
            "version": "==1.6.0"
        },
        "pygments": {
            "hashes": [
                "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887",
                "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"
            ],
            "markers": "python_version >= '3.8'",
            "version": "==2.19.2"
        },
        "pytest": {
            "hashes": [
                "sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7",
                "sha256:7c67fd69174877359ed9371ec3af8a3d2b04741818c51e5e99cc1742251fa93c"
            ],
            "index": "pypi",
            "markers": "python_version >= '3.9'",
            "version": "==8.4.1"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions