mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 04:48:18 +00:00
Remove rust 1.75 workaround (#2959)
This commit is contained in:
parent
15f0be8f04
commit
273de456ea
1 changed files with 91 additions and 95 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
//! implementing [`BuildContext`].
|
//! implementing [`BuildContext`].
|
||||||
|
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::ffi::OsString;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{ffi::OsString, future::Future};
|
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
|
|
@ -155,7 +155,6 @@ impl<'a> BuildContext for BuildDispatch<'a> {
|
||||||
Ok(Resolution::from(graph))
|
Ok(Resolution::from(graph))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::manual_async_fn)] // TODO(konstin): rustc 1.75 gets into a type inference cycle with async fn
|
|
||||||
#[instrument(
|
#[instrument(
|
||||||
skip(self, resolution, venv),
|
skip(self, resolution, venv),
|
||||||
fields(
|
fields(
|
||||||
|
|
@ -163,113 +162,110 @@ impl<'a> BuildContext for BuildDispatch<'a> {
|
||||||
venv = ?venv.root()
|
venv = ?venv.root()
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
fn install<'data>(
|
async fn install<'data>(
|
||||||
&'data self,
|
&'data self,
|
||||||
resolution: &'data Resolution,
|
resolution: &'data Resolution,
|
||||||
venv: &'data PythonEnvironment,
|
venv: &'data PythonEnvironment,
|
||||||
) -> impl Future<Output = Result<()>> + Send + 'data {
|
) -> Result<()> {
|
||||||
async move {
|
debug!(
|
||||||
debug!(
|
"Installing in {} in {}",
|
||||||
"Installing in {} in {}",
|
resolution
|
||||||
|
.distributions()
|
||||||
|
.map(ToString::to_string)
|
||||||
|
.join(", "),
|
||||||
|
venv.root().display(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Determine the current environment markers.
|
||||||
|
let tags = self.interpreter.tags()?;
|
||||||
|
|
||||||
|
// Determine the set of installed packages.
|
||||||
|
let site_packages = SitePackages::from_executable(venv)?;
|
||||||
|
|
||||||
|
let Plan {
|
||||||
|
cached,
|
||||||
|
remote,
|
||||||
|
installed: _,
|
||||||
|
reinstalls,
|
||||||
|
extraneous: _,
|
||||||
|
} = Planner::with_requirements(&resolution.requirements()).build(
|
||||||
|
site_packages,
|
||||||
|
&Reinstall::None,
|
||||||
|
&NoBinary::None,
|
||||||
|
self.index_locations,
|
||||||
|
self.cache(),
|
||||||
|
venv,
|
||||||
|
tags,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Nothing to do.
|
||||||
|
if remote.is_empty() && cached.is_empty() && reinstalls.is_empty() {
|
||||||
|
debug!("No build requirements to install for build");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve any registry-based requirements.
|
||||||
|
let remote = remote
|
||||||
|
.iter()
|
||||||
|
.map(|dist| {
|
||||||
resolution
|
resolution
|
||||||
.distributions()
|
.get_remote(&dist.name)
|
||||||
.map(ToString::to_string)
|
.cloned()
|
||||||
.join(", "),
|
.expect("Resolution should contain all packages")
|
||||||
venv.root().display(),
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// Download any missing distributions.
|
||||||
|
let wheels = if remote.is_empty() {
|
||||||
|
vec![]
|
||||||
|
} else {
|
||||||
|
// TODO(konstin): Check that there is no endless recursion.
|
||||||
|
let downloader = Downloader::new(self.cache, tags, self.client, self);
|
||||||
|
debug!(
|
||||||
|
"Downloading and building requirement{} for build: {}",
|
||||||
|
if remote.len() == 1 { "" } else { "s" },
|
||||||
|
remote.iter().map(ToString::to_string).join(", ")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Determine the current environment markers.
|
downloader
|
||||||
let tags = self.interpreter.tags()?;
|
.download(remote, self.in_flight)
|
||||||
|
.await
|
||||||
|
.context("Failed to download and build distributions")?
|
||||||
|
};
|
||||||
|
|
||||||
// Determine the set of installed packages.
|
// Remove any unnecessary packages.
|
||||||
let site_packages = SitePackages::from_executable(venv)?;
|
if !reinstalls.is_empty() {
|
||||||
|
for dist_info in &reinstalls {
|
||||||
let Plan {
|
let summary = uv_installer::uninstall(dist_info)
|
||||||
cached,
|
|
||||||
remote,
|
|
||||||
installed: _,
|
|
||||||
reinstalls,
|
|
||||||
extraneous: _,
|
|
||||||
} = Planner::with_requirements(&resolution.requirements()).build(
|
|
||||||
site_packages,
|
|
||||||
&Reinstall::None,
|
|
||||||
&NoBinary::None,
|
|
||||||
self.index_locations,
|
|
||||||
self.cache(),
|
|
||||||
venv,
|
|
||||||
tags,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Nothing to do.
|
|
||||||
if remote.is_empty() && cached.is_empty() && reinstalls.is_empty() {
|
|
||||||
debug!("No build requirements to install for build");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve any registry-based requirements.
|
|
||||||
let remote = remote
|
|
||||||
.iter()
|
|
||||||
.map(|dist| {
|
|
||||||
resolution
|
|
||||||
.get_remote(&dist.name)
|
|
||||||
.cloned()
|
|
||||||
.expect("Resolution should contain all packages")
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// Download any missing distributions.
|
|
||||||
let wheels = if remote.is_empty() {
|
|
||||||
vec![]
|
|
||||||
} else {
|
|
||||||
// TODO(konstin): Check that there is no endless recursion.
|
|
||||||
let downloader = Downloader::new(self.cache, tags, self.client, self);
|
|
||||||
debug!(
|
|
||||||
"Downloading and building requirement{} for build: {}",
|
|
||||||
if remote.len() == 1 { "" } else { "s" },
|
|
||||||
remote.iter().map(ToString::to_string).join(", ")
|
|
||||||
);
|
|
||||||
|
|
||||||
downloader
|
|
||||||
.download(remote, self.in_flight)
|
|
||||||
.await
|
.await
|
||||||
.context("Failed to download and build distributions")?
|
.context("Failed to uninstall build dependencies")?;
|
||||||
};
|
|
||||||
|
|
||||||
// Remove any unnecessary packages.
|
|
||||||
if !reinstalls.is_empty() {
|
|
||||||
for dist_info in &reinstalls {
|
|
||||||
let summary = uv_installer::uninstall(dist_info)
|
|
||||||
.await
|
|
||||||
.context("Failed to uninstall build dependencies")?;
|
|
||||||
debug!(
|
|
||||||
"Uninstalled {} ({} file{}, {} director{})",
|
|
||||||
dist_info.name(),
|
|
||||||
summary.file_count,
|
|
||||||
if summary.file_count == 1 { "" } else { "s" },
|
|
||||||
summary.dir_count,
|
|
||||||
if summary.dir_count == 1 { "y" } else { "ies" },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install the resolved distributions.
|
|
||||||
let wheels = wheels.into_iter().chain(cached).collect::<Vec<_>>();
|
|
||||||
if !wheels.is_empty() {
|
|
||||||
debug!(
|
debug!(
|
||||||
"Installing build requirement{}: {}",
|
"Uninstalled {} ({} file{}, {} director{})",
|
||||||
if wheels.len() == 1 { "" } else { "s" },
|
dist_info.name(),
|
||||||
wheels.iter().map(ToString::to_string).join(", ")
|
summary.file_count,
|
||||||
|
if summary.file_count == 1 { "" } else { "s" },
|
||||||
|
summary.dir_count,
|
||||||
|
if summary.dir_count == 1 { "y" } else { "ies" },
|
||||||
);
|
);
|
||||||
Installer::new(venv)
|
|
||||||
.install(&wheels)
|
|
||||||
.context("Failed to install build dependencies")?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Install the resolved distributions.
|
||||||
|
let wheels = wheels.into_iter().chain(cached).collect::<Vec<_>>();
|
||||||
|
if !wheels.is_empty() {
|
||||||
|
debug!(
|
||||||
|
"Installing build requirement{}: {}",
|
||||||
|
if wheels.len() == 1 { "" } else { "s" },
|
||||||
|
wheels.iter().map(ToString::to_string).join(", ")
|
||||||
|
);
|
||||||
|
Installer::new(venv)
|
||||||
|
.install(&wheels)
|
||||||
|
.context("Failed to install build dependencies")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::manual_async_fn)] // TODO(konstin): rustc 1.75 gets into a type inference cycle with async fn
|
|
||||||
#[instrument(skip_all, fields(package_id = package_id, subdirectory = ?subdirectory))]
|
#[instrument(skip_all, fields(package_id = package_id, subdirectory = ?subdirectory))]
|
||||||
async fn setup_build<'data>(
|
async fn setup_build<'data>(
|
||||||
&'data self,
|
&'data self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue