pip-tools
pip-tools copied to clipboard
Allow to skip dependencies (`--no-deps`) for individual requirements
It would be useful if you could specify --no-deps for some dependencies, where you do not want pip-compile to include the dependencies, but control it manually.
pip's own options are handled via https://github.com/pypa/pip/blob/f8732ac06dcb7c6af81dcdc0cc3158196b796baf/src/pip/_internal/req/req_file.py#L283 (e.g. --hash).
echo '--no-deps channels' | pip-compile -q - -o -
This might also make sense as a global option to pip-compile, but usually is more important for single deps only (i.e. in a line in the requirements.in file).
I think this is close to https://github.com/jazzband/pip-tools/issues/215 eg you want to make sure a package is not installed and a replacement is installed instead, or you want to force a specific version when a package is too strict about its deps.
I believe --no-deps is a bit of a sledgehammer solution to #215
For me --no-deps is useful since e.g. "channels" pulls in "daphne", which then pulls in twisted and much more (https://github.com/django/channels/issues/1285), which are really optional deps.
FTR, --no-deps is not supported option for pip install -r requiremtns.txt. See:
$ cat requirements.txt
--no-deps django
django
$ pip install -r requirements.txt
Usage: pip [options]
ERROR: Invalid requirement: --no-deps django
pip: error: no such option: --no-deps
Yeah, it should not end up there, but get consumed / used by pip-compile. It should also apply to a single dep only, not to all of them.
The --no-deps is global option. So what's the point? It's not gonna work if there are N packages in reqs.in with deps, because it'll be all installed without deps.
I've thought about pip-compile using this internally only. I do not know the internals, but I've thought that pip-compile could resolve those with the "--no-deps" option then, and merging them later - assuming that all reqs are resolved in one batch currently. Pip's resolver understands the option: https://github.com/pypa/pip/blob/f8732ac06dcb7c6af81dcdc0cc3158196b796baf/src/pip/_internal/resolve.py#L41-L55
Pip's resolver understands the option: https://github.com/pypa/pip/blob/f8732ac06dcb7c6af81dcdc0cc3158196b796baf/src/pip/_internal/resolve.py#L41-L55
Looks like ignore_dependencies works globally.
Noting here that --no-deps as a globally applied option to pip-sync (not pip-compile) is implemented in this commit as part of pull request #907 as a simple pass-through option to pip.
@atugushev
ignore_dependencies is an option to the resolver.
Could another resolver be used here? https://github.com/jazzband/pip-tools/blob/0da08e52294d944ccf59570f2d3397badc41b7d4/piptools/repositories/pypi.py#L221
(for all requirements that have a --no-deps option (similar to the existing -e option that can be specified with requirements.in entries))
Can we get a clearer picture of the feature requirement?
Does the problem go beyond particular packages specifying hard deps instead of using extras groups?
I don't think this particular workaround (which I think achieves the desired behavior) has been articulated here yet:
requirements.in:
-r reqs-with-deps.txt
req-without-dep1
req-without-dep2
reqs-with-deps.in:
req1
req2
$ pip-compile reqs-with-deps.in && pip-compile --pip-args --no-deps requirements.in