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

Generate both the requirements file and the corresponding contraints file in one command #1804

Open
nabla-c0d3 opened this issue Jan 31, 2023 · 1 comment
Labels
feature Request for a new feature

Comments

@nabla-c0d3
Copy link

nabla-c0d3 commented Jan 31, 2023

What's the problem this feature will solve?

Our application uses two sets of requirements:

  • requirements.in
  • requirements-dev.in

Previously, we would add -c requirements.txt at the top of our requirements-dev.in to ensure that compatible packages get installed, as described in the "Workflow for layered requirements" section of pip-tools' README.

Since pip changed how -c works by restricting what's allowed in "constraints files" (https://pip.pypa.io/en/stable/user_guide/#constraints-files), we can no longer put -c requirements.txt at the top of our requirements-dev.in.

This is because our requirements.txt contains entries that are not allowed to be in a constraints file, including extras and file: (ie. vendored) dependencies.

Describe the solution you'd like

One solution would be to have a command line option in pip-tools to generate a valid constraints file in addition to the requirements file. Something like this:

pip-compile --resolver=backtracking requirements.in -o requirements.txt --output-as-constraint-file requirements-as-constraints.txt

We would then be able to add -c requirements-as-constraints.txt to the top of our requirements-dev.in and have a similar workflow as before. Having both the requirements.txt and requirements-as-constraints.txt files generated in one command would also ensure that they are in sync.

Alternative Solutions

I couldn't find a simple workflow for what we're trying to do . pip-tools has --strip-extras but this doesn't help for file: dependencies, and it also would require an extra command to generate a constraints file.

Our current approach, which is unideal, is to just copy and paste problematic entries from the requirements.in to the requirement-dev.in.

@cout
Copy link

cout commented Mar 27, 2023

I discovered today another reason to support this: invoking pip-compile a second time with --strip-extras to generate the constraints file, I ended up with a different version for one of the packages between the generated constraints and requirements. I'm guessing a new version of the package between invocations of pip-compile; generating both files at the same time would have avoided this. (Removing both files and regenerating resulted in matching files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants