Skip to content

Commit 2507e50

Browse files
committed
chore: rename ProjectModel to PackageModel
While browsing the source code, Tim and I found that `ProjectModel` is a pretty confusing name, since: - We don't have projects anymore, but workspaces - It's also not the data of the workspace, but rather data specific to one package We propose to rename it to `PackageModel`
1 parent e5af3f2 commit 2507e50

File tree

10 files changed

+53
-53
lines changed

10 files changed

+53
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ This release contains loads of bug fixes and refactors, primarily to make `pixi
628628
- Improve error messages when a python interpreter is needed by @tdejager in [#4075](https://github.com/prefix-dev/pixi/pull/4075)
629629
- Manual validation of frozen and locked CLI arguments by @gshiba in [#4044](https://github.com/prefix-dev/pixi/pull/4044)
630630
- Better error for unexpected packages from build backend by @baszalmstra in [#4098](https://github.com/prefix-dev/pixi/pull/4098)
631-
- Implement stable hash for ProjectModelV1 to improve cache consistency by @baszalmstra in [#4094](https://github.com/prefix-dev/pixi/pull/4094)
631+
- Implement stable hash for PackageModelV1 to improve cache consistency by @baszalmstra in [#4094](https://github.com/prefix-dev/pixi/pull/4094)
632632
- Upgrade to uv 0.7.20 by @tdejager in [#4091](https://github.com/prefix-dev/pixi/pull/4091)[#4115](https://github.com/prefix-dev/pixi/pull/4115)
633633
- Use command dispatcher for `pixi global install` by @tdejager in [#4126](https://github.com/prefix-dev/pixi/pull/4126)
634634
- Notify which conda packages may have influenced the conflict by @tdejager in [#4135](https://github.com/prefix-dev/pixi/pull/4135)

crates/pixi_build_backend_passthrough/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use pixi_build_frontend::{
1515
json_rpc::CommunicationError,
1616
};
1717
use pixi_build_types::{
18-
BackendCapabilities, NamedSpecV1, PackageSpecV1, ProjectModelV1, SourcePackageName,
19-
TargetSelectorV1, TargetV1, TargetsV1, VersionedProjectModel,
18+
BackendCapabilities, NamedSpecV1, PackageModelV1, PackageSpecV1, SourcePackageName,
19+
TargetSelectorV1, TargetV1, TargetsV1, VersionedPackageModel,
2020
procedures::{
2121
conda_build_v1::{CondaBuildV1Params, CondaBuildV1Result},
2222
conda_outputs::{
@@ -36,7 +36,7 @@ const BACKEND_NAME: &str = "passthrough";
3636
/// backend is useful for testing and debugging purposes, as it does not perform
3737
/// any actual building or processing of the project model.
3838
pub struct PassthroughBackend {
39-
project_model: ProjectModelV1,
39+
project_model: PackageModelV1,
4040
config: PassthroughBackendConfig,
4141
source_dir: PathBuf,
4242
index_json: Option<IndexJson>,
@@ -233,7 +233,7 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator {
233233
params: InitializeParams,
234234
) -> Result<Self::Backend, Box<CommunicationError>> {
235235
let project_model = match params.project_model {
236-
Some(VersionedProjectModel::V1(project_model)) => project_model,
236+
Some(VersionedPackageModel::V1(project_model)) => project_model,
237237
_ => {
238238
return Err(Box::new(CommunicationError::BackendError(
239239
BackendError::new("Passthrough backend only supports project model v1"),

crates/pixi_build_discovery/src/discovery.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use itertools::Itertools;
77
use miette::Diagnostic;
88
use ordermap::OrderMap;
99
use pixi_build_type_conversions::{to_project_model_v1, to_target_selector_v1};
10-
use pixi_build_types::{ProjectModelV1, TargetSelectorV1};
10+
use pixi_build_types::{PackageModelV1, TargetSelectorV1};
1111
use pixi_config::Config;
1212
use pixi_manifest::{
1313
DiscoveryStart, ExplicitManifestError, PackageManifest, PrioritizedChannel, WithProvenance,
@@ -58,7 +58,7 @@ pub struct BackendInitializationParams {
5858
pub manifest_path: PathBuf,
5959

6060
/// Optionally, the manifest of the discovered package.
61-
pub project_model: Option<ProjectModelV1>,
61+
pub project_model: Option<PackageModelV1>,
6262

6363
/// Additional configuration that applies to the backend.
6464
pub configuration: Option<serde_json::Value>,
@@ -377,7 +377,7 @@ impl DiscoveredBackend {
377377
source: None,
378378
source_anchor: source_dir,
379379
manifest_path: package_xml_absolute_path,
380-
project_model: Some(ProjectModelV1::default()),
380+
project_model: Some(PackageModelV1::default()),
381381
configuration: None,
382382
target_configuration: None,
383383
},

crates/pixi_build_frontend/src/backend/json_rpc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use jsonrpsee::{
1414
use miette::Diagnostic;
1515
use ordermap::OrderMap;
1616
use pixi_build_types::{
17-
BackendCapabilities, FrontendCapabilities, ProjectModelV1, TargetSelectorV1,
18-
VersionedProjectModel,
17+
BackendCapabilities, FrontendCapabilities, PackageModelV1, TargetSelectorV1,
18+
VersionedPackageModel,
1919
procedures::{
2020
self,
2121
conda_build_v1::{CondaBuildV1Params, CondaBuildV1Result},
@@ -146,7 +146,7 @@ impl JsonRpcBackend {
146146
source_dir: PathBuf,
147147
manifest_path: PathBuf,
148148
workspace_root: PathBuf,
149-
package_manifest: Option<ProjectModelV1>,
149+
package_manifest: Option<PackageModelV1>,
150150
configuration: Option<serde_json::Value>,
151151
target_configuration: Option<OrderMap<TargetSelectorV1, serde_json::Value>>,
152152
cache_dir: Option<PathBuf>,
@@ -215,7 +215,7 @@ impl JsonRpcBackend {
215215
source_dir: PathBuf,
216216
manifest_path: PathBuf,
217217
workspace_root: PathBuf,
218-
project_model: Option<ProjectModelV1>,
218+
project_model: Option<PackageModelV1>,
219219
configuration: Option<serde_json::Value>,
220220
target_configuration: Option<OrderMap<TargetSelectorV1, serde_json::Value>>,
221221
cache_dir: Option<PathBuf>,
@@ -252,7 +252,7 @@ impl JsonRpcBackend {
252252
.request(
253253
procedures::initialize::METHOD_NAME,
254254
RpcParams::from(InitializeParams {
255-
project_model: project_model.map(VersionedProjectModel::V1),
255+
project_model: project_model.map(VersionedPackageModel::V1),
256256
configuration,
257257
target_configuration,
258258
manifest_path: manifest_path.clone(),

crates/pixi_build_type_conversions/src/project_model.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ fn to_targets_v1(
163163
})
164164
}
165165

166-
/// Converts a [`PackageManifest`] to a [`pbt::ProjectModelV1`].
166+
/// Converts a [`PackageManifest`] to a [`pbt::PackageModelV1`].
167167
pub fn to_project_model_v1(
168168
manifest: &PackageManifest,
169169
channel_config: &ChannelConfig,
170-
) -> Result<pbt::ProjectModelV1, SpecConversionError> {
171-
let project = pbt::ProjectModelV1 {
170+
) -> Result<pbt::PackageModelV1, SpecConversionError> {
171+
let project = pbt::PackageModelV1 {
172172
name: manifest.package.name.clone(),
173173
version: manifest.package.version.clone(),
174174
description: manifest.package.description.clone(),
@@ -188,7 +188,7 @@ pub fn to_project_model_v1(
188188
mod tests {
189189
use std::path::PathBuf;
190190

191-
use pixi_build_types::VersionedProjectModel;
191+
use pixi_build_types::VersionedPackageModel;
192192
use rattler_conda_types::ChannelConfig;
193193
use rstest::rstest;
194194

@@ -221,7 +221,7 @@ mod tests {
221221
.unwrap();
222222

223223
// Convert the manifest to the project model
224-
let project_model: VersionedProjectModel =
224+
let project_model: VersionedPackageModel =
225225
super::to_project_model_v1(&package_manifest.value, &some_channel_config())
226226
.unwrap()
227227
.into();

crates/pixi_build_types/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub use capabilities::{BackendCapabilities, FrontendCapabilities};
1111
pub use channel_configuration::ChannelConfiguration;
1212
pub use conda_package_metadata::CondaPackageMetadata;
1313
pub use project_model::{
14-
BinaryPackageSpecV1, GitReferenceV1, GitSpecV1, NamedSpecV1, PackageSpecV1, PathSpecV1,
15-
ProjectModelV1, SourcePackageName, SourcePackageSpecV1, TargetSelectorV1, TargetV1, TargetsV1,
16-
UrlSpecV1, VersionedProjectModel,
14+
BinaryPackageSpecV1, GitReferenceV1, GitSpecV1, NamedSpecV1, PackageModelV1, PackageSpecV1,
15+
PathSpecV1, SourcePackageName, SourcePackageSpecV1, TargetSelectorV1, TargetV1, TargetsV1,
16+
UrlSpecV1, VersionedPackageModel,
1717
};
1818
use rattler_conda_types::{
1919
GenericVirtualPackage, PackageName, Platform, Version, VersionSpec,

crates/pixi_build_types/src/procedures/initialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::PathBuf;
55
use ordermap::OrderMap;
66
use serde::{Deserialize, Serialize};
77

8-
use crate::{TargetSelectorV1, VersionedProjectModel};
8+
use crate::{TargetSelectorV1, VersionedPackageModel};
99

1010
pub const METHOD_NAME: &str = "initialize";
1111

@@ -48,7 +48,7 @@ pub struct InitializeParams {
4848
/// Project model that the backend should use even though it is an option
4949
/// it is highly recommended to use this field. Otherwise, it will be very
5050
/// easy to break backwards compatibility.
51-
pub project_model: Option<VersionedProjectModel>,
51+
pub project_model: Option<VersionedPackageModel>,
5252

5353
/// Backend specific configuration passed from the frontend to the backend.
5454
pub configuration: Option<serde_json::Value>,

crates/pixi_build_types/src/project_model.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,34 @@ use url::Url;
3232
#[derive(Debug, Clone, Serialize, Deserialize)]
3333
#[serde(tag = "version", content = "data")]
3434
#[serde(rename_all = "camelCase")]
35-
pub enum VersionedProjectModel {
35+
pub enum VersionedPackageModel {
3636
/// Version 1 of the project model.
3737
#[serde(rename = "1")]
38-
V1(ProjectModelV1),
38+
V1(PackageModelV1),
3939
// When adding don't forget to update the highest_version function
4040
}
4141

42-
impl VersionedProjectModel {
42+
impl VersionedPackageModel {
4343
/// Highest version of the project model.
4444
pub fn highest_version() -> u32 {
4545
// increase this when adding a new version
4646
1
4747
}
4848

4949
/// Move into the v1 type, returns None if the version is not v1.
50-
pub fn into_v1(self) -> Option<ProjectModelV1> {
50+
pub fn into_v1(self) -> Option<PackageModelV1> {
5151
match self {
52-
VersionedProjectModel::V1(v) => Some(v),
52+
VersionedPackageModel::V1(v) => Some(v),
5353
// Add this once we have more versions
5454
//_ => None,
5555
}
5656
}
5757

5858
/// Returns a reference to the v1 type, returns None if the version is not
5959
/// v1.
60-
pub fn as_v1(&self) -> Option<&ProjectModelV1> {
60+
pub fn as_v1(&self) -> Option<&PackageModelV1> {
6161
match self {
62-
VersionedProjectModel::V1(v) => Some(v),
62+
VersionedPackageModel::V1(v) => Some(v),
6363
// Add this once we have more versions
6464
//_ => None,
6565
}
@@ -71,7 +71,7 @@ pub type SourcePackageName = String;
7171

7272
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
7373
#[serde(rename_all = "camelCase")]
74-
pub struct ProjectModelV1 {
74+
pub struct PackageModelV1 {
7575
/// The name of the project
7676
pub name: Option<String>,
7777

@@ -102,22 +102,22 @@ pub struct ProjectModelV1 {
102102
/// URL of the project documentation
103103
pub documentation: Option<Url>,
104104

105-
/// The target of the project, this may contain
105+
/// The target of the package, this may contain
106106
/// platform specific configurations.
107107
pub targets: Option<TargetsV1>,
108108
}
109109

110-
impl IsDefault for ProjectModelV1 {
110+
impl IsDefault for PackageModelV1 {
111111
type Item = Self;
112112

113113
fn is_non_default(&self) -> Option<&Self::Item> {
114114
Some(self)
115115
}
116116
}
117117

118-
impl From<ProjectModelV1> for VersionedProjectModel {
119-
fn from(value: ProjectModelV1) -> Self {
120-
VersionedProjectModel::V1(value)
118+
impl From<PackageModelV1> for VersionedPackageModel {
119+
fn from(value: PackageModelV1) -> Self {
120+
VersionedPackageModel::V1(value)
121121
}
122122
}
123123

@@ -193,13 +193,13 @@ impl IsDefault for TargetsV1 {
193193
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
194194
#[serde(rename_all = "camelCase")]
195195
pub struct TargetV1 {
196-
/// Host dependencies of the project
196+
/// Host dependencies of the package
197197
pub host_dependencies: Option<OrderMap<SourcePackageName, PackageSpecV1>>,
198198

199-
/// Build dependencies of the project
199+
/// Build dependencies of the package
200200
pub build_dependencies: Option<OrderMap<SourcePackageName, PackageSpecV1>>,
201201

202-
/// Run dependencies of the project
202+
/// Run dependencies of the package
203203
pub run_dependencies: Option<OrderMap<SourcePackageName, PackageSpecV1>>,
204204
}
205205

@@ -415,12 +415,12 @@ impl std::fmt::Debug for BinaryPackageSpecV1 {
415415
}
416416

417417
// Custom Hash implementations that skip default values for stability
418-
impl Hash for ProjectModelV1 {
418+
impl Hash for PackageModelV1 {
419419
/// Custom hash implementation using StableHashBuilder to ensure different
420420
/// field configurations produce different hashes while maintaining
421421
/// forward/backward compatibility.
422422
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
423-
let ProjectModelV1 {
423+
let PackageModelV1 {
424424
name,
425425
version,
426426
description,
@@ -644,8 +644,8 @@ mod tests {
644644

645645
#[test]
646646
fn test_hash_stability_with_default_values() {
647-
// Create a minimal ProjectModelV1 instance
648-
let mut project_model = ProjectModelV1 {
647+
// Create a minimal PackageModelV1 instance
648+
let mut project_model = PackageModelV1 {
649649
name: Some("test-project".to_string()),
650650
version: None,
651651
description: None,
@@ -700,8 +700,8 @@ mod tests {
700700

701701
#[test]
702702
fn test_hash_changes_with_meaningful_values() {
703-
// Create a minimal ProjectModelV1 instance
704-
let mut project_model = ProjectModelV1 {
703+
// Create a minimal PackageModelV1 instance
704+
let mut project_model = PackageModelV1 {
705705
name: Some("test-project".to_string()),
706706
version: None,
707707
description: None,
@@ -995,15 +995,15 @@ mod tests {
995995

996996
#[test]
997997
fn test_hash_collision_bug_project_model() {
998-
// Test the same issue in ProjectModelV1
999-
let project1 = ProjectModelV1 {
998+
// Test the same issue in PackageModelV1
999+
let project1 = PackageModelV1 {
10001000
name: Some("test".to_string()),
10011001
description: Some("test description".to_string()),
10021002
license: None,
10031003
..Default::default()
10041004
};
10051005

1006-
let project2 = ProjectModelV1 {
1006+
let project2 = PackageModelV1 {
10071007
name: Some("test".to_string()),
10081008
description: None,
10091009
license: Some("test description".to_string()),
@@ -1015,7 +1015,7 @@ mod tests {
10151015

10161016
assert_ne!(
10171017
hash1, hash2,
1018-
"Same value in different fields should produce different hashes in ProjectModelV1"
1018+
"Same value in different fields should produce different hashes in PackageModelV1"
10191019
);
10201020
}
10211021
}

crates/pixi_command_dispatcher/src/build/build_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use async_fd_lock::{LockWrite, RwLockWriteGuard};
99
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
1010
use ordermap::OrderMap;
1111
use pixi_build_discovery::{BackendInitializationParams, DiscoveredBackend};
12-
use pixi_build_types::{ProjectModelV1, TargetSelectorV1};
12+
use pixi_build_types::{PackageModelV1, TargetSelectorV1};
1313
use pixi_record::PinnedSourceSpec;
1414
use pixi_stable_hash::{StableHashBuilder, json::StableJson, map::StableMap};
1515
use rattler_conda_types::{ChannelUrl, GenericVirtualPackage, Platform, RepoDataRecord};
@@ -317,7 +317,7 @@ impl BuildCacheEntry {
317317
/// warranted.
318318
pub struct PackageBuildInputHashBuilder<'a> {
319319
/// The project model itself. Contains dependencies and more.
320-
pub project_model: Option<&'a ProjectModelV1>,
320+
pub project_model: Option<&'a PackageModelV1>,
321321

322322
/// The backend specific configuration
323323
pub configuration: Option<&'a serde_json::Value>,

crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use once_cell::sync::Lazy;
1111
use pathdiff::diff_paths;
1212
use pixi_build_discovery::{CommandSpec, EnabledProtocols};
1313
use pixi_build_frontend::Backend;
14-
use pixi_build_types::{ProjectModelV1, procedures::conda_outputs::CondaOutputsParams};
14+
use pixi_build_types::{PackageModelV1, procedures::conda_outputs::CondaOutputsParams};
1515
use pixi_glob::GlobHashKey;
1616
use pixi_record::{InputHash, PinnedSourceSpec};
1717
use pixi_spec::{SourceAnchor, SourceSpec};
@@ -488,7 +488,7 @@ pub enum BuildBackendMetadataError {
488488

489489
/// Computes an additional hash to be used in glob hash
490490
pub fn calculate_additional_glob_hash(
491-
project_model: &Option<ProjectModelV1>,
491+
project_model: &Option<PackageModelV1>,
492492
variants: &Option<BTreeMap<String, Vec<String>>>,
493493
) -> Vec<u8> {
494494
let mut hasher = Xxh3::new();

0 commit comments

Comments
 (0)