Implement "Requires" field in pip show#2347
Implement "Requires" field in pip show#2347charliermarsh merged 10 commits intoastral-sh:mainfrom ChannyClaus:main
pip show#2347Conversation
crates/uv/tests/pip_show.rs
Outdated
| } | ||
|
|
||
| #[test] | ||
| #[cfg(not(windows))] |
There was a problem hiding this comment.
not super clear why windows doesn't pull tzdata https://github.com/astral-sh/uv/actions/runs/8225296455/job/22490152644; seems like it's not a platform-dependent dependency https://github.com/pandas-dev/pandas/blob/871f01b5582fc737a63f17c1d9027eb6a2099912/pyproject.toml#L37. may continue to look while having this open for review 😭 (probably not a blocking issue?)
There was a problem hiding this comment.
We have a windows filter hack in the snapshots for our common test packages:
uv/crates/uv/tests/common/mod.rs
Lines 370 to 376 in 1181aa9
Could you use a pure python package for the test case? Pandas and numpy wheel are big due to their native modules (something like 5-20 MB) and since we run the tests with no cache these add up.
There was a problem hiding this comment.
updated to use click.
$ du -sh /Users/chan.kang/test/uv/venv/lib/python3.12/site-packages/click
824K /Users/chan.kang/test/uv/venv/lib/python3.12/site-packages/click
That would be a nice addition, feel free to make a follow-up PR.
There's unfortunately no tracking for which extras get installed, so we don't know if an extra was activated or not. |
crates/uv/src/commands/pip_show.rs
Outdated
| .into_iter() | ||
| .filter(|req| req.evaluate_markers(markers, &[])) | ||
| .map(|req| req.name.to_string()) | ||
| .collect::<Vec<_>>(); |
There was a problem hiding this comment.
Can you try collecting into a BTreeSet instead? There are some cases where names occur twice in the requirements. This would remove those duplicates and skip the sorting step
There was a problem hiding this comment.
Do you happen to remember which particular package has duplicates (was thinking if I should add a test using it)? https://github.com/pypa/pip/blob/fb5f63f0f4c3a204ada8353ce9858d4d4b777c2a/src/pip/_internal/commands/show.py#L104 does seem to suggest the same.
pip showpip show
Summary
Follow-up for 395be44
adds
Requiresfield to pip show output.I've aimed to make it behave exactly the same as
pipdoes for now, but there seem to be subtle issues that may require some discussion going forward:uv pip showsupport extras?piphas an open issue for it, but currently does not support Add support for outputting a list of extras and their requirements. pypa/pip#4824.Requred-byfield (not implemented in this PR) inpip showcurrently doesn't take the extras into account transparently, i.e. whenPySockshas been installed as an extra forrequests[socks],pip show PySocksdoesn't haverequestsorrequests[socks]underRequred-byfield. Shoulduv pip showfor now just replicatepip's behavior for now for simplicity and parity or try to cover the extras for completeness?Test Plan
Added a couple of tests:
requests==2.31.0has four dependencies that would be ordered differently unless sorted. Additionally, it has two dependencies that are optionally included for extras.pandas==2.1.3depends on different versions ofnumpydepending on the python version used.