-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
--constraint support #1364
Comments
I think the implementation can be pretty simple. We can just do the same for constraint file as we do for the output file for the purpose of detecting the current constraints. ireqs = parse_requirements(
output_file.name,
finder=tmp_repository.finder,
session=tmp_repository.session,
options=tmp_repository.options,
)
if constraint_file:
ireqs = itertools.chain(ireqs, parse_requirements(
constraint_file,
finder=tmp_repository.finder,
session=tmp_repository.session,
options=tmp_repository.options,
)) |
Alternative approach: Create
Relative paths may be trouble until a certain PR gets approved, but you can use absolute paths to test the approach. Anyway, compile that to |
That's an interesting idea, thank you. I finally tried it today, it's close enough. However, the
|
IDK why I didn't think about it, but apparently you can pass It still would be great to have a separate flag for it, though. Sounds like a quite common case to me, let's see if there is demand for it. |
Similar feature request here with comment about drawbacks and proposed alternative |
I'm a |
The described method allows to pass the constraints file as a content of another file but not as a CLI argument. The first thing I tried before opening the issue is to pass it as echo "-c {{.CONSTR_PATH}}" > requirements.in
pip-tools requirements.in pyproject.toml
rm requirements.in Even if we decide that this workaround is ok and there is no need for code changes, it still should be at least documented, I'd never figure it out on my own. |
Thank you for providing the workaround, I was banging my head against a wall for a while before finding this thread. Agree with @orsinium that it would be great to at least get this documented, though an explicit As an additional data point, my use case involved creating separate requirements files for different extras defined in a pyproject.toml file. Having a We define our dependencies in addition to |
Guys, how to make dependabot working with the proposed workaround?
We are using unconstrained in file, and we have one
Somehow it is not woking with dependabot... |
@AndydeCleyre considering #1891 wouldn't it makes sense to support |
Yes probably, especially since AFAIK you can't specify constraints in a pyproject.toml the same way. |
This PR #1936 adds |
What's the problem this feature will solve?
There are 2 projects:
lib
is an internal library. It hassetup.py
with dependencies of the library.srv
is an internal service that useslib
. It has a lock filerequirements.txt
.The goal is to generate
lib/requirements.txt
which has only packages fromlib/setup.py
but the same versions as specified insrv/requirements.txt
. Motivation:lib
, it will work as expected in the environment ofsrv
.lib
in the environment ofsrv
is complicated on CI: the env ofsrv
is too big, and we want to avoid making it for pipelines inlib
.Describe the solution you'd like
The idea is the same as in pip's Constraints Files (
-c/--constraint
option). So, it makes sense to introduce the same key for pip-tools.Alternative Solutions
pip-tools already uses the output file as the constraint. So, a workaround I found is to specify the constraint file as the output file and then restore it. The PoC:
Additional context
The text was updated successfully, but these errors were encountered: