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

Refactor manifest #572

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::environment::{update_prefix, verify_prefix_location_unchanged};
use crate::prefix::Prefix;
use crate::project::DependencyType::CondaDependency;
use crate::project::{DependencyType, SpecType};
use crate::{
consts,
@@ -94,11 +93,11 @@ impl DependencyType {
if args.pypi {
Self::PypiDependency
} else if args.host {
CondaDependency(SpecType::Host)
DependencyType::CondaDependency(SpecType::Host)
} else if args.build {
CondaDependency(SpecType::Build)
DependencyType::CondaDependency(SpecType::Build)
} else {
CondaDependency(SpecType::Run)
DependencyType::CondaDependency(SpecType::Run)
}
}
}
@@ -122,7 +121,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.filter(|p| !project.platforms().contains(p))
.cloned()
.collect::<Vec<Platform>>();
project.add_platforms(platforms_to_add.iter())?;
project.manifest.add_platforms(platforms_to_add.iter())?;

match dependency_type {
DependencyType::CondaDependency(spec_type) => {
@@ -183,7 +182,10 @@ pub async fn execute(args: Args) -> miette::Result<()> {
}

// Print if it is something different from host and dep
if !matches!(dependency_type, CondaDependency(SpecType::Run)) {
if !matches!(
dependency_type,
DependencyType::CondaDependency(SpecType::Run)
) {
eprintln!(
"Added these as {}.",
console::style(dependency_type.name()).bold()
@@ -212,10 +214,12 @@ pub async fn add_pypi_specs_to_project(
// TODO: Get best version
// Add the dependency to the project
if specs_platforms.is_empty() {
project.add_pypi_dependency(name, spec)?;
project.manifest.add_pypi_dependency(name, spec)?;
} else {
for platform in specs_platforms.iter() {
project.add_target_pypi_dependency(*platform, name.clone(), spec)?;
project
.manifest
.add_target_pypi_dependency(*platform, name.clone(), spec)?;
}
}
}
@@ -309,10 +313,12 @@ pub async fn add_conda_specs_to_project(

// Add the dependency to the project
if specs_platforms.is_empty() {
project.add_dependency(&spec, spec_type)?;
project.manifest.add_dependency(&spec, spec_type)?;
} else {
for platform in specs_platforms.iter() {
project.add_target_dependency(*platform, &spec, spec_type)?;
project
.manifest
.add_target_dependency(*platform, &spec, spec_type)?;
}
}
}
1 change: 1 addition & 0 deletions src/cli/info.rs
Original file line number Diff line number Diff line change
@@ -197,6 +197,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
let project_info = project.map(|p| ProjectInfo {
manifest_path: p.root().to_path_buf().join("pixi.toml"),
tasks: p
.manifest
.tasks(Some(Platform::current()))
.into_keys()
.map(|k| k.to_string())
4 changes: 3 additions & 1 deletion src/cli/project/channel/add.rs
Original file line number Diff line number Diff line change
@@ -48,7 +48,9 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
let lock_file = load_lock_file(&project).await?;

// Add the channels to the lock-file
project.add_channels(missing_channels.iter().map(|(name, _channel)| name))?;
project
.manifest
.add_channels(missing_channels.iter().map(|(name, _channel)| name))?;

// Try to update the lock-file with the new channels
let lock_file = update_lock_file(&project, lock_file, None).await?;
6 changes: 4 additions & 2 deletions src/cli/remove.rs
Original file line number Diff line number Diff line change
@@ -45,9 +45,11 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.iter()
.map(|dep| {
if let Some(p) = &args.platform {
project.remove_target_dependency(dep, &spec_type, p)
project
.manifest
.remove_target_dependency(dep, &spec_type, p)
} else {
project.remove_dependency(dep, &spec_type)
project.manifest.remove_dependency(dep, &spec_type)
}
})
.collect::<Vec<_>>();
1 change: 1 addition & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@ async fn execute_task<'p>(
if status_code == 127 {
let available_tasks = task
.project()
.manifest
.tasks(Some(Platform::current()))
.into_keys()
.sorted()
13 changes: 9 additions & 4 deletions src/cli/task.rs
Original file line number Diff line number Diff line change
@@ -139,7 +139,9 @@ pub fn execute(args: Args) -> miette::Result<()> {
Operation::Add(args) => {
let name = &args.name;
let task: Task = args.clone().into();
project.add_task(name, task.clone(), args.platform)?;
project
.manifest
.add_task(name, task.clone(), args.platform)?;
eprintln!(
"{}Added task {}: {}",
console::style(console::Emoji("✔ ", "+")).green(),
@@ -152,6 +154,7 @@ pub fn execute(args: Args) -> miette::Result<()> {
for name in args.names.iter() {
if let Some(platform) = args.platform {
if !project
.manifest
.target_specific_tasks(platform)
.contains_key(name.as_str())
{
@@ -163,7 +166,7 @@ pub fn execute(args: Args) -> miette::Result<()> {
);
continue;
}
} else if !project.tasks(None).contains_key(name.as_str()) {
} else if !project.manifest.tasks(None).contains_key(name.as_str()) {
eprintln!(
"{}Task {} does not exist",
console::style(console::Emoji("❌ ", "X")).red(),
@@ -191,7 +194,7 @@ pub fn execute(args: Args) -> miette::Result<()> {
}

for (name, platform) in to_remove {
project.remove_task(name, platform)?;
project.manifest.remove_task(name, platform)?;
eprintln!(
"{}Removed task {} ",
console::style(console::Emoji("✔ ", "+")).green(),
@@ -202,7 +205,9 @@ pub fn execute(args: Args) -> miette::Result<()> {
Operation::Alias(args) => {
let name = &args.alias;
let task: Task = args.clone().into();
project.add_task(name, task.clone(), args.platform)?;
project
.manifest
.add_task(name, task.clone(), args.platform)?;
eprintln!(
"{} Added alias {}: {}",
console::style("@").blue(),
4 changes: 2 additions & 2 deletions src/environment.rs
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ pub fn sanity_check_project(project: &Project) -> miette::Result<()> {
// Make sure the project supports the current platform
let platform = Platform::current();
if !project.platforms().contains(&platform) {
let span = project.manifest.project.platforms.span();
let span = project.manifest.parsed.project.platforms.span();
return Err(miette::miette!(
help = format!(
"The project needs to be configured to support your platform ({platform})."
@@ -99,7 +99,7 @@ pub fn sanity_check_project(project: &Project) -> miette::Result<()> {
)],
"the project is not configured for your current platform"
)
.with_source_code(project.source()));
.with_source_code(project.manifest_named_source()));
}

// Make sure the system requirements are met
2 changes: 1 addition & 1 deletion src/lock_file/pypi.rs
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ pub async fn resolve_pypi_dependencies<'p>(
// Determine the compatible tags
let compatible_tags = project_platform_tags(
platform,
&project.manifest.system_requirements,
project.system_requirements(),
python_record.as_ref(),
);

Loading