mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 12:24:15 +00:00
parent
05a56dab61
commit
bcc52ed108
6 changed files with 89 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::fmt::Write;
|
||||
|
||||
use anyhow::Result;
|
||||
use fs_err::File;
|
||||
use itertools::{Either, Itertools};
|
||||
use owo_colors::OwoColorize;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
|
@ -8,6 +9,7 @@ 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};
|
||||
|
|
@ -22,6 +24,7 @@ pub(crate) fn pip_show(
|
|||
strict: bool,
|
||||
python: Option<&str>,
|
||||
system: bool,
|
||||
files: bool,
|
||||
cache: &Cache,
|
||||
printer: Printer,
|
||||
) -> Result<ExitStatus> {
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
@ -1638,6 +1639,7 @@ impl PipShowSettings {
|
|||
package,
|
||||
strict,
|
||||
no_strict,
|
||||
files,
|
||||
python,
|
||||
system,
|
||||
no_system,
|
||||
|
|
@ -1646,6 +1648,7 @@ impl PipShowSettings {
|
|||
|
||||
Self {
|
||||
package,
|
||||
files,
|
||||
settings: PipSettings::combine(
|
||||
PipOptions {
|
||||
python: python.and_then(Maybe::into_option),
|
||||
|
|
|
|||
|
|
@ -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 -----
|
||||
"#);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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’s native certificate store.</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue