Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,10 @@ pub struct PipShowArgs {
#[arg(long, overrides_with("strict"), hide = true)]
pub no_strict: bool,

/// Show the full list of installed files for each package.
#[arg(short, long)]
pub files: bool,

/// The Python interpreter to find the package in.
///
/// By default, uv looks for packages in a virtual environment but will look
Expand Down
13 changes: 13 additions & 0 deletions crates/uv/src/commands/pip/show.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use std::fmt::Write;

use anyhow::Result;
use fs_err::File;
use itertools::{Either, Itertools};
use owo_colors::OwoColorize;
use rustc_hash::FxHashMap;

use uv_cache::Cache;
use uv_distribution_types::{Diagnostic, Name};
use uv_fs::Simplified;
use uv_install_wheel::read_record_file;
use uv_installer::SitePackages;
use uv_normalize::PackageName;
use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest};
Expand All @@ -22,6 +24,7 @@ pub(crate) fn pip_show(
strict: bool,
python: Option<&str>,
system: bool,
files: bool,
cache: &Cache,
printer: Printer,
) -> Result<ExitStatus> {
Expand Down Expand Up @@ -184,6 +187,16 @@ pub(crate) fn pip_show(
)?;
}
}

// If requests, show the list of installed files.
if files {
let path = distribution.path().join("RECORD");
let record = read_record_file(&mut File::open(path)?)?;
writeln!(printer.stdout(), "Files:")?;
for entry in record {
writeln!(printer.stdout(), " {}", entry.path)?;
}
}
}

// Validate that the environment is consistent.
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.strict,
args.settings.python.as_deref(),
args.settings.system,
args.files,
&cache,
printer,
)
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ impl PipListSettings {
#[derive(Debug, Clone)]
pub(crate) struct PipShowSettings {
pub(crate) package: Vec<PackageName>,
pub(crate) files: bool,
pub(crate) settings: PipSettings,
}

Expand All @@ -1638,6 +1639,7 @@ impl PipShowSettings {
package,
strict,
no_strict,
files,
python,
system,
no_system,
Expand All @@ -1646,6 +1648,7 @@ impl PipShowSettings {

Self {
package,
files,
settings: PipSettings::combine(
PipOptions {
python: python.and_then(Maybe::into_option),
Expand Down
66 changes: 66 additions & 0 deletions crates/uv/tests/it/pip_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,69 @@ fn show_required_by_multiple() -> Result<()> {

Ok(())
}

#[test]
fn show_files() {
let context = TestContext::new("3.12");

uv_snapshot!(context
.pip_install()
.arg("requests==2.31.0")
.arg("--strict"), @r#"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 5 packages in [TIME]
Prepared 5 packages in [TIME]
Installed 5 packages in [TIME]
+ certifi==2024.2.2
+ charset-normalizer==3.3.2
+ idna==3.6
+ requests==2.31.0
+ urllib3==2.2.1
"#
);

// Windows has a different files order.
#[cfg(not(windows))]
uv_snapshot!(context.filters(), context.pip_show().arg("requests").arg("--files"), @r#"
success: true
exit_code: 0
----- stdout -----
Name: requests
Version: 2.31.0
Location: [SITE_PACKAGES]/
Requires: certifi, charset-normalizer, idna, urllib3
Required-by:
Files:
requests-2.31.0.dist-info/INSTALLER
requests-2.31.0.dist-info/LICENSE
requests-2.31.0.dist-info/METADATA
requests-2.31.0.dist-info/RECORD
requests-2.31.0.dist-info/REQUESTED
requests-2.31.0.dist-info/WHEEL
requests-2.31.0.dist-info/top_level.txt
requests/__init__.py
requests/__version__.py
requests/_internal_utils.py
requests/adapters.py
requests/api.py
requests/auth.py
requests/certs.py
requests/compat.py
requests/cookies.py
requests/exceptions.py
requests/help.py
requests/hooks.py
requests/models.py
requests/packages.py
requests/sessions.py
requests/status_codes.py
requests/structures.py
requests/utils.py

----- stderr -----
"#);
}
2 changes: 2 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6440,6 +6440,8 @@ uv pip show [OPTIONS] [PACKAGE]...

<p>See <code>--project</code> to only change the project root directory.</p>

</dd><dt><code>--files</code>, <code>-f</code></dt><dd><p>Show the full list of installed files for each package</p>

</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>
Expand Down
Loading