Implement uv build (#6895)

## Summary

This PR exposes uv's PEP 517 implementation via a `uv build` frontend,
such that you can use `uv build` to build source and binary
distributions (i.e., wheels and sdists) from a given directory.

There are some TODOs that I'll tackle in separate PRs:

- [x] Support building a wheel from a source distribution (rather than
from source) (#6898)
- [x] Stream the build output (#6912)

Closes https://github.com/astral-sh/uv/issues/1510

Closes https://github.com/astral-sh/uv/issues/1663.
This commit is contained in:
Charlie Marsh 2024-09-04 11:23:46 -04:00 committed by GitHub
parent a3a1bfd5ec
commit df84d25a7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1028 additions and 168 deletions

View file

@ -4,7 +4,7 @@ use std::process::ExitCode;
use std::str::FromStr;
use std::time::Instant;
use anstream::{eprintln, println};
use anstream::eprintln;
use anyhow::Result;
use clap::Parser;
use owo_colors::OwoColorize;
@ -16,7 +16,6 @@ use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{EnvFilter, Layer};
use crate::build::{build, BuildArgs};
use crate::clear_compile::ClearCompileArgs;
use crate::compile::CompileArgs;
use crate::generate_all::Args as GenerateAllArgs;
@ -43,7 +42,6 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
mod build;
mod clear_compile;
mod compile;
mod generate_all;
@ -57,8 +55,6 @@ const ROOT_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../");
#[derive(Parser)]
enum Cli {
/// Build a source distribution into a wheel.
Build(BuildArgs),
/// Display the metadata for a `.whl` at a given URL.
WheelMetadata(WheelMetadataArgs),
/// Compile all `.py` to `.pyc` files in the tree.
@ -82,10 +78,6 @@ enum Cli {
async fn run() -> Result<()> {
let cli = Cli::parse();
match cli {
Cli::Build(args) => {
let target = build(args).await?;
println!("Wheel built to {}", target.display());
}
Cli::WheelMetadata(args) => wheel_metadata::wheel_metadata(args).await?,
Cli::Compile(args) => compile::compile(args).await?,
Cli::ClearCompile(args) => clear_compile::clear_compile(&args)?,