Skip to content

Commit

Permalink
refactor: rename [build] to [build-system] (#2513)
Browse files Browse the repository at this point in the history
We decided to rename `[build]` to `[build-system]`. This change takes
care of that.

I also took the liberty to remove most `alias`es from `model.py` and use
an `alias_generator` instead. Less code is better!

---------

Co-authored-by: Tim de Jager <[email protected]>
  • Loading branch information
baszalmstra and tdejager authored Nov 21, 2024
1 parent f220c3a commit 34115e9
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 76 deletions.
2 changes: 1 addition & 1 deletion crates/pixi_build_frontend/src/protocols/pixi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Display for FinishError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
FinishError::Init(init) => write!(f, "{init}"),
FinishError::NoBuildSection(_) => write!(f, "failed to setup a build backend, the project manifest does not contain a [build] section"),
FinishError::NoBuildSection(_) => write!(f, "failed to setup a build backend, the project manifest does not contain a [build-system] section"),
FinishError::Tool(ToolCacheError::Instantiate(tool, err)) => match err {
Error::CannotGetCurrentDirAndPathListEmpty|Error::CannotFindBinaryPath => write!(f, "failed to setup a build backend, the backend tool '{}' could not be found", tool.display()),
Error::CannotCanonicalize => write!(f, "failed to setup a build backend, although the backend tool '{}' can be resolved it could not be canonicalized", tool.display()),
Expand Down
4 changes: 3 additions & 1 deletion crates/pixi_build_frontend/src/protocols/pixi/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ use crate::{
#[derive(Debug, Error, Diagnostic)]
pub enum InitializeError {
#[error("failed to setup communication with the build backend, an unexpected io error occurred while communicating with the pixi build backend")]
#[diagnostic(help("Ensure that the project manifest contains a valid [build] section."))]
#[diagnostic(help(
"Ensure that the project manifest contains a valid [build-system] section."
))]
Io(#[from] std::io::Error),
#[error(transparent)]
#[diagnostic(transparent)]
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_build_frontend/src/tool/spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use miette::IntoDiagnostic;
use pixi_consts::consts::CACHED_BUILD_ENVS_DIR;
use pixi_manifest::BuildSection;
use pixi_manifest::BuildSystem;
use pixi_utils::EnvironmentHash;
use rattler::{install::Installer, package_cache::PackageCache};
use rattler_conda_types::{GenericVirtualPackage, MatchSpec, Platform};
Expand Down Expand Up @@ -44,7 +44,7 @@ impl IsolatedToolSpec {
}

/// Construct a new instance from a build section
pub fn from_build_section(build_section: &BuildSection) -> Self {
pub fn from_build_section(build_section: &BuildSystem) -> Self {
Self {
specs: build_section.dependencies.clone(),
command: build_section.build_backend.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_build_frontend/tests/basic/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.0"

[tasks]

[build]
[build-system]
build-backend = "pixi-build-python"
dependencies = []

Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_build_frontend/tests/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn test_missing_backend() {
platforms = []
channels = []
[build]
[build-system]
dependencies = []
build-backend = "non-existing"
channels = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde_with::DisplayFromStr;
#[serde_as]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct BuildSection {
pub struct BuildSystem {
/// The dependencies for the build tools which will be installed in the build environment.
/// These need to be conda packages
#[serde_as(as = "Vec<DisplayFromStr>")]
Expand All @@ -27,7 +27,7 @@ pub struct BuildSection {
pub channels: Vec<NamedChannelOrUrl>,
}

impl BuildSection {
impl BuildSystem {
/// Returns the channels as URLs
pub fn channels_url(
&self,
Expand Down Expand Up @@ -60,7 +60,7 @@ mod tests {
build-backend = "pixi-build-python"
"#;

let build: BuildSection = toml_edit::de::from_str(toml).unwrap();
let build: BuildSystem = toml_edit::de::from_str(toml).unwrap();
assert_eq!(build.dependencies.len(), 1);
assert_eq!(
build.dependencies[0].to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_manifest/src/has_environment_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait HasEnvironmentDependencies<'source>:
/// should be used.
fn should_combine_dependencies(&self) -> bool {
// If the manifest has a build section defined we should not combine.
if self.manifest().workspace.build.is_some() {
if self.manifest().workspace.build_system.is_some() {
return false;
}
true
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_manifest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod activation;
mod build;
mod build_system;
pub(crate) mod channel;
mod dependencies;
mod environment;
Expand All @@ -24,7 +24,7 @@ mod validation;
mod workspace;

pub use activation::Activation;
pub use build::BuildSection;
pub use build_system::BuildSystem;
pub use channel::{PrioritizedChannel, TomlPrioritizedChannelStrOrMap};
pub use dependencies::{CondaDependencies, Dependencies, PyPiDependencies};
pub use environment::{Environment, EnvironmentName};
Expand Down
6 changes: 3 additions & 3 deletions crates/pixi_manifest/src/manifests/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
preview::Preview,
pypi::PyPiPackageName,
pyproject::PyProjectManifest,
to_options, BuildSection, DependencyOverwriteBehavior, Environment, EnvironmentName, Feature,
to_options, BuildSystem, DependencyOverwriteBehavior, Environment, EnvironmentName, Feature,
FeatureName, GetFeatureError, PrioritizedChannel, PypiDependencyLocation, SpecType, Target,
TargetSelector, Task, TaskName, WorkspaceManifest,
};
Expand Down Expand Up @@ -738,8 +738,8 @@ impl Manifest {
}

/// Return the build section from the parsed manifest
pub fn build_section(&self) -> Option<&BuildSection> {
self.workspace.build.as_ref()
pub fn build_section(&self) -> Option<&BuildSystem> {
self.workspace.build_system.as_ref()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TOML parse error at line 8, column 2
|
8 | [foobar]
| ^^^^^^
unknown field `foobar`, expected one of `project`, `workspace`, `system-requirements`, `target`, `dependencies`, `host-dependencies`, `build-dependencies`, `pypi-dependencies`, `activation`, `tasks`, `feature`, `environments`, `pypi-options`, `tool`, `build`, `$schema`
unknown field `foobar`, expected one of `project`, `workspace`, `system-requirements`, `target`, `dependencies`, `host-dependencies`, `build-dependencies`, `pypi-dependencies`, `activation`, `tasks`, `feature`, `environments`, `pypi-options`, `tool`, `build-system`, `$schema`

TOML parse error at line 8, column 16
|
Expand Down
16 changes: 8 additions & 8 deletions crates/pixi_manifest/src/manifests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
task::{Task, TaskName},
utils::PixiSpanned,
workspace::Workspace,
BuildSection,
BuildSystem,
};

/// Holds the parsed content of the workspace part of a pixi manifest. This
Expand All @@ -45,7 +45,7 @@ pub struct WorkspaceManifest {
pub solve_groups: SolveGroups,

/// The build section of the project.
pub build: Option<BuildSection>,
pub build_system: Option<BuildSystem>,
}

impl WorkspaceManifest {
Expand Down Expand Up @@ -175,7 +175,7 @@ impl<'de> Deserialize<'de> for WorkspaceManifest {

/// The build section
#[serde(default)]
build: Option<BuildSection>,
build_system: Option<BuildSystem>,

/// The URI for the manifest schema which is unused by pixi
#[allow(dead_code)]
Expand Down Expand Up @@ -272,14 +272,14 @@ impl<'de> Deserialize<'de> for WorkspaceManifest {
}));
}

let build = toml_manifest.build;
let build = toml_manifest.build_system;

Ok(Self {
workspace: toml_manifest.workspace,
features,
environments,
solve_groups,
build,
build_system: build,
})
}
}
Expand Down Expand Up @@ -695,15 +695,15 @@ mod tests {
channels = []
platforms = []
[build]
[build-system]
dependencies = ["python-build-backend > 12"]
build-backend = "python-build-backend"
channels = []
"#
.to_string();
let manifest = toml_edit::de::from_str::<WorkspaceManifest>(&contents)
.expect("parsing should succeed!");
assert_yaml_snapshot!(manifest.build.clone().unwrap());
assert_yaml_snapshot!(manifest.build_system.clone().unwrap());
}

#[test]
Expand All @@ -714,7 +714,7 @@ mod tests {
channels = []
platforms = []
[build]
[build-system]
dependencies = ["python-build-backend > > 12"]
build-backend = "python-build-backend"
channels = []
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_manifest/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl WorkspaceManifest {
}

// If there is a build section, make sure the build-string is not empty
if let Some(build) = &self.build {
if let Some(build) = &self.build_system {
if build.build_backend.is_empty() {
return Err(miette::miette!(
help = "the build-backend must contain at least one command. e.g `pixi-build-python`",
Expand Down
8 changes: 4 additions & 4 deletions examples/cpp-sdl/pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/cpp-sdl/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Showcases how to create a simple C++ executable with Pixi"
name = "sdl_example"
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]

[build]
[build-system]
build-backend = "pixi-build-cmake"
channels = [
"https://prefix.dev/pixi-build-backends",
Expand Down
2 changes: 1 addition & 1 deletion examples/flask-hello-world-pyproject/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test = ["pytest>=8.3.3,<9"]
hatchling = "*"


[tool.pixi.build]
[tool.pixi.build-system]
build-backend = "pixi-build-python"
channels = [
"https://repo.prefix.dev/pixi-build-backends",
Expand Down
2 changes: 1 addition & 1 deletion examples/flask-hello-world/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ start = "python -m flask run --port=5050"
[dependencies]
flask = "2.*"

[build]
[build-system]
build-backend = "pixi-build-python"
channels = [
"https://fast.prefix.dev/pixi-build-backends",
Expand Down
2 changes: 1 addition & 1 deletion schema/examples/valid/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ readme = "README.md"
repository = "https://github.com/author/project"
version = "0.1.0"

[build]
[build-system]
build-backend = "pixi-build-python"
channels = [
"https://prefix.dev/pixi-build-backends",
Expand Down
Loading

0 comments on commit 34115e9

Please sign in to comment.