Skip to content

Commit

Permalink
Refactor uv-toolchain types (#4121)
Browse files Browse the repository at this point in the history
Extends #4120 
Part of #2607 

There should be no behavior changes here. Restructures the discovery API
to be focused on a toolchain first perspective in preparation for
exposing a `find_or_fetch` method for toolchains in
#4138.
  • Loading branch information
zanieb committed Jun 7, 2024
1 parent 325982c commit 53035d6
Show file tree
Hide file tree
Showing 23 changed files with 777 additions and 746 deletions.
4 changes: 2 additions & 2 deletions crates/bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn resolve_warm_jupyter(c: &mut Criterion<WallTime>) {
.unwrap();

let cache = &Cache::from_path("../../.cache").init().unwrap();
let venv = PythonEnvironment::from_virtualenv(cache).unwrap();
let venv = PythonEnvironment::from_root("../../.venv", cache).unwrap();
let client = &RegistryClientBuilder::new(cache.clone()).build();
let manifest = &Manifest::simple(vec![Requirement::from(
pep508_rs::Requirement::from_str("jupyter").unwrap(),
Expand Down Expand Up @@ -44,7 +44,7 @@ fn resolve_warm_airflow(c: &mut Criterion<WallTime>) {
.unwrap();

let cache = &Cache::from_path("../../.cache").init().unwrap();
let venv = PythonEnvironment::from_virtualenv(cache).unwrap();
let venv = PythonEnvironment::from_root("../../.venv", cache).unwrap();
let client = &RegistryClientBuilder::new(cache.clone()).build();
let manifest = &Manifest::simple(vec![
Requirement::from(pep508_rs::Requirement::from_str("apache-airflow[all]").unwrap()),
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-dev/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use uv_configuration::{
use uv_dispatch::BuildDispatch;
use uv_git::GitResolver;
use uv_resolver::{FlatIndex, InMemoryIndex};
use uv_toolchain::PythonEnvironment;
use uv_toolchain::Toolchain;
use uv_types::{BuildContext, BuildIsolation, InFlight};

#[derive(Parser)]
Expand Down Expand Up @@ -65,12 +65,12 @@ pub(crate) async fn build(args: BuildArgs) -> Result<PathBuf> {
let index = InMemoryIndex::default();
let index_urls = IndexLocations::default();
let setup_py = SetupPyStrategy::default();
let venv = PythonEnvironment::from_virtualenv(&cache)?;
let toolchain = Toolchain::find_virtualenv(&cache)?;

let build_dispatch = BuildDispatch::new(
&client,
&cache,
venv.interpreter(),
toolchain.interpreter(),
&index_urls,
&flat_index,
&index,
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-dev/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use clap::Parser;
use tracing::info;
use uv_cache::{Cache, CacheArgs};
use uv_toolchain::PythonEnvironment;
use uv_toolchain::Toolchain;

#[derive(Parser)]
pub(crate) struct CompileArgs {
Expand All @@ -20,8 +20,8 @@ pub(crate) async fn compile(args: CompileArgs) -> anyhow::Result<()> {
let interpreter = if let Some(python) = args.python {
python
} else {
let venv = PythonEnvironment::from_virtualenv(&cache)?;
venv.python_executable().to_path_buf()
let interpreter = Toolchain::find_virtualenv(&cache)?.into_interpreter();
interpreter.sys_executable().to_path_buf()
};

let files = uv_installer::compile_tree(
Expand Down
Loading

0 comments on commit 53035d6

Please sign in to comment.