Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature gate maturin new and maturin init commands #1330

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ tracing = "0.1.36"
tracing-subscriber = { version = "0.3.15", features = ["env-filter"], optional = true }

# project scaffolding, maturin new/init
dialoguer = { version = "0.10.2", default-features = false }
console = "0.15.2"
minijinja = "0.26.0"
dialoguer = { version = "0.10.2", default-features = false, optional = true }
console = { version = "0.15.2", optional = true }
minijinja = { version = "0.26.0", optional = true }

# upload
bytesize = { version = "1.0.1", optional = true }
Expand All @@ -88,18 +88,29 @@ rustversion = "1.0.9"
trycmd = "0.14.0"

[features]
default = ["cross-compile", "log", "upload", "rustls"]
default = ["full", "rustls"]

full = ["cross-compile", "log", "scaffolding", "upload"]

log = ["tracing-subscriber"]

upload = ["ureq", "multipart", "rpassword", "configparser", "bytesize"]
password-storage = ["upload", "keyring"]
log = ["tracing-subscriber"]

rustls = ["ureq/tls", "cargo-xwin/rustls-tls"]
native-tls = ["ureq/native-tls", "native-tls-crate", "cargo-xwin/native-tls"]

# cross compile using zig or xwin
cross-compile = ["zig", "xwin"]
zig = ["cargo-zigbuild"]
xwin = ["cargo-xwin"]

# project scaffolding
scaffolding = ["dialoguer", "console", "minijinja"]

# Internal feature to speed up the tests significantly
faster-tests = []

# Deprecated features, keep it now for compatibility
human-panic = []

Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub use crate::metadata::{Metadata21, WheelMetadata};
pub use crate::module_writer::{
write_dist_info, ModuleWriter, PathWriter, SDistWriter, WheelWriter,
};
#[cfg(feature = "scaffolding")]
pub use crate::new_project::{init_project, new_project, GenerateProjectOptions};
pub use crate::pyproject_toml::PyProjectToml;
pub use crate::python_interpreter::PythonInterpreter;
Expand All @@ -49,6 +50,7 @@ mod cross_compile;
mod develop;
mod metadata;
mod module_writer;
#[cfg(feature = "scaffolding")]
mod new_project;
mod project_layout;
pub mod pyproject_toml;
Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ use anyhow::{bail, Context, Result};
use cargo_zigbuild::Zig;
use clap::{CommandFactory, Parser, Subcommand};
use maturin::{
develop, init_project, new_project, write_dist_info, BridgeModel, BuildOptions, CargoOptions,
GenerateProjectOptions, PathWriter, PlatformTag, PythonInterpreter, Target,
develop, write_dist_info, BridgeModel, BuildOptions, CargoOptions, PathWriter, PlatformTag,
PythonInterpreter, Target,
};
#[cfg(feature = "scaffolding")]
use maturin::{init_project, new_project, GenerateProjectOptions};
#[cfg(feature = "upload")]
use maturin::{upload_ui, PublishOpt};
use std::env;
Expand Down Expand Up @@ -114,6 +116,7 @@ enum Opt {
out: Option<PathBuf>,
},
/// Create a new cargo project in an existing directory
#[cfg(feature = "scaffolding")]
#[command(name = "init")]
InitProject {
/// Project path
Expand All @@ -122,6 +125,7 @@ enum Opt {
options: GenerateProjectOptions,
},
/// Create a new cargo project
#[cfg(feature = "scaffolding")]
#[command(name = "new")]
NewProject {
/// Project path
Expand Down Expand Up @@ -393,7 +397,9 @@ fn run() -> Result<()> {
.context("Failed to build source distribution, pyproject.toml not found")?;
}
Opt::Pep517(subcommand) => pep517(subcommand)?,
#[cfg(feature = "scaffolding")]
Opt::InitProject { path, options } => init_project(path, options)?,
#[cfg(feature = "scaffolding")]
Opt::NewProject { path, options } => new_project(path, options)?,
#[cfg(feature = "upload")]
Opt::Upload { publish, files } => {
Expand Down