diff --git a/Cargo.lock b/Cargo.lock index fc5da8e685d67..e67fdfbf0dd0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4875,12 +4875,14 @@ dependencies = [ "fs2", "junction", "path-slash", + "rustix", "schemars", "serde", "tempfile", "tokio", "tracing", "urlencoding", + "winsafe 0.0.22", ] [[package]] @@ -5066,7 +5068,6 @@ dependencies = [ "reqwest", "reqwest-middleware", "rmp-serde", - "rustix", "same-file", "schemars", "serde", @@ -5091,7 +5092,6 @@ dependencies = [ "windows-registry", "windows-result 0.2.0", "windows-sys 0.59.0", - "winsafe 0.0.22", ] [[package]] diff --git a/crates/uv-fs/Cargo.toml b/crates/uv-fs/Cargo.toml index c7aa1cb1a20f3..88f53659bfa00 100644 --- a/crates/uv-fs/Cargo.toml +++ b/crates/uv-fs/Cargo.toml @@ -29,6 +29,12 @@ tempfile = { workspace = true } tracing = { workspace = true } urlencoding = { workspace = true } +[target.'cfg(target_os = "windows")'.dependencies] +winsafe = { workspace = true } + +[target.'cfg(any(unix, target_os = "wasi", target_os = "redox"))'.dependencies] +rustix = { workspace = true } + [target.'cfg(windows)'.dependencies] junction = { workspace = true } diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index 5c69e5a962b3f..658b6127ff1dc 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -12,6 +12,7 @@ pub use crate::path::*; pub mod cachedir; mod path; +pub mod which; /// Reads data from the path and requires that it be valid UTF-8 or UTF-16. /// diff --git a/crates/uv-python/src/which.rs b/crates/uv-fs/src/which.rs similarity index 100% rename from crates/uv-python/src/which.rs rename to crates/uv-fs/src/which.rs diff --git a/crates/uv-python/Cargo.toml b/crates/uv-python/Cargo.toml index 9bd7363ecc199..87d714fc76db4 100644 --- a/crates/uv-python/Cargo.toml +++ b/crates/uv-python/Cargo.toml @@ -53,12 +53,8 @@ tracing = { workspace = true } url = { workspace = true } which = { workspace = true } -[target.'cfg(any(unix, target_os = "wasi", target_os = "redox"))'.dependencies] -rustix = { workspace = true } - [target.'cfg(target_os = "windows")'.dependencies] windows-sys = { workspace = true } -winsafe = { workspace = true } windows-registry = { workspace = true } windows-result = { workspace = true } diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index a0ff76405ccdc..68938eeeda8bb 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -11,6 +11,7 @@ use which::{which, which_all}; use pep440_rs::{Prerelease, Version, VersionSpecifier, VersionSpecifiers}; use uv_cache::Cache; +use uv_fs::which::is_executable; use uv_fs::Simplified; use uv_warnings::warn_user_once; @@ -27,7 +28,6 @@ use crate::virtualenv::{ conda_prefix_from_env, virtualenv_from_env, virtualenv_from_working_dir, virtualenv_python_executable, }; -use crate::which::is_executable; use crate::{Interpreter, PythonVersion}; /// A request to find a Python installation. diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index b13ba983c809d..0d64bc6ce37b5 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -37,7 +37,6 @@ mod python_version; mod target; mod version_files; mod virtualenv; -pub mod which; #[cfg(not(test))] pub(crate) fn current_dir() -> Result { diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index b0e4c269b684b..5747ac8fc06a5 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -18,10 +18,11 @@ use uv_configuration::{ Concurrency, DevMode, EditableMode, ExtrasSpecification, InstallOptions, SourceStrategy, }; use uv_distribution::LoweredRequirement; +use uv_fs::which::is_executable; use uv_fs::{PythonExt, Simplified}; use uv_installer::{SatisfiesResult, SitePackages}; use uv_normalize::PackageName; -use uv_python::which::is_executable; + use uv_python::{ EnvironmentPreference, Interpreter, PythonDownloads, PythonEnvironment, PythonInstallation, PythonPreference, PythonRequest, PythonVersionFile, VersionRequest, @@ -723,10 +724,11 @@ pub(crate) async fn run( if let RunCommand::Empty = command { writeln!( printer.stdout(), - "Provide a command or script to invoke with `uv run ` or `uv run script.py`.\n" + "Provide a command or script to invoke with `uv run ` or `uv run