forked from prefix-dev/pixi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
123 lines (109 loc) · 3.3 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
mod activation;
mod build_system;
pub(crate) mod channel;
mod dependencies;
mod environment;
mod environments;
mod error;
mod feature;
mod features_ext;
mod has_features_iter;
mod has_manifest_ref;
mod manifests;
mod package;
mod preview;
pub mod pypi;
pub mod pyproject;
mod solve_group;
mod spec_type;
mod system_requirements;
mod target;
pub mod task;
pub mod toml;
pub mod utils;
mod validation;
mod workspace;
pub use activation::Activation;
pub use build_system::BuildSystem;
pub use channel::PrioritizedChannel;
pub use dependencies::{CondaDependencies, Dependencies, PyPiDependencies};
pub use environment::{Environment, EnvironmentName};
pub use error::TomlError;
pub use feature::{Feature, FeatureName};
pub use features_ext::FeaturesExt;
pub use has_features_iter::HasFeaturesIter;
pub use has_manifest_ref::HasManifestRef;
use itertools::Itertools;
pub use manifests::{Manifest, ManifestKind, ManifestSource, WorkspaceManifest};
use miette::Diagnostic;
pub use preview::{KnownPreviewFeature, Preview, PreviewFeature};
pub use pypi::pypi_requirement::PyPiRequirement;
use rattler_conda_types::Platform;
pub use spec_type::SpecType;
pub use system_requirements::{LibCSystemRequirement, SystemRequirements};
pub use target::{TargetSelector, Targets, WorkspaceTarget};
pub use task::{Task, TaskName};
use thiserror::Error;
pub use workspace::Workspace;
pub use crate::{
environments::Environments,
solve_group::{SolveGroup, SolveGroups},
};
/// Errors that can occur when getting a feature.
#[derive(Debug, Clone, Error, Diagnostic)]
pub enum GetFeatureError {
#[error("feature `{0}` does not exist")]
FeatureDoesNotExist(FeatureName),
}
#[derive(Debug, Copy, Clone)]
pub enum DependencyOverwriteBehavior {
/// Overwrite anything that is already present.
Overwrite,
/// Overwrite only if the dependency is explicitly defined (e.g. it has some
/// constraints).
OverwriteIfExplicit,
/// Ignore any duplicate
IgnoreDuplicate,
/// Error on duplicate
Error,
}
pub enum PypiDependencyLocation {
/// [pypi-dependencies] in pixi.toml or [tool.pixi.pypi-dependencies] in pyproject.toml
PixiPypiDependencies,
/// [project.dependencies] in pyproject.toml
Dependencies,
/// [project.optional-dependencies] table in pyproject.toml
OptionalDependencies,
/// [dependency-groups] in pyproject.toml
DependencyGroups,
}
/// Converts an array of Platforms to a non-empty Vec of Option<Platform>
fn to_options(platforms: &[Platform]) -> Vec<Option<Platform>> {
match platforms.is_empty() {
true => vec![None],
false => platforms.iter().map(|p| Some(*p)).collect_vec(),
}
}
use console::StyledObject;
use fancy_display::FancyDisplay;
use pixi_consts::consts;
impl FancyDisplay for EnvironmentName {
fn fancy_display(&self) -> StyledObject<&str> {
consts::ENVIRONMENT_STYLE.apply_to(self.as_str())
}
}
impl FancyDisplay for &EnvironmentName {
fn fancy_display(&self) -> StyledObject<&str> {
consts::ENVIRONMENT_STYLE.apply_to(self.as_str())
}
}
impl FancyDisplay for TaskName {
fn fancy_display(&self) -> StyledObject<&str> {
consts::TASK_STYLE.apply_to(self.as_str())
}
}
impl FancyDisplay for FeatureName {
fn fancy_display(&self) -> StyledObject<&str> {
consts::FEATURE_STYLE.apply_to(self.as_str())
}
}