Skip to content

Commit

Permalink
chore: update package keys (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra authored Jan 7, 2025
1 parent 64e70ae commit 63efd36
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ output/

# Output directory
pixi-build-python-output/
**/repodata.json
48 changes: 36 additions & 12 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ serde = "1.0"
serde_yaml = "0.9"
serde_json = "1.0"
tempfile = "3.10.1"
toml_edit = "0.22.22"
tokio = "1.37.0"
tracing-subscriber = "0.3.19"
url = "2.5.4"
Expand All @@ -37,10 +38,10 @@ rattler_conda_types = { version = "0.29.1", default-features = false }
rattler_package_streaming = { version = "0.22.14", default-features = false }
rattler_virtual_packages = { version = "1.1.10", default-features = false }

pixi_build_types = { git = "https://github.com/tdejager/pixi", branch = "feat/split-initalize-and-capabilities" }
pixi_consts = { git = "https://github.com/tdejager/pixi", branch = "feat/split-initalize-and-capabilities" }
pixi_manifest = { git = "https://github.com/tdejager/pixi", branch = "feat/split-initalize-and-capabilities" }
pixi_spec = { git = "https://github.com/tdejager/pixi", branch = "feat/split-initalize-and-capabilities" }
pixi_build_types = { git = "https://github.com/baszalmstra/pixi", branch = "refactor/package_everything" }
pixi_consts = { git = "https://github.com/baszalmstra/pixi", branch = "refactor/package_everything" }
pixi_manifest = { git = "https://github.com/baszalmstra/pixi", branch = "refactor/package_everything" }
pixi_spec = { git = "https://github.com/baszalmstra/pixi", branch = "refactor/package_everything" }

[patch.crates-io]
rattler = { git = "https://github.com/conda/rattler", branch = "main" }
Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ reqwest-middleware = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_yaml = { workspace = true }
serde_json = { workspace = true }
toml_edit = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["macros"] }
tracing-subscriber = { workspace = true }
Expand Down
38 changes: 18 additions & 20 deletions crates/pixi-build/src/bin/pixi-build-cmake/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{

use chrono::Utc;
use itertools::Itertools;
use jsonrpc_core::serde_json;
use miette::{Context, IntoDiagnostic};
use pixi_build_backend::{
dependencies::extract_dependencies,
Expand Down Expand Up @@ -76,7 +75,7 @@ impl CMakeBuildBackend {
/// at the given path.
pub fn new(
manifest_path: &Path,
config: CMakeBackendConfig,
config: Option<CMakeBackendConfig>,
logging_output_handler: LoggingOutputHandler,
cache_dir: Option<PathBuf>,
) -> miette::Result<Self> {
Expand All @@ -85,6 +84,13 @@ impl CMakeBuildBackend {
format!("failed to parse manifest from {}", manifest_path.display())
})?;

// Read config from the manifest itself if its not provided
// TODO: I guess this should also be passed over the protocol.
let config = match config {
Some(config) => config,
None => CMakeBackendConfig::from_path(manifest_path)?,
};

Ok(Self {
manifest,
_config: config,
Expand Down Expand Up @@ -584,17 +590,9 @@ impl ProtocolFactory for CMakeBuildBackendFactory {
&self,
params: InitializeParams,
) -> miette::Result<(Self::Protocol, InitializeResult)> {
let config = if params.configuration.is_null() {
CMakeBackendConfig::default()
} else {
serde_json::from_value(params.configuration)
.into_diagnostic()
.context("failed to parse backend configuration")?
};

let instance = CMakeBuildBackend::new(
params.manifest_path.as_path(),
config,
None,
self.logging_output_handler.clone(),
params.cache_directory,
)?;
Expand Down Expand Up @@ -636,17 +634,17 @@ mod tests {
name = "test-reqs"
version = "1.0"
[host-dependencies]
[package.host-dependencies]
hatchling = "*"
[build-dependencies]
[package.build-dependencies]
boltons = "*"
[run-dependencies]
[package.run-dependencies]
foobar = "3.2.1"
[build-system]
build-backend = { name = "pixi-build-python", version = "*" }
[package.build]
backend = { name = "pixi-build-python", version = "*" }
"#;

let tmp_dir = tempdir().unwrap();
Expand All @@ -659,7 +657,7 @@ mod tests {

let cmake_backend = CMakeBuildBackend::new(
&manifest.path,
CMakeBackendConfig::default(),
Some(CMakeBackendConfig::default()),
LoggingOutputHandler::default(),
None,
)
Expand Down Expand Up @@ -696,10 +694,10 @@ mod tests {
name = "test-reqs"
version = "1.0"
[build-system]
build-backend = { name = "pixi-build-python", version = "*" }
[package.build]
backend = { name = "pixi-build-python", version = "*" }
[host-dependencies]
[package.host-dependencies]
hatchling = { git = "git+https://github.com/hatchling/hatchling.git", subdirectory = "src" }
"#;

Expand Down
25 changes: 25 additions & 0 deletions crates/pixi-build/src/bin/pixi-build-cmake/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
use miette::IntoDiagnostic;
use serde::Deserialize;
use std::path::Path;

#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct CMakeBackendConfig {}

impl CMakeBackendConfig {
/// Parse the configuration from a manifest file.
pub fn from_path(path: &Path) -> miette::Result<Self> {
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Manifest {
#[serde(default)]
tool: Tool,
}

#[derive(Default, Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Tool {
#[serde(default)]
pixi_build_python: CMakeBackendConfig,
}

let manifest = fs_err::read_to_string(path).into_diagnostic()?;
let document: Manifest = toml_edit::de::from_str(&manifest).into_diagnostic()?;
Ok(document.tool.pixi_build_python)
}
}
26 changes: 24 additions & 2 deletions crates/pixi-build/src/bin/pixi-build-python/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::identity;

use miette::IntoDiagnostic;
use serde::Deserialize;
use std::convert::identity;
use std::path::Path;

#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "kebab-case")]
Expand All @@ -16,4 +17,25 @@ impl PythonBackendConfig {
pub fn noarch(&self) -> bool {
self.noarch.map_or(true, identity)
}

/// Parse the configuration from a manifest file.
pub fn from_path(path: &Path) -> miette::Result<Self> {
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Manifest {
#[serde(default)]
tool: Tool,
}

#[derive(Default, Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Tool {
#[serde(default)]
pixi_build_python: PythonBackendConfig,
}

let manifest = fs_err::read_to_string(path).into_diagnostic()?;
let document: Manifest = toml_edit::de::from_str(&manifest).into_diagnostic()?;
Ok(document.tool.pixi_build_python)
}
}
Loading

0 comments on commit 63efd36

Please sign in to comment.