diff --git a/Cargo.lock b/Cargo.lock index 82682caf6..d5e65eb07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5035,6 +5035,7 @@ dependencies = [ "uv-cache", "uv-fs", "uv-interpreter", + "uv-version", ] [[package]] diff --git a/crates/uv-build/src/lib.rs b/crates/uv-build/src/lib.rs index 4cf7bc04b..045162e11 100644 --- a/crates/uv-build/src/lib.rs +++ b/crates/uv-build/src/lib.rs @@ -414,7 +414,6 @@ impl SourceBuild { interpreter.clone(), uv_virtualenv::Prompt::None, false, - Vec::new(), )?, BuildIsolation::Shared(venv) => venv.clone(), }; diff --git a/crates/uv-virtualenv/Cargo.toml b/crates/uv-virtualenv/Cargo.toml index 88879cb8c..7fa1512f2 100644 --- a/crates/uv-virtualenv/Cargo.toml +++ b/crates/uv-virtualenv/Cargo.toml @@ -26,6 +26,7 @@ pypi-types = { workspace = true } uv-cache = { workspace = true } uv-fs = { workspace = true } uv-interpreter = { workspace = true } +uv-version = { workspace = true } anstream = { workspace = true } cachedir = { workspace = true } diff --git a/crates/uv-virtualenv/src/bare.rs b/crates/uv-virtualenv/src/bare.rs index a63b3e33d..2ee30baf8 100644 --- a/crates/uv-virtualenv/src/bare.rs +++ b/crates/uv-virtualenv/src/bare.rs @@ -11,10 +11,10 @@ use fs_err::File; use pypi_types::Scheme; use tracing::info; +use crate::{Error, Prompt}; use uv_fs::Simplified; use uv_interpreter::{Interpreter, Virtualenv}; - -use crate::{Error, Prompt}; +use uv_version::version; /// The bash activate scripts with the venv dependent paths patches out const ACTIVATE_TEMPLATES: &[(&str, &str)] = &[ @@ -47,7 +47,6 @@ pub fn create_bare_venv( interpreter: &Interpreter, prompt: Prompt, system_site_packages: bool, - extra_cfg: Vec<(String, String)>, ) -> Result { // Determine the base Python executable; that is, the Python executable that should be // considered the "base" for the virtual environment. This is typically the Python executable @@ -218,23 +217,6 @@ pub fn create_bare_venv( fs::write(scripts.join(name), activator)?; } - // Validate extra_cfg - let reserved_keys = [ - "home", - "implementation", - "version_info", - "include-system-site-packages", - "base-prefix", - "base-exec-prefix", - "base-executable", - "prompt", - ]; - for (key, _) in &extra_cfg { - if reserved_keys.contains(&key.as_str()) { - return Err(Error::ReservedConfigKey(key.to_string())); - } - } - let mut pyvenv_cfg_data: Vec<(String, String)> = vec![ ( "home".to_string(), @@ -244,6 +226,7 @@ pub fn create_bare_venv( "implementation".to_string(), interpreter.markers().platform_python_implementation.clone(), ), + ("uv".to_string(), version().to_string()), ( "version_info".to_string(), interpreter.markers().python_full_version.string.clone(), @@ -256,10 +239,7 @@ pub fn create_bare_venv( "false".to_string() }, ), - ] - .into_iter() - .chain(extra_cfg) - .collect(); + ]; if let Some(prompt) = prompt { pyvenv_cfg_data.push(("prompt".to_string(), prompt)); diff --git a/crates/uv-virtualenv/src/lib.rs b/crates/uv-virtualenv/src/lib.rs index ce9e730b8..21d84636c 100644 --- a/crates/uv-virtualenv/src/lib.rs +++ b/crates/uv-virtualenv/src/lib.rs @@ -18,8 +18,6 @@ pub enum Error { InterpreterError(#[from] uv_interpreter::Error), #[error(transparent)] Platform(#[from] PlatformError), - #[error("Reserved key used for pyvenv.cfg: {0}")] - ReservedConfigKey(String), #[error("Could not find a suitable Python executable for the virtual environment based on the interpreter: {0}")] NotFound(String), } @@ -53,16 +51,9 @@ pub fn create_venv( interpreter: Interpreter, prompt: Prompt, system_site_packages: bool, - extra_cfg: Vec<(String, String)>, ) -> Result { // Create the virtualenv at the given location. - let virtualenv = create_bare_venv( - location, - &interpreter, - prompt, - system_site_packages, - extra_cfg, - )?; + let virtualenv = create_bare_venv(location, &interpreter, prompt, system_site_packages)?; // Create the corresponding `PythonEnvironment`. let interpreter = interpreter.with_virtualenv(virtualenv); diff --git a/crates/uv-virtualenv/src/main.rs b/crates/uv-virtualenv/src/main.rs index 1dda61ed6..20752e895 100644 --- a/crates/uv-virtualenv/src/main.rs +++ b/crates/uv-virtualenv/src/main.rs @@ -46,7 +46,6 @@ fn run() -> Result<(), uv_virtualenv::Error> { &interpreter, Prompt::from_args(cli.prompt), cli.system_site_packages, - Vec::new(), )?; Ok(()) } diff --git a/crates/uv/src/commands/run.rs b/crates/uv/src/commands/run.rs index 9ca80dd82..5dee4e4e2 100644 --- a/crates/uv/src/commands/run.rs +++ b/crates/uv/src/commands/run.rs @@ -233,7 +233,6 @@ async fn environment_for_run( python_env.into_interpreter(), uv_virtualenv::Prompt::None, false, - Vec::new(), )?; // Determine the tags, markers, and interpreter to use for resolution. diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index cadbf4932..f96df2b26 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -140,13 +140,9 @@ async fn venv_impl( ) .into_diagnostic()?; - // Extra cfg for pyvenv.cfg to specify uv version - let extra_cfg = vec![("uv".to_string(), env!("CARGO_PKG_VERSION").to_string())]; - // Create the virtual environment. - let venv = - uv_virtualenv::create_venv(path, interpreter, prompt, system_site_packages, extra_cfg) - .map_err(VenvError::Creation)?; + let venv = uv_virtualenv::create_venv(path, interpreter, prompt, system_site_packages) + .map_err(VenvError::Creation)?; // Install seed packages. if seed {