mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Add user-facing output to indicate PEP 723 script (#4881)
This commit is contained in:
parent
ae242c3b8f
commit
ffcc05240e
2 changed files with 19 additions and 10 deletions
|
@ -1,9 +1,11 @@
|
|||
use std::borrow::Cow;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use itertools::Itertools;
|
||||
use owo_colors::OwoColorize;
|
||||
use tokio::process::Command;
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -13,6 +15,7 @@ use uv_cli::ExternalCommand;
|
|||
use uv_client::{BaseClientBuilder, Connectivity};
|
||||
use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode};
|
||||
use uv_distribution::{VirtualProject, Workspace, WorkspaceError};
|
||||
use uv_fs::Simplified;
|
||||
use uv_installer::{SatisfiesResult, SitePackages};
|
||||
use uv_normalize::PackageName;
|
||||
use uv_python::{
|
||||
|
@ -63,7 +66,11 @@ pub(crate) async fn run(
|
|||
// Determine whether the command to execute is a PEP 723 script.
|
||||
let script_interpreter = if let RunCommand::Python(target, _) = &command {
|
||||
if let Some(metadata) = uv_scripts::read_pep723_metadata(&target).await? {
|
||||
debug!("Found PEP 723 script at: {}", target.display());
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Reading inline script metadata from: {}",
|
||||
target.user_display().cyan()
|
||||
)?;
|
||||
|
||||
// (1) Explicit request from user
|
||||
let python_request = if let Some(request) = python.as_deref() {
|
||||
|
|
|
@ -225,16 +225,17 @@ fn run_script() -> Result<()> {
|
|||
|
||||
// Running the script should install the requirements.
|
||||
uv_snapshot!(context.filters(), context.run().arg("--preview").arg("main.py"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ iniconfig==2.0.0
|
||||
"###);
|
||||
----- stderr -----
|
||||
Reading inline script metadata from: main.py
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ iniconfig==2.0.0
|
||||
"###);
|
||||
|
||||
// Running again should use the existing environment.
|
||||
uv_snapshot!(context.filters(), context.run().arg("--preview").arg("main.py"), @r###"
|
||||
|
@ -243,6 +244,7 @@ fn run_script() -> Result<()> {
|
|||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Reading inline script metadata from: main.py
|
||||
Resolved 1 package in [TIME]
|
||||
"###);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue