Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 30, 2024
1 parent 1594e3b commit c704aee
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions crates/uv/src/commands/venv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use uv_configuration::{
NoBuild, PreviewMode, SetupPyStrategy,
};
use uv_dispatch::BuildDispatch;
use uv_fs::Simplified;
use uv_fs::{Simplified, CWD};
use uv_python::{
request_from_version_file, EnvironmentPreference, PythonFetch, PythonInstallation,
PythonPreference, PythonRequest, VersionRequest,
Expand Down Expand Up @@ -132,25 +132,27 @@ async fn venv_impl(
printer: Printer,
relocatable: bool,
) -> miette::Result<ExitStatus> {
if preview.is_disabled() && relocatable {
warn_user_once!("`--relocatable` is experimental and may change without warning");
}

let client_builder = BaseClientBuilder::default()
.connectivity(connectivity)
.native_tls(native_tls);

let client_builder_clone = client_builder.clone();

let reporter = PythonDownloadReporter::single(printer);

// (1) Explicit request from user
let mut interpreter_request = python_request.map(PythonRequest::parse);

// (2) Request from `.python-version`
if preview.is_enabled() && interpreter_request.is_none() {
interpreter_request = request_from_version_file().await.into_diagnostic()?;
}

// (3) `Requires-Python` in `pyproject.toml`
if preview.is_enabled() && interpreter_request.is_none() {
let project = match VirtualProject::discover(
&std::env::current_dir().into_diagnostic()?,
&DiscoveryOptions::default(),
)
.await
{
let project = match VirtualProject::discover(&CWD, &DiscoveryOptions::default()).await {
Ok(project) => Some(project),
Err(WorkspaceError::MissingPyprojectToml) => None,
Err(WorkspaceError::NonWorkspace(_)) => None,
Expand All @@ -167,9 +169,6 @@ async fn venv_impl(
});
}
}
if preview.is_disabled() && relocatable {
warn_user_once!("`--relocatable` is experimental and may change without warning");
}

// Locate the Python interpreter to use in the environment
let python = PythonInstallation::find_or_fetch(
Expand Down Expand Up @@ -239,7 +238,7 @@ async fn venv_impl(
}

// Instantiate a client.
let client = RegistryClientBuilder::from(client_builder_clone)
let client = RegistryClientBuilder::from(client_builder)
.cache(cache.clone())
.index_urls(index_locations.index_urls())
.index_strategy(index_strategy)
Expand Down

0 comments on commit c704aee

Please sign in to comment.