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
6 changes: 0 additions & 6 deletions crates/rattler_build_core/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ pub async fn run_build(

match output.run_build_script().await {
Ok(_) => {}
Err(InterpreterError::Debug(info)) => {
tracing::info!("{}", info);
return Err(miette::miette!(
"Script not executed because debug mode is enabled"
));
}
Err(InterpreterError::ExecutionFailed(_)) => {
return Err(miette::miette!("Script failed to execute"));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_build_core/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! All the metadata that makes up a recipe file
pub use crate::types::{
BuildConfiguration, Debug, Output, PlatformWithVirtualPackages, build_reindexed_channels,
BuildConfiguration, Output, PlatformWithVirtualPackages, build_reindexed_channels,
};

#[cfg(test)]
Expand Down
19 changes: 3 additions & 16 deletions crates/rattler_build_core/src/package_test/run_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rattler_build_recipe::stage1::{
TestType,
tests::{CommandsTest, DownstreamTest, PerlTest, PythonTest, PythonVersion, RTest, RubyTest},
};
use rattler_build_script::{Debug as ScriptDebug, Script, ScriptContent};
use rattler_build_script::{Script, ScriptContent};
use rattler_conda_types::{
Channel, ChannelUrl, MatchSpec, ParseStrictness, Platform,
compression_level::CompressionLevel,
Expand All @@ -38,11 +38,8 @@ use rattler::package_cache::PackageCache;
use rattler_cache::validation::ValidationMode;

use crate::{
env_vars,
metadata::{Debug, PlatformWithVirtualPackages},
render::solver::create_environment,
source::copy_dir::CopyDir,
tool_configuration,
env_vars, metadata::PlatformWithVirtualPackages, render::solver::create_environment,
source::copy_dir::CopyDir, tool_configuration,
};

#[allow(missing_docs)]
Expand Down Expand Up @@ -201,7 +198,6 @@ impl Tests {
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(false),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand All @@ -222,7 +218,6 @@ impl Tests {
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(false),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down Expand Up @@ -291,8 +286,6 @@ pub struct TestConfiguration {
pub tool_configuration: tool_configuration::Configuration,
/// The output directory to create the test prefixes in (will be `output_dir/test`)
pub output_dir: PathBuf,
/// Debug mode yes, or no
pub debug: Debug,
/// Exclude packages newer than this date from the solver
pub exclude_newer: Option<chrono::DateTime<chrono::Utc>>,
}
Expand Down Expand Up @@ -751,7 +744,6 @@ async fn run_python_test_inner(
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand All @@ -775,7 +767,6 @@ async fn run_python_test_inner(
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down Expand Up @@ -858,7 +849,6 @@ async fn run_perl_test(
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down Expand Up @@ -977,7 +967,6 @@ async fn run_commands_test(
build_prefix.as_ref(),
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down Expand Up @@ -1162,7 +1151,6 @@ async fn run_r_test(
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down Expand Up @@ -1240,7 +1228,6 @@ async fn run_ruby_test(
None,
None::<fn(&str) -> Result<String, String>>,
None,
ScriptDebug::new(config.debug.is_enabled()),
)
.await
.map_err(|e| TestError::TestFailed(e.to_string()))?;
Expand Down
6 changes: 2 additions & 4 deletions crates/rattler_build_core/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::{collections::HashMap, collections::HashSet};

// Re-export from rattler_build_script
pub use rattler_build_script::{
Debug as ScriptDebug, ExecutionArgs, InterpreterError, ResolvedScriptContents,
SandboxArguments, SandboxConfiguration, Script, ScriptContent,
ExecutionArgs, InterpreterError, ResolvedScriptContents, SandboxArguments,
SandboxConfiguration, Script, ScriptContent,
};

use crate::{
Expand Down Expand Up @@ -78,7 +78,6 @@ impl Output {
execution_platform: Platform::current(),
work_dir: work_dir.clone(),
sandbox_config: self.build_configuration.sandbox_config().cloned(),
debug: ScriptDebug::new(self.build_configuration.debug.is_enabled()),
})
}

Expand Down Expand Up @@ -135,7 +134,6 @@ impl Output {
build_prefix,
Some(jinja_renderer),
self.build_configuration.sandbox_config(),
ScriptDebug::new(self.build_configuration.debug.is_enabled()),
)
.await?;

Expand Down
2 changes: 0 additions & 2 deletions crates/rattler_build_core/src/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use miette::{Context, IntoDiagnostic};
use minijinja::Value;
use rattler_build_jinja::{Jinja, Variable};
use rattler_build_recipe::stage1::{InheritsFrom, StagingCache};
use rattler_build_script::Debug as ScriptDebug;
use rattler_build_types::NormalizedKey;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -298,7 +297,6 @@ impl Output {
build_prefix,
Some(jinja_renderer),
self.build_configuration.sandbox_config(),
ScriptDebug::new(self.build_configuration.debug.is_enabled()),
)
.await
.into_diagnostic()?;
Expand Down
5 changes: 1 addition & 4 deletions crates/rattler_build_core/src/types/build_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rattler_solve::{ChannelPriority, SolveStrategy};
use serde::{Deserialize, Serialize};

use crate::types::{
Debug, Directories, PackageIdentifier, PackagingSettings, PlatformWithVirtualPackages,
Directories, PackageIdentifier, PackagingSettings, PlatformWithVirtualPackages,
};

use rattler_build_script::SandboxConfiguration;
Expand Down Expand Up @@ -59,9 +59,6 @@ pub struct BuildConfiguration {
/// The configuration for the sandbox
#[serde(skip_serializing, default)]
pub sandbox_config: Option<SandboxConfiguration>,
/// Whether to enable debug output in build scripts
#[serde(skip_serializing, default)]
pub debug: Debug,
/// Exclude packages newer than this date from the solver
#[serde(skip_serializing, default)]
pub exclude_newer: Option<chrono::DateTime<chrono::Utc>>,
Expand Down
16 changes: 0 additions & 16 deletions crates/rattler_build_core/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,6 @@ impl<'de> Deserialize<'de> for PlatformWithVirtualPackages {
}
}

/// A newtype wrapper around a boolean indicating whether debug output is enabled
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Debug(bool);

impl Debug {
/// Create a new Debug instance
pub fn new(debug: bool) -> Self {
Self(debug)
}

/// Returns true if debug output is enabled
pub fn is_enabled(&self) -> bool {
self.0
}
}

/// A package identifier
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PackageIdentifier {
Expand Down
27 changes: 0 additions & 27 deletions crates/rattler_build_script/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ pub struct ExecutionArgs {

/// The sandbox configuration to use for the script execution
pub sandbox_config: Option<SandboxConfiguration>,

/// Whether to enable debug output
pub debug: Debug,
}

impl ExecutionArgs {
Expand Down Expand Up @@ -116,28 +113,6 @@ impl ResolvedScriptContents {
}
}

/// Debug mode for script execution
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Debug(bool);

impl Debug {
/// Create a new Debug mode
pub fn new(enabled: bool) -> Self {
Self(enabled)
}

/// Check if debug mode is enabled
pub fn is_enabled(&self) -> bool {
self.0
}
}

impl From<bool> for Debug {
fn from(enabled: bool) -> Self {
Self(enabled)
}
}

impl Script {
/// Run the script with the given parameters
///
Expand All @@ -157,7 +132,6 @@ impl Script {
build_prefix: Option<&PathBuf>,
jinja_renderer: Option<F>,
sandbox_config: Option<&SandboxConfiguration>,
debug: Debug,
) -> Result<(), crate::InterpreterError>
where
F: Fn(&str) -> Result<String, String>,
Expand Down Expand Up @@ -226,7 +200,6 @@ impl Script {
execution_platform: Platform::current(),
work_dir,
sandbox_config: sandbox_config.cloned(),
debug,
};

crate::execution::run_script(exec_args, interpreter).await?;
Expand Down
16 changes: 2 additions & 14 deletions crates/rattler_build_script/src/interpreter/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ pub struct BashInterpreter;
fn print_debug_info(args: &ExecutionArgs) -> String {
let mut output = String::new();

if args.debug.is_enabled() {
output.push_str("\nDebug mode enabled - not executing the script.\n\n");
} else {
output.push_str("\nScript execution failed.\n\n");
}
output.push_str("\nScript execution failed.\n\n");

output.push_str(&format!(" Work directory: {}\n", args.work_dir.display()));
output.push_str(&format!(" Prefix: {}\n", args.run_prefix.display()));
Expand Down Expand Up @@ -57,15 +53,7 @@ impl Interpreter for BashInterpreter {
}

let build_script_path_str = build_script_path.to_string_lossy().to_string();
let mut cmd_args = vec!["bash"];
if args.debug.is_enabled() {
cmd_args.push("-x");
}
cmd_args.push(&build_script_path_str);

if args.debug.is_enabled() {
return Err(InterpreterError::Debug(print_debug_info(&args)));
}
let cmd_args = vec!["bash", &build_script_path_str];

let output = run_process_with_replacements(
&cmd_args,
Expand Down
11 changes: 2 additions & 9 deletions crates/rattler_build_script/src/interpreter/cmd_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ use super::{CMDEXE_PREAMBLE, Interpreter, InterpreterError, find_interpreter};

fn print_debug_info(args: &ExecutionArgs) -> String {
let mut output = String::new();
if args.debug.is_enabled() {
output.push_str("\nDebug mode enabled - not executing the script.\n\n");
} else {
output.push_str("\nScript execution failed.\n\n")
}

output.push_str("\nScript execution failed.\n\n");

output.push_str(&format!(" Work directory: {}\n", args.work_dir.display()));
output.push_str(&format!(" Prefix: {}\n", args.run_prefix.display()));
Expand Down Expand Up @@ -60,10 +57,6 @@ impl Interpreter for CmdExeInterpreter {
let build_script_path_str = build_script_path.to_string_lossy().to_string();
let cmd_args = ["cmd.exe", "/d", "/c", &build_script_path_str];

if args.debug.is_enabled() {
return Err(InterpreterError::Debug(print_debug_info(&args)));
}

let output = run_process_with_replacements(
&cmd_args,
&args.work_dir,
Expand Down
4 changes: 0 additions & 4 deletions crates/rattler_build_script/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ use crate::execution::ExecutionArgs;
/// The error type for the interpreter
#[derive(Debug, thiserror::Error)]
pub enum InterpreterError {
/// This error is returned when running in debug mode
#[error("Debugging information: {0}")]
Debug(String),

/// This error is returned when the script execution fails or the
/// interpreter is not found
#[error("IO Error: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/rattler_build_script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ mod interpreter;

#[cfg(feature = "execution")]
pub use execution::{
Debug, ExecutionArgs, ResolvedScriptContents, create_build_script,
run_process_with_replacements, run_script,
ExecutionArgs, ResolvedScriptContents, create_build_script, run_process_with_replacements,
run_script,
};
#[cfg(feature = "execution")]
pub use interpreter::InterpreterError;
2 changes: 0 additions & 2 deletions docs/reference/cli/rattler-build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ e.g. `tar-bz2:<number>` (from 1 to 9) or `conda:<number>` (from -7 to
<br>**options**: `none`, `local`, `all`
- <a id="arg---noarch-build-platform" href="#arg---noarch-build-platform">`--noarch-build-platform <NOARCH_BUILD_PLATFORM>`</a>
: Define a "noarch platform" for which the noarch packages will be built for. The noarch builds will be skipped on the other platforms
- <a id="arg---debug" href="#arg---debug">`--debug`</a>
: Enable debug output in build scripts
- <a id="arg---markdown-summary" href="#arg---markdown-summary">`--markdown-summary <MARKDOWN_SUMMARY>`</a>
: Write a markdown summary to the specified file (appends to the file). Useful for generating PR comments or custom reports
- <a id="arg---error-prefix-in-binary" href="#arg---error-prefix-in-binary">`--error-prefix-in-binary`</a>
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/cli/rattler-build/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ e.g. `tar-bz2:<number>` (from 1 to 9) or `conda:<number>` (from -7 to
<br>**options**: `none`, `local`, `all`
- <a id="arg---noarch-build-platform" href="#arg---noarch-build-platform">`--noarch-build-platform <NOARCH_BUILD_PLATFORM>`</a>
: Define a "noarch platform" for which the noarch packages will be built for. The noarch builds will be skipped on the other platforms
- <a id="arg---debug" href="#arg---debug">`--debug`</a>
: Enable debug output in build scripts
- <a id="arg---markdown-summary" href="#arg---markdown-summary">`--markdown-summary <MARKDOWN_SUMMARY>`</a>
: Write a markdown summary to the specified file (appends to the file). Useful for generating PR comments or custom reports
- <a id="arg---error-prefix-in-binary" href="#arg---error-prefix-in-binary">`--error-prefix-in-binary`</a>
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/cli/rattler-build/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ rattler-build test [OPTIONS] --package-file <PACKAGE_FILE>
<br>**env**: `RATTLER_COMPRESSION_THREADS`
- <a id="arg---test-index" href="#arg---test-index">`--test-index <TEST_INDEX>`</a>
: The index of the test to run. This is used to run a specific test from the package
- <a id="arg---debug" href="#arg---debug">`--debug`</a>
: Build test environment and output debug information for manual debugging
- <a id="arg---experimental" href="#arg---experimental">`--experimental`</a>
: Enable experimental features
<br>**env**: `RATTLER_BUILD_EXPERIMENTAL`
Expand Down
2 changes: 0 additions & 2 deletions py-rattler-build/rust/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ pub fn build_rendered_variant_py(
no_build_id: bool,
package_format: Option<String>,
no_include_recipe: bool,
debug: bool,
exclude_newer: Option<chrono::DateTime<chrono::Utc>>,
) -> PyResult<BuildResultPy> {
let tool_config = tool_config.inner;
Expand Down Expand Up @@ -218,7 +217,6 @@ pub fn build_rendered_variant_py(
store_recipe: !effective_no_include_recipe,
force_colors: false, // Set to false for Python API
sandbox_config: None,
debug: ::rattler_build::metadata::Debug::new(debug),
exclude_newer,
},
finalized_dependencies: None,
Expand Down
Loading
Loading