Skip to content

Commit

Permalink
feat(init): support different init build backends
Browse files Browse the repository at this point in the history
  • Loading branch information
samypr100 committed Oct 14, 2024
1 parent 01c44af commit 38e2eb3
Show file tree
Hide file tree
Showing 9 changed files with 1,381 additions and 33 deletions.
9 changes: 8 additions & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use url::Url;
use uv_cache::CacheArgs;
use uv_configuration::{
ConfigSettingEntry, ExportFormat, IndexStrategy, KeyringProviderType, PackageNameSpecifier,
TargetTriple, TrustedHost, TrustedPublishing, VersionControlSystem,
ProjectBuildBackend, TargetTriple, TrustedHost, TrustedPublishing, VersionControlSystem,
};
use uv_distribution_types::{FlatIndexLocation, IndexUrl};
use uv_normalize::{ExtraName, PackageName};
Expand Down Expand Up @@ -2461,6 +2461,13 @@ pub struct InitArgs {
#[arg(long, value_enum, conflicts_with = "script")]
pub vcs: Option<VersionControlSystem>,

/// Initialize a build-backend of choice for the project.
///
/// By default, uv will use (`hatchling`). Use `--build-backend` to specify an
/// alternative build backend.
#[arg(long, value_enum, conflicts_with_all=["script", "no_package"])]
pub build_backend: Option<ProjectBuildBackend>,

/// Do not create a `README.md` file.
#[arg(long)]
pub no_readme: bool,
Expand Down
2 changes: 2 additions & 0 deletions crates/uv-configuration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub use name_specifiers::*;
pub use overrides::*;
pub use package_options::*;
pub use preview::*;
pub use project_build_backend::*;
pub use sources::*;
pub use target_triple::*;
pub use trusted_host::*;
Expand All @@ -34,6 +35,7 @@ mod name_specifiers;
mod overrides;
mod package_options;
mod preview;
mod project_build_backend;
mod sources;
mod target_triple;
mod trusted_host;
Expand Down
22 changes: 22 additions & 0 deletions crates/uv-configuration/src/project_build_backend.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// Available project build backends for use in `pyproject.toml`.
#[derive(Clone, Copy, Debug, PartialEq, Default, serde::Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ProjectBuildBackend {
#[default]
/// Use [hatchling](https://pypi.org/project/hatchling) as the project build backend.
Hatch,
/// Use [flit-core](https://pypi.org/project/flit-core) as the project build backend.
Flit,
/// Use [pdm-backend](https://pypi.org/project/pdm-backend) as the project build backend.
PDM,
/// Use [setuptools](https://pypi.org/project/setuptools) as the project build backend.
Setuptools,
/// Use [maturin](https://pypi.org/project/maturin) as the project build backend.
Maturin,
/// Use [scikit-build-core](https://pypi.org/project/scikit-build-core) as the project build backend.
Scikit,
/// Use [meson-python](https://pypi.org/project/meson-python) as the project build backend.
Meson,
}
Loading

0 comments on commit 38e2eb3

Please sign in to comment.