Skip to content

pip-compile --extra doesn't take into account already pinned versions #1891

@ianliu

Description

@ianliu

I'm trying to move away from *.in files and manage everything from pyproject.toml, but I'm facing a problem where pip-compile --extra doesn't take into account the already pinned versions from pip-compile (without --extra).

Environment Versions

  1. OS Type: Arch Linux
  2. Python version: 3.11.3
  3. pip version: pip 23.1.2 from /usr/lib/python3.11/site-packages/pip (python 3.11)
  4. pip-tools version: 6.13.0

Steps to replicate

  1. Create the following pyproject.toml:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "foobar"
version = "1"
dependencies = ["django==4.1.7"]

[project.optional-dependencies]
dev = ["pytest"]
  1. Execute pip-compile --no-header --no-annotate --resolver backtracking to obtain:
asgiref==3.7.2
django==4.1.7
sqlparse==0.4.4
  1. Remove the restriction from the django dependency from the pyproject.toml, and verify that pip-compile doesn't update any package.
  2. Execute pip-compile --no-header --no-annotate --resolver backtracking --extra dev -o dev-requirements.txt, and see that the django dependency has been updated in the dev-requirements.txt:
asgiref==3.7.2
django==4.2.2
iniconfig==2.0.0
packaging==23.1
pluggy==1.2.0
pytest==7.4.0
sqlparse==0.4.4

I also tried to pass --pip-args "-c requirements.txt", but nothing changed.

Expected result

Actually, I would expect a way to pin only the dev dependencies, since the main dependencies were already pinned. Some workflow similar to the Workflow for layered requirements but with pyproject.toml instead of *.in files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    extrasHandling optional dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions