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

Add requirements.in and use pip-compile to generate requirements.txt #488

Open
Nydauron opened this issue Jun 18, 2024 · 0 comments
Open

Comments

@Nydauron
Copy link
Contributor

It makes sense to have requirements.txt be a lockfile, but trying to modify the version numbers of top-level dependencies can be a nightmare.

The proposed idea is to add a new file, requirements.in, that contains all top-level dependencies. These constraints can target a range or a specific version. We can then use pip-compile (from the pip-tools package, installable via pip install pip-tools) to generate a requirements.txt file:

pip-compile --output-file=requirements.txt --strip-extras

The lockfile can then be updated to the newest versions (as allowed by requirements.in) by running:

pip-compile -U --output-file=requirements.txt --strip-extras

Adding or updating version constraints in requirements.in should then result in pip-compile being run which can be enforced by adding an additional git hook on pre-commit.

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

No branches or pull requests

1 participant