mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Start puffin-dev (#193)
Currently, this is only the source distribution building feature moved. It's intended that we can add development and test commands there without affecting the main cli surface
This commit is contained in:
parent
862c1654a0
commit
216b6c41c2
7 changed files with 93 additions and 71 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
@ -2037,33 +2037,6 @@ dependencies = [
|
|||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "puffin-build-cli"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"colored",
|
||||
"directories",
|
||||
"fs-err",
|
||||
"futures",
|
||||
"gourgeist",
|
||||
"itertools",
|
||||
"pep508_rs",
|
||||
"platform-host",
|
||||
"platform-tags",
|
||||
"puffin-build",
|
||||
"puffin-client",
|
||||
"puffin-dispatch",
|
||||
"puffin-interpreter",
|
||||
"puffin-package",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "puffin-cli"
|
||||
version = "0.0.1"
|
||||
|
@ -2128,6 +2101,33 @@ dependencies = [
|
|||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "puffin-dev"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"colored",
|
||||
"directories",
|
||||
"fs-err",
|
||||
"futures",
|
||||
"gourgeist",
|
||||
"itertools",
|
||||
"pep508_rs",
|
||||
"platform-host",
|
||||
"platform-tags",
|
||||
"puffin-build",
|
||||
"puffin-client",
|
||||
"puffin-dispatch",
|
||||
"puffin-interpreter",
|
||||
"puffin-package",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "puffin-dispatch"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "puffin-build-cli"
|
||||
name = "puffin-dev"
|
||||
version = "0.0.1"
|
||||
description = "Build wheels from source distributions"
|
||||
edition = { workspace = true }
|
|
@ -1,29 +1,17 @@
|
|||
#![allow(clippy::print_stdout, clippy::print_stderr)]
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
use std::time::Instant;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use colored::Colorize;
|
||||
use directories::ProjectDirs;
|
||||
use fs_err as fs;
|
||||
use tracing::debug;
|
||||
use tracing_subscriber::fmt::format::FmtSpan;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
use platform_host::Platform;
|
||||
use puffin_build::SourceDistributionBuilder;
|
||||
use puffin_client::RegistryClientBuilder;
|
||||
use puffin_dispatch::BuildDispatch;
|
||||
use puffin_interpreter::Virtualenv;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
pub struct BuildArgs {
|
||||
/// Base python in a way that can be found with `which`
|
||||
/// TODO(konstin): Also use proper python parsing here
|
||||
#[clap(short, long)]
|
||||
|
@ -34,8 +22,8 @@ struct Args {
|
|||
sdist: PathBuf,
|
||||
}
|
||||
|
||||
async fn run() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
/// Build a source distribution to a wheel
|
||||
pub async fn build(args: BuildArgs) -> anyhow::Result<PathBuf> {
|
||||
let wheel_dir = if let Some(wheel_dir) = args.wheels {
|
||||
fs::create_dir_all(&wheel_dir).context("Invalid wheel directory")?;
|
||||
wheel_dir
|
||||
|
@ -61,27 +49,5 @@ async fn run() -> Result<()> {
|
|||
SourceDistributionBuilder::setup(&args.sdist, venv.interpreter_info(), &build_dispatch)
|
||||
.await?;
|
||||
let wheel = builder.build(&wheel_dir)?;
|
||||
println!("Wheel built to {}", wheel_dir.join(wheel).display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> ExitCode {
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer().with_span_events(FmtSpan::CLOSE))
|
||||
.with(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
let start = Instant::now();
|
||||
let result = run().await;
|
||||
debug!("Took {}ms", start.elapsed().as_millis());
|
||||
if let Err(err) = result {
|
||||
eprintln!("{}", "puffin-build failed".red().bold());
|
||||
for err in err.chain() {
|
||||
eprintln!(" {}: {}", "Caused by".red().bold(), err);
|
||||
}
|
||||
ExitCode::FAILURE
|
||||
} else {
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
Ok(wheel_dir.join(wheel))
|
||||
}
|
3
crates/puffin-dev/src/lib.rs
Normal file
3
crates/puffin-dev/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub use build::{build, BuildArgs};
|
||||
|
||||
mod build;
|
53
crates/puffin-dev/src/main.rs
Normal file
53
crates/puffin-dev/src/main.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
#![allow(clippy::print_stdout, clippy::print_stderr)]
|
||||
|
||||
use std::process::ExitCode;
|
||||
use std::time::Instant;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use colored::Colorize;
|
||||
use tracing::debug;
|
||||
use tracing_subscriber::fmt::format::FmtSpan;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
use puffin_dev::{build, BuildArgs};
|
||||
|
||||
#[derive(Parser)]
|
||||
enum Cli {
|
||||
/// Build a source distribution into a wheel
|
||||
Build(BuildArgs),
|
||||
}
|
||||
|
||||
async fn run() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
match cli {
|
||||
Cli::Build(args) => {
|
||||
let target = build(args).await?;
|
||||
println!("Wheel built to {}", target.display());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> ExitCode {
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer().with_span_events(FmtSpan::CLOSE))
|
||||
.with(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
let start = Instant::now();
|
||||
let result = run().await;
|
||||
debug!("Took {}ms", start.elapsed().as_millis());
|
||||
if let Err(err) = result {
|
||||
eprintln!("{}", "puffin-dev failed".red().bold());
|
||||
for err in err.chain() {
|
||||
eprintln!(" {}: {}", "Caused by".red().bold(), err);
|
||||
}
|
||||
ExitCode::FAILURE
|
||||
} else {
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
}
|
|
@ -12,8 +12,8 @@ if [ ! -f sdist_building_test_data/sdist/geoextract-0.3.1.tar.gz ]; then
|
|||
wget https://files.pythonhosted.org/packages/c4/00/9d9826a6e1c9139cc7183647f47f6b7acb290fa4c572140aa84a12728e60/geoextract-0.3.1.tar.gz -O sdist_building_test_data/sdist/geoextract-0.3.1.tar.gz
|
||||
fi
|
||||
rm -rf sdist_building_test_data/wheels
|
||||
RUST_LOG=puffin_build=debug cargo run -p puffin-build-cli --bin puffin-build-cli -- --wheels sdist_building_test_data/wheels sdist_building_test_data/sdist/tqdm-4.66.1.tar.gz
|
||||
RUST_LOG=puffin_build=debug cargo run -p puffin-build-cli --bin puffin-build-cli -- --wheels sdist_building_test_data/wheels sdist_building_test_data/sdist/geoextract-0.3.1.tar.gz
|
||||
RUST_LOG=puffin_build=debug cargo run --bin puffin-dev -- build --wheels sdist_building_test_data/wheels sdist_building_test_data/sdist/tqdm-4.66.1.tar.gz
|
||||
RUST_LOG=puffin_build=debug cargo run --bin puffin-dev -- build --wheels sdist_building_test_data/wheels sdist_building_test_data/sdist/geoextract-0.3.1.tar.gz
|
||||
|
||||
# Check that pip accepts the wheels. It would be better to do functional checks
|
||||
virtualenv -p 3.8 -q --clear sdist_building_test_data/.venv
|
Loading…
Add table
Add a link
Reference in a new issue