Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a nesting structure so that pip-compile can pin the same versions across nested extras. #1907

Closed
FeryET opened this issue Jul 10, 2023 · 1 comment · Fixed by #1936
Labels
extras Handling optional dependencies

Comments

@FeryET
Copy link

FeryET commented Jul 10, 2023

What's the problem this feature will solve?

I am using setup.cfg to manage my dependencies and extra dependencies, and I am nesting some extra dependencies in each other. Currently, pip-compile does not guarantee resolving to the same version when I compile the requirements for nested extras.

[options.extras_require]
server =
    pydantic~=1.10.7, >1.9.0

dev =
    %(server)s
    wget

Describe the solution you'd like

I would like to constrain the extended extras to the versions pinned by the nested extra. Here server should pin a pydantic version that dev must follow, and all should be generated into a single independent requirements.txt for each extra.

This is especially important in building smaller containers, since I can guarantee version pinning and smaller diffs between layers of nested extras.

FROM base as builder-1
pip install --no-cache-dir server-requirements.txt

FROM builder
pip install --no-cache-dir dev-requirements.txt

Alternative Solutions

I can use multiple requirements.txt and nest them in each other and introduce dynamic constraints by symlinking the outputs of base extra.

Additional context

I use a single setup.cfg so that I can nest extra pip dependencies easily using setuptools magic. This gives me great flexibility to add requirements and does not make my repo much more crowded. If I had to migrate to having multiple requirments.in and dynamic constrains, it would add a lot of intermediary files, and it is harder to maintain the repository. I think having a single file in which I can define all packages is way more superior to any alternative IMO.

@atugushev
Copy link
Member

@FeryET could you please try this PR (#1936)? I've added support for pip-compile -c requirements.txt, which I believe should resolve the issue.

@atugushev atugushev added the extras Handling optional dependencies label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extras Handling optional dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants