@@ -20,9 +20,7 @@ use uv_configuration::{ConfigSettings, IndexStrategy, NoBinary, NoBuild, SetupPy
2020use uv_dispatch:: BuildDispatch ;
2121use uv_fs:: Simplified ;
2222use uv_git:: GitResolver ;
23- use uv_interpreter:: {
24- find_default_interpreter, find_interpreter, InterpreterRequest , SourceSelector ,
25- } ;
23+ use uv_interpreter:: { PythonEnvironment , SystemPython } ;
2624use uv_resolver:: { ExcludeNewer , FlatIndex , InMemoryIndex , OptionsBuilder } ;
2725use uv_types:: { BuildContext , BuildIsolation , HashStrategy , InFlight } ;
2826
@@ -121,18 +119,17 @@ async fn venv_impl(
121119 cache : & Cache ,
122120 printer : Printer ,
123121) -> miette:: Result < ExitStatus > {
124- // Locate the Python interpreter.
125- let interpreter = if let Some ( python) = python_request. as_ref ( ) {
126- let system = uv_interpreter:: SystemPython :: Required ;
127- let request = InterpreterRequest :: parse ( python) ;
128- let sources = SourceSelector :: from_settings ( system, preview) ;
129- find_interpreter ( & request, system, & sources, cache)
122+ // Locate the Python interpreter to use in the environment
123+ // If a specific interpreter is requested, it is required to come from the system.
124+ // Otherwise, we'll allow the interpeter from a virtual environment to be used.
125+ let system = if python_request. is_some ( ) {
126+ SystemPython :: Required
130127 } else {
131- find_default_interpreter ( preview , cache )
132- }
133- . into_diagnostic ( ) ?
134- . into_diagnostic ( ) ?
135- . into_interpreter ( ) ;
128+ SystemPython :: Allowed
129+ } ;
130+ let interpreter = PythonEnvironment :: find ( python_request , system , preview , cache )
131+ . into_diagnostic ( ) ?
132+ . into_interpreter ( ) ;
136133
137134 // Add all authenticated sources to the cache.
138135 for url in index_locations. urls ( ) {
0 commit comments