Add support for pip install --only-deps.#13895
Conversation
|
Okay, looks like the legacy resolver requires a similar treatment or has to throw an error. I'll see what I can do :-) |
|
FYI, it's completely fine to ban the user from providing only deps and use legacy resolver, if that makes things simpler. Recently there is movement on dropping the legacy resolver. |
This comment was marked as duplicate.
This comment was marked as duplicate.
|
The main failure reason is that I missed the fact that the options-object does not always have the proper values (i.e., While the scope of the issue was to provide I will do that today after work. |
sbidoul
left a comment
There was a problem hiding this comment.
Thanks for working on this!
A couple of comments/questions.
|
I cannot reproduce the CI failures locally: FAILED tests/unit/metadata/test_metadata.py::test_trailing_slash_directory_metadata[/path/to/foo.egg-info] - importlib.metadata.MetadataNotFound: No package metadata was found. But they seem to be failing on the main branch as well. |
Absolutely, that has to be done at the same time. |
|
I rebased the branch on the current main, I hope that resolves then Python 3.15 issues of the CI pipeline. I also added basic function tests to wheel, download, and lock for the feature. |
sbidoul
left a comment
There was a problem hiding this comment.
Thanks! I did some tests and it works as expected. The implementation is simple and contained which is great!
A few comments to address, but this looks like it's almost ready.
|
Thanks for the thorough review, @sbidoul, your feedback was great and I believe it helped a lot to improve the PR! If not, I can rebase and squash the commits to be a bit more concise and mark the PR as ready. |
d7cdda6 to
261ccbf
Compare
|
I have squashed and rebased the PR and marked it as "Ready for review". Let me know if there's more I can address :) (P.S.: As mentioned in the issue, don't feel pressured, I am in no hurry :) ) |
|
@shoeffner I worry I sent you on a difficult track with Alternatively, examining the installation report of |
|
Haha, no need to worry. I will take a look into that, thanks for the suggestion! |
|
@shoeffner a quick note that July and 26.2 is approaching. So if you find the time to have a last look at the tests in the coming couple of weeks, this can likely make it into 26.2. |
|
I'd like to include this in pip 26.2 if it is ready by the end of the month. I still need to perform an in-depth review, but on the surface, the proposed UI looks good to me. I'll need to think about the UI a bit more since I haven't thought about this feature in ages (and we're growing a lot of complexity1 around requirements which makes me uneasy). Footnotes
|
bcf66f4 to
c434c9d
Compare
|
Sorry for the slow response time!
|
sbidoul
left a comment
There was a problem hiding this comment.
A couple of documentation suggestions but otherwise this looks good to me. Thanks for this work!
| action="store_true", | ||
| default=False, | ||
| help=( | ||
| "Handle only the dependencies of the provided requirements, not the " |
There was a problem hiding this comment.
"handle" sounds a little bit strange, but I see why you use this as this option is used for install, wheel, download and lock. I don't have a better idea.
There was a problem hiding this comment.
Maybe a different sentence structure such as "Take only the dependencies ... into account" could work?
There was a problem hiding this comment.
I changed it accordingly, but am happy to change it to any other good wording.
This commit follows the agreed interface in [1]:
pip install --only-deps . # project.dependencies
pip install --only-deps .[doc] # project.dependencies and project.optional-dependencies
If --only-deps or its longform --only-dependencies is provided, neither the
explicitly requested packages nor the build dependencies are installed, instead
only the "runtime" dependencies are used. In other words, no user supplied
packages will be installed, only their dependencies.
--only-deps and --no-deps are mutually exclusive and pip will refuse to install
anything if both are specified. Similarly, --only-deps is mutually exclusive
to -r / --requirements, --use-deprecated legacy-resolver, and --group.
Relevant explanations can be found in the user guide, which now includes a
section regarding --only-deps.
Because --only-deps does not install build dependencies, no implicit or dynamic
dependencies can be managed this way, that means a build tool cannot
automatically install more dependencies by executing additional code.
This also adds the --only-deps flag to wheel, lock, and download, indicating
a user only wants to handle dependencies of a package.
To test the changes more easily, the commit adds
PipTestResult.assert_not_installed and tests for it.
First part of pypa#11440, which also specifies "build-only dependencies",
which are out of scope for this PR.
[1]: pypa#11440 (comment)
This commit follows the agreed interface in 1:
If --only-deps or its longform --only-dependencies is provided, neither the explicitly requested packages nor the build dependencies are installed, instead only the "runtime" dependencies are used.
--only-deps and --no-deps are mutually exclusive and pip will refuse to install anything if both are specified.
Because --only-deps does not install build dependencies, no implicit or dynamic dependencies can be managed this way, that means a build tool cannot automatically install more dependencies by executing additional code.
First part of #11440.