-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get tool.pixi.project.name from project.name
- Loading branch information
1 parent
dd5e26d
commit 98ea377
Showing
7 changed files
with
93 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,11 @@ use rattler_conda_types::{NamelessMatchSpec, PackageName, ParseStrictness::Lenie | |
use serde::Deserialize; | ||
use std::str::FromStr; | ||
use toml_edit; | ||
use toml_edit::TomlError; | ||
|
||
use super::{ | ||
error::RequirementConversionError, python::PyPiPackageName, ProjectManifest, PyPiRequirement, | ||
SpecType, | ||
error::{RequirementConversionError, TomlError}, | ||
python::PyPiPackageName, | ||
ProjectManifest, PyPiRequirement, SpecType, | ||
}; | ||
|
||
#[derive(Deserialize, Debug, Clone)] | ||
|
@@ -33,7 +33,17 @@ impl std::ops::Deref for PyProjectManifest { | |
impl PyProjectManifest { | ||
/// Parses a toml string into a pyproject manifest. | ||
pub fn from_toml_str(source: &str) -> Result<Self, TomlError> { | ||
toml_edit::de::from_str(source).map_err(TomlError::from) | ||
let manifest: PyProjectManifest = | ||
toml_edit::de::from_str(source).map_err(TomlError::from)?; | ||
|
||
// Make sure [project] exists in pyproject.toml, | ||
// This will ensure project.name is defined | ||
// TODO: do we want to Err if tool.pixi.name is defined? | ||
if manifest.project.is_none() { | ||
return Err(TomlError::NoProjectTable(0..1)); | ||
} | ||
|
||
Ok(manifest) | ||
} | ||
} | ||
|
||
|
@@ -42,8 +52,9 @@ impl From<PyProjectManifest> for ProjectManifest { | |
// Start by loading the data nested under "tool.pixi" | ||
let mut manifest = item.tool.pixi.clone(); | ||
|
||
// TODO: tool.pixi.project.name should be made optional or read from project.name | ||
// Get tool.pixi.project.name from project.name | ||
// TODO: could copy across / convert some other optional fields if relevant | ||
manifest.project.name = item.project.as_ref().map(|p| p.name.clone()); | ||
|
||
// Add python as dependency based on the project.requires_python property (if any) | ||
let pythonspec = item | ||
|
@@ -115,8 +126,10 @@ mod tests { | |
}; | ||
|
||
const PYPROJECT_FULL: &str = r#" | ||
[tool.pixi.project] | ||
[project] | ||
name = "project" | ||
[tool.pixi.project] | ||
version = "0.1.0" | ||
description = "A project" | ||
authors = ["Author <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters