Skip to content

Pip doesn’t allow you to self-depend #10393

@flying-sheep

Description

@flying-sheep

Description

When specifying dependencies, you sometimes want to depend on other extras:

[project]
name = 'my_pkg'

[project.optional-dependencies]
test-utils = ['pytest', 'requests-mock', '...']
test = ['my_pkg[test-utils]']

Expected behavior

@uranusjr said it should work:

Circular dependency is a feature that Python packaging is explicitly designed to allow, so it works and should continue to work. […]

pip version

21.2.4

Python version

3.9.6

OS

Arch Linux

How to Reproduce

  1. Create a new package with something like the above setup
  2. Install it with the extra depending on itself: pip install .[test]
  3. It can’t find the package because it doesn’t merge . with my_pkg

Specifying test = ['.[test-utils]'] doesn’t work.

Output

@henryiii said:

It does not pull the extra from the current package, but rather from the existing cached packages. So if you add a new extra […] and then depend on it, it starts spewing out a long list of package checking:

Collecting my_pkg[test-utils]
  Using cached my_pkg-1.11.1-py3-none-any.whl (1.5 MB)
WARNING: my_pkg 1.11.1 does not provide the extra 'test-utils'
  Using cached my_pkg-1.11.0-py3-none-any.whl (1.5 MB)
WARNING: my_pkg 1.11.0 does not provide the extra 'test-utils'
  Using cached my_pkg-1.10.0-py3-none-any.whl (1.5 MB)
WARNING: my_pkg 1.10.0 does not provide the extra 'test-utils'

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions