From 8ae344db6c28f4aa4c609afa497d0478297e321f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 24 Apr 2024 11:06:22 -0500 Subject: [PATCH] feat(python): display warning message when trying to use an unsupported Python version Closes https://github.com/astral-sh/uv/issues/2587. Co-authored-by: Stevie Gayet --- crates/uv/src/commands/venv.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index f96df2b26169..f17a74707305 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -24,6 +24,7 @@ use uv_fs::Simplified; use uv_interpreter::{find_default_python, find_requested_python, Error}; use uv_resolver::{ExcludeNewer, FlatIndex, InMemoryIndex, OptionsBuilder}; use uv_types::{BuildContext, BuildIsolation, HashStrategy, InFlight}; +use uv_warnings::warn_user; use crate::commands::ExitStatus; use crate::printer::Printer; @@ -120,6 +121,14 @@ async fn venv_impl( find_default_python(cache).into_diagnostic()? }; + // Warn on usage with an unsupported Python version + if interpreter.python_tuple() < (3, 8) { + warn_user!( + "uv is only compatible with Python 3.8+, found Python {}.", + interpreter.python_version() + ); + } + // Add all authenticated sources to the cache. for url in index_locations.urls() { store_credentials_from_url(url);