pip-tools icon indicating copy to clipboard operation
pip-tools copied to clipboard

Allow to skip dependencies (`--no-deps`) for individual requirements

Open blueyed opened this issue 6 years ago • 13 comments

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).

blueyed avatar May 13 '19 10:05 blueyed

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

graingert avatar May 14 '19 08:05 graingert

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.

blueyed avatar May 16 '19 11:05 blueyed

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

atugushev avatar May 16 '19 11:05 atugushev

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.

blueyed avatar May 16 '19 11:05 blueyed

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.

atugushev avatar May 16 '19 11:05 atugushev

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

blueyed avatar May 16 '19 12:05 blueyed

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.

atugushev avatar May 17 '19 07:05 atugushev

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.

AndydeCleyre avatar Nov 10 '19 04:11 AndydeCleyre

@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))

blueyed avatar Dec 31 '19 10:12 blueyed

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?

AndydeCleyre avatar Jan 01 '21 18:01 AndydeCleyre

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

AndydeCleyre avatar Feb 27 '22 03:02 AndydeCleyre