Skip to content

Commit 319c018

Browse files
samypr100konstin
andauthored
Add templates for popular build backends (#7857)
Co-authored-by: konstin <[email protected]>
1 parent ea0c32d commit 319c018

File tree

9 files changed

+1063
-53
lines changed

9 files changed

+1063
-53
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use url::Url;
1212
use uv_cache::CacheArgs;
1313
use uv_configuration::{
1414
ConfigSettingEntry, ExportFormat, IndexStrategy, KeyringProviderType, PackageNameSpecifier,
15-
TargetTriple, TrustedHost, TrustedPublishing, VersionControlSystem,
15+
ProjectBuildBackend, TargetTriple, TrustedHost, TrustedPublishing, VersionControlSystem,
1616
};
1717
use uv_distribution_types::{Index, IndexUrl, Origin, PipExtraIndex, PipFindLinks, PipIndex};
1818
use uv_normalize::{ExtraName, PackageName};
@@ -2525,6 +2525,10 @@ pub struct InitArgs {
25252525
#[arg(long, value_enum, conflicts_with = "script")]
25262526
pub vcs: Option<VersionControlSystem>,
25272527

2528+
/// Initialize a build-backend of choice for the project.
2529+
#[arg(long, value_enum, conflicts_with_all=["script", "no_package"])]
2530+
pub build_backend: Option<ProjectBuildBackend>,
2531+
25282532
/// Do not create a `README.md` file.
25292533
#[arg(long)]
25302534
pub no_readme: bool,

crates/uv-configuration/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use name_specifiers::*;
1414
pub use overrides::*;
1515
pub use package_options::*;
1616
pub use preview::*;
17+
pub use project_build_backend::*;
1718
pub use sources::*;
1819
pub use target_triple::*;
1920
pub use trusted_host::*;
@@ -36,6 +37,7 @@ mod name_specifiers;
3637
mod overrides;
3738
mod package_options;
3839
mod preview;
40+
mod project_build_backend;
3941
mod sources;
4042
mod target_triple;
4143
mod trusted_host;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// Available project build backends for use in `pyproject.toml`.
2+
#[derive(Clone, Copy, Debug, PartialEq, Default, serde::Deserialize)]
3+
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
4+
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
5+
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
6+
pub enum ProjectBuildBackend {
7+
#[default]
8+
/// Use [hatchling](https://pypi.org/project/hatchling) as the project build backend.
9+
Hatch,
10+
/// Use [flit-core](https://pypi.org/project/flit-core) as the project build backend.
11+
Flit,
12+
/// Use [pdm-backend](https://pypi.org/project/pdm-backend) as the project build backend.
13+
PDM,
14+
/// Use [setuptools](https://pypi.org/project/setuptools) as the project build backend.
15+
Setuptools,
16+
/// Use [maturin](https://pypi.org/project/maturin) as the project build backend.
17+
Maturin,
18+
/// Use [scikit-build-core](https://pypi.org/project/scikit-build-core) as the project build backend.
19+
Scikit,
20+
}

0 commit comments

Comments
 (0)