diff --git a/crates/distribution-types/src/index_url.rs b/crates/distribution-types/src/index_url.rs index a6a0dcc2d..46b97551f 100644 --- a/crates/distribution-types/src/index_url.rs +++ b/crates/distribution-types/src/index_url.rs @@ -105,3 +105,11 @@ impl<'a> IntoIterator for &'a IndexUrls { self.index.iter().chain(self.extra_index.iter()) } } + +impl<'a> IndexUrls { + pub fn iter( + &'a self, + ) -> Chain, std::slice::Iter<'a, IndexUrl>> { + self.into_iter() + } +} diff --git a/crates/puffin-build/src/lib.rs b/crates/puffin-build/src/lib.rs index a6105918c..f27110363 100644 --- a/crates/puffin-build/src/lib.rs +++ b/crates/puffin-build/src/lib.rs @@ -8,7 +8,6 @@ use std::future::Future; use std::io; use std::io::BufRead; use std::path::{Path, PathBuf}; -use std::pin::Pin; use std::process::Output; use std::str::FromStr; use std::sync::Arc; @@ -544,16 +543,14 @@ impl SourceBuild { } impl SourceBuildTrait for SourceBuild { - fn metadata<'a>( - &'a mut self, - ) -> Pin>> + Send + 'a>> { + fn metadata(&mut self) -> impl Future>> + Send { Box::pin(async { Ok(self.get_metadata_without_build().await?) }) } fn wheel<'a>( &'a self, wheel_dir: &'a Path, - ) -> Pin> + Send + 'a>> { + ) -> impl Future> + Send + 'a { Box::pin(async { Ok(self.build(wheel_dir).await?) }) } } diff --git a/crates/puffin-dev/src/main.rs b/crates/puffin-dev/src/main.rs index e0e9eb46c..b82665dc5 100644 --- a/crates/puffin-dev/src/main.rs +++ b/crates/puffin-dev/src/main.rs @@ -58,7 +58,7 @@ enum Cli { ResolveMany(ResolveManyArgs), InstallMany(InstallManyArgs), /// Resolve requirements passed on the CLI - ResolveCli(ResolveCliArgs), + Resolve(ResolveCliArgs), WheelMetadata(WheelMetadataArgs), } @@ -75,7 +75,7 @@ async fn run() -> Result<()> { Cli::InstallMany(args) => { install_many::install_many(args).await?; } - Cli::ResolveCli(args) => { + Cli::Resolve(args) => { resolve_cli::resolve_cli(args).await?; } Cli::WheelMetadata(args) => wheel_metadata::wheel_metadata(args).await?, diff --git a/crates/puffin-dispatch/src/lib.rs b/crates/puffin-dispatch/src/lib.rs index 852290a76..4eb97e2f7 100644 --- a/crates/puffin-dispatch/src/lib.rs +++ b/crates/puffin-dispatch/src/lib.rs @@ -4,7 +4,6 @@ use std::future::Future; use std::path::{Path, PathBuf}; -use std::pin::Pin; use anyhow::{bail, Context, Result}; use itertools::Itertools; @@ -86,7 +85,7 @@ impl<'a> BuildContext for BuildDispatch<'a> { fn resolve<'data>( &'data self, requirements: &'data [Requirement], - ) -> Pin> + Send + 'data>> { + ) -> impl Future> + Send + 'data { Box::pin(async { let markers = self.interpreter.markers(); let tags = self.interpreter.tags()?; @@ -119,7 +118,7 @@ impl<'a> BuildContext for BuildDispatch<'a> { &'data self, resolution: &'data Resolution, venv: &'data Virtualenv, - ) -> Pin> + Send + 'data>> { + ) -> impl Future> + Send + 'data { Box::pin(async move { debug!( "Installing in {} in {}", @@ -223,7 +222,7 @@ impl<'a> BuildContext for BuildDispatch<'a> { subdirectory: Option<&'data Path>, package_id: &'data str, build_kind: BuildKind, - ) -> Pin> + Send + 'data>> { + ) -> impl Future> + Send + 'data { Box::pin(async move { if self.no_build { bail!("Building source distributions is disabled"); diff --git a/crates/puffin-resolver/src/resolver.rs b/crates/puffin-resolver/src/resolver.rs index 96927ffe2..ac1a5bd84 100644 --- a/crates/puffin-resolver/src/resolver.rs +++ b/crates/puffin-resolver/src/resolver.rs @@ -1,7 +1,6 @@ //! Given a set of requirements, find a set of compatible packages. use std::future::Future; -use std::pin::Pin; use std::sync::Arc; use anyhow::Result; @@ -52,7 +51,7 @@ pub trait ResolverProvider: Send + Sync { fn get_version_map<'io>( &'io self, package_name: &'io PackageName, - ) -> Pin + Send + 'io>>; + ) -> impl Future + Send + 'io; /// Get the metadata for a distribution. /// @@ -62,7 +61,7 @@ pub trait ResolverProvider: Send + Sync { fn get_or_build_wheel_metadata<'io>( &'io self, dist: &'io Dist, - ) -> Pin + Send + 'io>>; + ) -> impl Future + Send + 'io; /// Set the [`Reporter`] to use for this installer. #[must_use] @@ -109,7 +108,7 @@ impl<'a, Context: BuildContext + Send + Sync> ResolverProvider fn get_version_map<'io>( &'io self, package_name: &'io PackageName, - ) -> Pin + Send + 'io>> { + ) -> impl Future + Send + 'io { Box::pin( self.client .simple(package_name) @@ -134,7 +133,7 @@ impl<'a, Context: BuildContext + Send + Sync> ResolverProvider fn get_or_build_wheel_metadata<'io>( &'io self, dist: &'io Dist, - ) -> Pin + Send + 'io>> { + ) -> impl Future + Send + 'io { Box::pin(self.fetcher.get_or_build_wheel_metadata(dist)) } diff --git a/crates/puffin-resolver/tests/resolver.rs b/crates/puffin-resolver/tests/resolver.rs index c0fcb9859..3e290ffe3 100644 --- a/crates/puffin-resolver/tests/resolver.rs +++ b/crates/puffin-resolver/tests/resolver.rs @@ -3,9 +3,7 @@ //! Integration tests for the resolver. These tests rely on a live network connection, and hit //! `PyPI` directly. -use std::future::Future; use std::path::{Path, PathBuf}; -use std::pin::Pin; use std::str::FromStr; use anyhow::Result; @@ -51,45 +49,37 @@ impl BuildContext for DummyContext { panic!("The test should not need to build source distributions") } - fn resolve<'a>( - &'a self, - _requirements: &'a [Requirement], - ) -> Pin> + Send + 'a>> { + async fn resolve<'a>(&'a self, _requirements: &'a [Requirement]) -> Result { panic!("The test should not need to build source distributions") } - fn install<'a>( + async fn install<'a>( &'a self, _resolution: &'a Resolution, _venv: &'a Virtualenv, - ) -> Pin> + Send + 'a>> { + ) -> Result<()> { panic!("The test should not need to build source distributions") } - fn setup_build<'a>( + async fn setup_build<'a>( &'a self, _source: &'a Path, _subdirectory: Option<&'a Path>, _package_id: &'a str, _build_kind: BuildKind, - ) -> Pin> + Send + 'a>> { - Box::pin(async { Ok(DummyBuilder) }) + ) -> Result { + Ok(DummyBuilder) } } struct DummyBuilder; impl SourceBuildTrait for DummyBuilder { - fn metadata<'a>( - &'a mut self, - ) -> Pin>> + Send + 'a>> { + async fn metadata(&mut self) -> Result> { panic!("The test should not need to build source distributions") } - fn wheel<'a>( - &'a self, - _wheel_dir: &'a Path, - ) -> Pin> + Send + 'a>> { + async fn wheel<'a>(&'a self, _wheel_dir: &'a Path) -> Result { panic!("The test should not need to build source distributions") } } diff --git a/crates/puffin-traits/src/lib.rs b/crates/puffin-traits/src/lib.rs index 81e490e2c..7fe2a38d3 100644 --- a/crates/puffin-traits/src/lib.rs +++ b/crates/puffin-traits/src/lib.rs @@ -3,7 +3,6 @@ use std::fmt::{Display, Formatter}; use std::future::Future; use std::path::{Path, PathBuf}; -use std::pin::Pin; use anyhow::Result; @@ -77,7 +76,7 @@ pub trait BuildContext { fn resolve<'a>( &'a self, requirements: &'a [Requirement], - ) -> Pin> + Send + 'a>>; + ) -> impl Future> + Send + 'a; /// Install the given set of package versions into the virtual environment. The environment must /// use the same base python as [`BuildContext::base_python`] @@ -85,7 +84,7 @@ pub trait BuildContext { &'a self, resolution: &'a Resolution, venv: &'a Virtualenv, - ) -> Pin> + Send + 'a>>; + ) -> impl Future> + Send + 'a; /// Setup a source distribution build by installing the required dependencies. A wrapper for /// `puffin_build::SourceBuild::setup`. @@ -99,7 +98,7 @@ pub trait BuildContext { subdirectory: Option<&'a Path>, package_id: &'a str, build_kind: BuildKind, - ) -> Pin> + Send + 'a>>; + ) -> impl Future> + Send + 'a; } /// A wrapper for `puffin_build::SourceBuild` to avoid cyclical crate dependencies. @@ -113,19 +112,15 @@ pub trait SourceBuildTrait { /// /// Returns the metadata directory if we're having a PEP 517 build and the /// `prepare_metadata_for_build_wheel` hook exists - fn metadata<'a>( - &'a mut self, - ) -> Pin>> + Send + 'a>>; + fn metadata(&mut self) -> impl Future>> + Send; /// A wrapper for `puffin_build::SourceBuild::build`. /// /// For PEP 517 builds, this calls `build_wheel`. /// /// Returns the filename of the built wheel inside the given `wheel_dir`. - fn wheel<'a>( - &'a self, - wheel_dir: &'a Path, - ) -> Pin> + Send + 'a>>; + fn wheel<'a>(&'a self, wheel_dir: &'a Path) + -> impl Future> + Send + 'a; } #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 71326c3d7..6d833ff50 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.74" +channel = "1.75"