Skip to content

pip-compile does not use the python version from the generated file header #14137

@mbooz-rh

Description

@mbooz-rh

Is there an existing issue for this?

  • I have searched the existing issues

Package ecosystem

pip-compile

Package manager version

7.4.1

Language version

3.9, 3.13

Manifest location and content before the Dependabot update

/dev-requirements-py39.txt
/dev-requirements.in

dependabot.yml content

No response

Updated dependency

The following dependency is added to the python 3.9 lockfile, when it should be exluded based on python version:

  • alabaster==1.0.0 ; python_version >= "3.10"

What you expected to see, versus what you actually saw

Expect dependabot to extract Python version from .txt lockfile's header and run pip-compile with that version #4216. The dev-requirements-py39.txt should exclude alabaster, as the dev-requirements.in file restricts it to python versions >= 3.10. Instead, pip-compile is run using Python3.13 for both lockfiles. This causes the package to be added, when it should be excluded from the lockfile.

Native package manager behavior

pip-compile excludes requirements from the .txt lockfiles that do not match the python version used to generate the lockfile.

python3.9 command:
bash pip-compile --generate-hashes --output-file=dev-requirements-py39.txt dev-requirements.in
python3.13 command:
bash pip-compile --generate-hashes --output-file=dev-requirements-py313.txt dev-requirements.in

Images of the diff or a link to the PR, issue, or logs

Relevant PRs:

Logs showing both manifests created with the same python version:

Image Image

Smallest manifest that reproduces the issue

/dev-requirements-py39.txt
dev-requirements.in
requirements.in

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions