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

feat: move package fields under [package]. #2731

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
31 changes: 29 additions & 2 deletions Cargo.lock

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

12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ csv = "1.3.0"
dashmap = "6.1.0"
deno_task_shell = "0.16.0"
dialoguer = "0.11.0"
digest = "0.10"
dirs = "5.0.1"
dunce = "1.0.4"
fd-lock = "4.0.2"
flate2 = "1.0.28"
fs-err = { version = "2.11.0" }
fs_extra = "1.3.0"
futures = "0.3.30"
hex = "0.4.3"
http = "1.1.0"
http-cache-reqwest = "0.15.0"
human_bytes = "0.4.3"
Expand Down Expand Up @@ -82,13 +84,15 @@ shlex = "1.3.0"
signal-hook = "0.3.17"
spdx = "0.10.4"
strsim = "0.11.1"
strum = "0.26.3"
tabwriter = "1.4.0"
tar = "0.4.40"
tempfile = "3.14.0"
thiserror = "1.0.58"
tokio = "1.37.0"
tokio-stream = "0.1.16"
tokio-util = "0.7.10"
toml-span = { git = "https://github.com/baszalmstra/toml-span", branch = "add_table_spans" }
toml_edit = "0.22.11"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand Down Expand Up @@ -151,6 +155,7 @@ pixi_manifest = { path = "crates/pixi_manifest" }
pixi_progress = { path = "crates/pixi_progress" }
pixi_record = { path = "crates/pixi_record" }
pixi_spec = { path = "crates/pixi_spec" }
pixi_toml = { path = "crates/pixi_toml" }
pixi_utils = { path = "crates/pixi_utils", default-features = false }
pixi_uv_conversions = { path = "crates/pixi_uv_conversions" }
pypi_mapping = { path = "crates/pypi_mapping" }
Expand Down Expand Up @@ -265,10 +270,14 @@ pixi_config = { workspace = true }
pixi_consts = { workspace = true }
pixi_default_versions = { workspace = true }
pixi_glob = { workspace = true }
pixi_manifest = { workspace = true, features = ["rattler_lock"] }
pixi_manifest = { workspace = true, features = [
"rattler_lock",
"rattler_solve",
] }
pixi_progress = { workspace = true }
pixi_record = { workspace = true }
pixi_spec = { workspace = true }
pixi_toml = { workspace = true }
pixi_utils = { workspace = true, default-features = false }
pixi_uv_conversions = { workspace = true }
pypi_mapping = { workspace = true }
Expand All @@ -293,6 +302,7 @@ tempfile = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal"] }
tokio-util = { workspace = true }
toml-span = { workspace = true }
toml_edit = { workspace = true, features = ["serde"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
31 changes: 4 additions & 27 deletions crates/pixi_build_frontend/src/protocols/builders/pixi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use miette::Diagnostic;
use pixi_consts::consts;
use pixi_manifest::{Manifest, PackageManifest, PrioritizedChannel, WorkspaceManifest};
use rattler_conda_types::{ChannelConfig, MatchSpec};
use serde::{de::IntoDeserializer, Deserialize};
use thiserror::Error;
use which::Error;

Expand Down Expand Up @@ -160,10 +159,10 @@ impl ProtocolBuilder {
let tool_spec = if let Some(backend_spec) = self.override_backend_spec {
backend_spec
} else {
let build_system = &self.package_manifest.build_system;
let build_system = &self.package_manifest.build;
let specs = [(
&build_system.build_backend.name,
&build_system.build_backend.spec,
&build_system.backend.name,
&build_system.backend.spec,
)]
.into_iter()
.chain(build_system.additional_dependencies.iter())
Expand All @@ -186,7 +185,7 @@ impl ProtocolBuilder {

ToolSpec::Isolated(IsolatedToolSpec {
specs,
command: build_system.build_backend.name.as_source().to_string(),
command: build_system.backend.name.as_source().to_string(),
channels,
})
};
Expand All @@ -196,20 +195,9 @@ impl ProtocolBuilder {
.await
.map_err(FinishError::Tool)?;

let configuration = self
.package_manifest
.build_system
.build_backend
.additional_args
.map_or(serde_json::Value::Null, |value| {
let deserializer = value.into_deserializer();
serde_json::Value::deserialize(deserializer).unwrap_or(serde_json::Value::Null)
});

Ok(JsonRPCBuildProtocol::setup(
self.source_dir,
self.manifest_path,
configuration,
build_id,
self.cache_dir,
tool,
Expand All @@ -224,21 +212,10 @@ impl ProtocolBuilder {
ipc: InProcessBackend,
build_id: usize,
) -> Result<JsonRPCBuildProtocol, FinishError> {
let configuration = self
.package_manifest
.build_system
.build_backend
.additional_args
.map_or(serde_json::Value::Null, |value| {
let deserializer = value.into_deserializer();
serde_json::Value::deserialize(deserializer).unwrap_or(serde_json::Value::Null)
});

Ok(JsonRPCBuildProtocol::setup_with_transport(
"<IPC>".to_string(),
self.source_dir,
self.manifest_path,
configuration,
build_id,
self.cache_dir,
Sender::from(ipc.rpc_out),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ impl ProtocolBuilder {
Ok(JsonRPCBuildProtocol::setup(
self.source_dir,
self.recipe_dir.join("recipe.yaml"),
serde_json::Value::Null,
build_id,
self.cache_dir,
tool,
Expand Down
4 changes: 0 additions & 4 deletions crates/pixi_build_frontend/src/protocols/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl JsonRPCBuildProtocol {
async fn setup(
source_dir: PathBuf,
manifest_path: PathBuf,
configuration: serde_json::Value,
build_id: usize,
cache_dir: Option<PathBuf>,
tool: Tool,
Expand Down Expand Up @@ -178,7 +177,6 @@ impl JsonRPCBuildProtocol {
backend_identifier,
source_dir,
manifest_path,
configuration,
build_id,
cache_dir,
tx,
Expand All @@ -195,7 +193,6 @@ impl JsonRPCBuildProtocol {
source_dir: PathBuf,
// In case of rattler-build it's recipe.yaml
manifest_path: PathBuf,
configuration: serde_json::Value,
build_id: usize,
cache_dir: Option<PathBuf>,
sender: impl TransportSenderT + Send,
Expand All @@ -215,7 +212,6 @@ impl JsonRPCBuildProtocol {
manifest_path: manifest_path.clone(),
capabilities: FrontendCapabilities {},
cache_directory: cache_dir,
configuration,
}),
)
.await
Expand Down
71 changes: 2 additions & 69 deletions crates/pixi_build_frontend/tests/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ use std::path::Path;

use bytes::Bytes;
use futures::{SinkExt, StreamExt};
use jsonrpsee::types::Request;
use miette::{Diagnostic, GraphicalReportHandler, GraphicalTheme};
use pixi_build_frontend::{BuildFrontend, InProcessBackend, SetupRequest};
use pixi_build_types::procedures::initialize::InitializeParams;
use pixi_manifest::toml::{ExternalWorkspaceProperties, TomlManifest};
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncWrite, BufReader};
use pixi_manifest::toml::{ExternalWorkspaceProperties, FromTomlStr, TomlManifest};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio_stream::wrappers::ReceiverStream;
use tokio_util::{
io::{CopyToBytes, SinkWriter, StreamReader},
Expand Down Expand Up @@ -171,71 +169,6 @@ async fn test_invalid_backend() {
insta::assert_snapshot!(snapshot);
}

#[tokio::test]
async fn test_backend_configuration() {
let toml = r#"
[workspace]
platforms = []
channels = []
preview = ['pixi-build']

[package]
version = "0.1.0"
name = "project"

[build-system]
build-backend = { name = "ipc", version = "*" }

[build-backend.ipc]
hello = "world"
"#;

let source_dir = tempfile::TempDir::new().unwrap();
let manifest = source_dir
.path()
.join(pixi_consts::consts::PROJECT_MANIFEST);

let (frontend_tx, backend_rx) = pipe();
let (backend_tx, frontend_rx) = pipe();
let ipc = InProcessBackend {
rpc_in: Box::new(frontend_rx),
rpc_out: Box::new(frontend_tx),
};

let protocol_setup = tokio::spawn(async move {
let (workspace, package) = TomlManifest::from_toml_str(toml)
.unwrap()
.into_manifests(ExternalWorkspaceProperties::default())
.unwrap();
pixi_build_frontend::pixi_protocol::ProtocolBuilder::new(
source_dir.path().to_path_buf(),
manifest.to_path_buf(),
workspace,
package.unwrap(),
)
.finish_with_ipc(ipc, 0)
.await
.expect_err("the test never sends a response to the initialize request");
});

let read_initialize_message = async move {
let initialize_line = BufReader::new(backend_rx)
.lines()
.next_line()
.await
.unwrap()
.unwrap();
let request: Request = serde_json::from_str(&initialize_line).unwrap();
let init_params: InitializeParams = request.params().parse().unwrap();
drop(backend_tx); // Simulates the backend closing the connection.
init_params
};

let (_, init_params) = tokio::join!(protocol_setup, read_initialize_message);

insta::assert_snapshot!(serde_json::to_string_pretty(&init_params.configuration).unwrap());
}

/// Creates a pipe that connects an async write instance to an async read
/// instance.
pub fn pipe() -> (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/pixi_build_frontend/tests/diagnostics.rs
expression: snapshot
---
× failed to setup a build backend, the pixi.toml could not be parsed
╰─▶ × missing field `channels`
╰─▶ × missing field 'channels' in table
╭─[pixi.toml:1:1]
1 │ [workspace]
· ───────────
Expand Down
4 changes: 0 additions & 4 deletions crates/pixi_build_types/src/procedures/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ pub struct InitializeParams {
/// The manifest that the build backend should use.
pub manifest_path: PathBuf,

/// Additional configuration to configure the backend. This configuration is
/// specific to the backend.
pub configuration: serde_json::Value,

/// The capabilities that the frontend provides.
pub capabilities: FrontendCapabilities,

Expand Down
Loading
Loading