Skip to content
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
2 changes: 0 additions & 2 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ pub struct BuildContext {
/// The directory to store the built wheels in. Defaults to a new "wheels"
/// directory in the project's target directory
pub out: PathBuf,
/// Build artifacts in release mode, with optimizations
pub release: bool,
/// Strip the library for minimum file size
pub strip: bool,
/// Checking the linked libraries for manylinux/musllinux compliance
Expand Down
9 changes: 0 additions & 9 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ impl BuildOptions {
#[derive(Debug)]
pub struct BuildContextBuilder {
build_options: BuildOptions,
release: bool,
strip: bool,
editable: bool,
sdist_only: bool,
Expand All @@ -559,18 +558,12 @@ impl BuildContextBuilder {
fn new(build_options: BuildOptions) -> Self {
Self {
build_options,
release: false,
strip: false,
editable: false,
sdist_only: false,
}
}

pub fn release(mut self, release: bool) -> Self {
self.release = release;
self
}

pub fn strip(mut self, strip: bool) -> Self {
self.strip = strip;
self
Expand All @@ -589,7 +582,6 @@ impl BuildContextBuilder {
pub fn build(self) -> Result<BuildContext> {
let Self {
build_options,
release,
strip,
editable,
sdist_only,
Expand Down Expand Up @@ -819,7 +811,6 @@ impl BuildContextBuilder {
manifest_path: cargo_toml_path,
target_dir,
out: wheel_dir,
release,
strip,
auditwheel,
#[cfg(feature = "zig")]
Expand Down
5 changes: 0 additions & 5 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ fn cargo_build_command(
.into_rustc_options(user_specified_target);
cargo_rustc.message_format = vec!["json-render-diagnostics".to_string()];

// --release and --profile are conflicting options
if context.release && cargo_rustc.profile.is_none() {
cargo_rustc.release = true;
}

// Add `--crate-type cdylib` if available
if compile_target
.target
Expand Down
8 changes: 6 additions & 2 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,17 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {
extras,
skip_install,
pip_path,
cargo_options,
mut cargo_options,
uv,
compression,
} = develop_options;
compression.validate();

// set profile to release if specified; `--release` and `--profile` are mutually exclusive
if release {
cargo_options.profile = Some("release".to_string());
}

let mut target_triple = cargo_options.target.clone();
let target = Target::from_target_triple(cargo_options.target.as_ref())?;
let python = target.get_venv_python(venv_dir);
Expand Down Expand Up @@ -429,7 +434,6 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {

let build_context = build_options
.into_build_context()
.release(release)
.strip(strip)
.editable(true)
.build()?;
Expand Down
45 changes: 33 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
strip,
} => {
assert_eq!(build_options.interpreter.len(), 1);
let context = build_options
let mut context = build_options
.into_build_context()
.release(true)
.strip(strip)
.editable(false)
.build()?;

// TBD: does `--profile release` do anything here?
if context.cargo_options.profile.is_none() {
context.cargo_options.profile = Some("release".to_string());
}

let mut writer = PathWriter::from_path(metadata_directory);
write_dist_info(
&mut writer,
Expand All @@ -294,12 +298,14 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
strip,
editable,
} => {
let build_context = build_options
let mut build_context = build_options
.into_build_context()
.release(true)
.strip(strip)
.editable(editable)
.build()?;
if build_context.cargo_options.profile.is_none() {
build_context.cargo_options.profile = Some("release".to_string());
}
let wheels = build_context.build_wheels()?;
assert_eq!(wheels.len(), 1);
println!("{}", wheels[0].0.to_str().unwrap());
Expand All @@ -321,7 +327,6 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
};
let build_context = build_options
.into_build_context()
.release(false)
.strip(false)
.editable(false)
.sdist_only(true)
Expand Down Expand Up @@ -363,14 +368,17 @@ fn run() -> Result<()> {

match opt.command {
Command::Build {
build,
mut build,
release,
strip,
sdist,
} => {
// set profile to release if specified; `--release` and `--profile` are mutually exclusive
if release {
build.profile = Some("release".to_string());
}
let build_context = build
.into_build_context()
.release(release)
.strip(strip)
.editable(false)
.build()?;
Expand All @@ -384,20 +392,34 @@ fn run() -> Result<()> {
}
#[cfg(feature = "upload")]
Command::Publish {
build,
mut build,
mut publish,
debug,
no_strip,
no_sdist,
} => {
let build_context = build
// set profile to dev if specified; `--debug` and `--profile` are mutually exclusive
//
// do it here to take precedence over pyproject.toml profile setting
if debug {
build.profile = Some("dev".to_string());
}

let mut build_context = build
.into_build_context()
.release(!debug)
.strip(!no_strip)
.editable(false)
.build()?;

if !build_context.release {
// ensure profile always set when publishing
// (respect pyproject.toml if set)
// don't need to check `debug` here, set above to take precedence if set
let profile = build_context
.cargo_options
.profile
.get_or_insert_with(|| "release".to_string());

if profile == "dev" {
eprintln!("⚠️ Warning: You're publishing debug wheels");
}

Expand Down Expand Up @@ -462,7 +484,6 @@ fn run() -> Result<()> {
};
let build_context = build_options
.into_build_context()
.release(false)
.strip(false)
.editable(false)
.sdist_only(true)
Expand Down
5 changes: 0 additions & 5 deletions tests/common/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub fn pyo3_no_extension_module() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build()?
Expand Down Expand Up @@ -62,7 +61,6 @@ pub fn locked_doesnt_build_without_cargo_lock() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand Down Expand Up @@ -100,7 +98,6 @@ pub fn invalid_manylinux_does_not_panic() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build()?
Expand Down Expand Up @@ -169,7 +166,6 @@ pub fn pypi_compatibility_unsupported_target() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand Down Expand Up @@ -210,7 +206,6 @@ pub fn pypi_compatibility_mixed_tags() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand Down
2 changes: 0 additions & 2 deletions tests/common/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub fn test_integration(
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build()?;
Expand Down Expand Up @@ -260,7 +259,6 @@ pub fn test_integration_conda(package: impl AsRef<Path>, bindings: Option<String

let build_context = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build()?;
Expand Down
9 changes: 0 additions & 9 deletions tests/common/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub fn test_musl() -> Result<bool> {

let build_context = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build()?;
Expand Down Expand Up @@ -114,7 +113,6 @@ pub fn test_workspace_cargo_lock() -> Result<()> {

let build_context = options
.into_build_context()
.release(false)
.strip(false)
.editable(false)
.build()?;
Expand Down Expand Up @@ -149,7 +147,6 @@ pub fn test_source_distribution(

let mut build_context = build_options
.into_build_context()
.release(false)
.strip(false)
.editable(false)
.sdist_only(true)
Expand Down Expand Up @@ -225,7 +222,6 @@ fn build_wheel_files(package: impl AsRef<Path>, unique_name: &str) -> Result<Zip

let build_context = build_options
.into_build_context()
.release(false)
.strip(false)
.editable(false)
.build()?;
Expand Down Expand Up @@ -286,7 +282,6 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand All @@ -303,7 +298,6 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand All @@ -324,7 +318,6 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand All @@ -341,7 +334,6 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand All @@ -367,7 +359,6 @@ pub fn abi3_without_version() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.release(false)
.strip(cfg!(feature = "faster-tests"))
.editable(false)
.build();
Expand Down
Loading