-
Notifications
You must be signed in to change notification settings - Fork 881
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
Implement "Requires" field in pip show
#2347
Conversation
crates/uv/tests/pip_show.rs
Outdated
} | ||
|
||
#[test] | ||
#[cfg(not(windows))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
// The optional leading +/- is for install logs, the optional next line is for lock files | |
let windows_only_deps = [ | |
("( [+-] )?colorama==\\d+(\\.[\\d+])+\n( # via .*\n)?"), | |
("( [+-] )?colorama==\\d+(\\.[\\d+])+\\s+(# via .*\n)?"), | |
("( [+-] )?tzdata==\\d+(\\.[\\d+])+\n( # via .*\n)?"), | |
("( [+-] )?tzdata==\\d+(\\.[\\d+])+\\s+(# via .*\n)?"), | |
]; |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 show
pip show
f080835
to
23bc073
Compare
Summary
Follow-up for 395be44
adds
Requires
field to pip show output.I've aimed to make it behave exactly the same as
pip
does for now, but there seem to be subtle issues that may require some discussion going forward:uv pip show
support extras?pip
has 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-by
field (not implemented in this PR) inpip show
currently doesn't take the extras into account transparently, i.e. whenPySocks
has been installed as an extra forrequests[socks]
,pip show PySocks
doesn't haverequests
orrequests[socks]
underRequred-by
field. Shoulduv pip show
for 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.0
has four dependencies that would be ordered differently unless sorted. Additionally, it has two dependencies that are optionally included for extras.pandas==2.1.3
depends on different versions ofnumpy
depending on the python version used.