Skip to content

Commit

Permalink
Merge #1439
Browse files Browse the repository at this point in the history
1439: Update `toml_edit` to 0.19 and switch back to `toml` for parsing r=messense a=messense

https://epage.github.io/blog/2023/01/toml-vs-toml-edit/

Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
bors[bot] and messense authored Feb 1, 2023
2 parents 7c8bd5a + c3d02b6 commit 26d6f91
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 45 deletions.
58 changes: 40 additions & 18 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name = "maturin"
anyhow = "1.0.63"
base64 = "0.13.0"
glob = "0.3.0"
cargo-config2 = "0.1.1"
cargo-config2 = "0.1.4"
cargo_metadata = "0.15.2"
cargo-options = "0.5.2"
cbindgen = { version = "0.24.2", default-features = false }
Expand All @@ -36,7 +36,8 @@ serde_json = "1.0.80"
sha2 = "0.10.3"
tar = "0.4.38"
tempfile = "3.2.0"
toml_edit = { version = "0.17.1", features = ["easy"] }
toml = "0.7.0"
toml_edit = "0.19.1"
zip = { version = "0.6.1", default-features = false, features = ["bzip2", "deflate", "time"] }
thiserror = "1.0.37"
dirs = "4.0.0"
Expand All @@ -46,7 +47,7 @@ once_cell = "1.7.2"
rustc_version = "0.4.0"
semver = "1.0.13"
target-lexicon = "0.12.0"
pyproject-toml = "0.3.0"
pyproject-toml = "0.3.3"
python-pkginfo = "0.5.5"
textwrap = "0.16.0"
ignore = "0.4.18"
Expand Down Expand Up @@ -87,7 +88,7 @@ keyring = { version = "1.1.1", optional = true }
indoc = "2.0.0"
pretty_assertions = "1.3.0"
rustversion = "1.0.9"
trycmd = "0.14.0"
trycmd = "0.14.11"
which = "4.3.0"

[features]
Expand Down
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ deny = [
skip = [
#{ name = "ansi_term", version = "=0.11.0" },
{ name = "ahash", version = "0.3.8" },
# from cbindgen
{ name = "toml", version = "0.5.11" },
# from secret-service
{ name = "block-buffer", version = "0.9.0" },
{ name = "digest", version = "0.9.0" },
Expand Down
8 changes: 4 additions & 4 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl CargoToml {
"Can't read Cargo.toml at {}",
manifest_file.as_ref().display(),
))?;
let cargo_toml = toml_edit::easy::from_str(&contents).context(format!(
let cargo_toml = toml::from_str(&contents).context(format!(
"Failed to parse Cargo.toml at {}",
manifest_file.as_ref().display()
))?;
Expand Down Expand Up @@ -109,7 +109,7 @@ pub struct RemainingCoreMetadata {
/// Cargo compile targets
pub targets: Option<Vec<CargoTarget>>,
#[serde(flatten)]
pub other: HashMap<String, toml_edit::easy::Value>,
pub other: HashMap<String, toml::Value>,
}

/// Cargo compile target
Expand Down Expand Up @@ -160,7 +160,7 @@ mod test {
"#
);

let cargo_toml: Result<CargoToml, _> = toml_edit::easy::from_str(cargo_toml);
let cargo_toml: Result<CargoToml, _> = toml::from_str(cargo_toml);
assert!(cargo_toml.is_ok());

let maturin = cargo_toml.unwrap().remaining_core_metadata();
Expand Down Expand Up @@ -192,7 +192,7 @@ mod test {
"#
);

let cargo_toml: Result<CargoToml, _> = toml_edit::easy::from_str(cargo_toml);
let cargo_toml: Result<CargoToml, _> = toml::from_str(cargo_toml);
assert!(cargo_toml.is_ok());
}
}
10 changes: 5 additions & 5 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ mod test {
let toml_with_path = cargo_toml.replace("REPLACE_README_PATH", &readme_path);
fs::write(&manifest_path, &toml_with_path).unwrap();

let cargo_toml_struct: CargoToml = toml_edit::easy::from_str(&toml_with_path).unwrap();
let cargo_toml_struct: CargoToml = toml::from_str(&toml_with_path).unwrap();
let cargo_metadata = MetadataCommand::new()
.manifest_path(manifest_path)
.exec()
Expand Down Expand Up @@ -727,7 +727,7 @@ mod test {
fn test_merge_metadata_from_pyproject_toml() {
let manifest_dir = PathBuf::from("test-crates").join("pyo3-pure");
let cargo_toml_str = fs_err::read_to_string(manifest_dir.join("Cargo.toml")).unwrap();
let cargo_toml: CargoToml = toml_edit::easy::from_str(&cargo_toml_str).unwrap();
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_str).unwrap();
let cargo_metadata = MetadataCommand::new()
.manifest_path(manifest_dir.join("Cargo.toml"))
.exec()
Expand Down Expand Up @@ -778,7 +778,7 @@ mod test {
fn test_merge_metadata_from_pyproject_toml_with_customized_python_source_dir() {
let manifest_dir = PathBuf::from("test-crates").join("pyo3-mixed-py-subdir");
let cargo_toml_str = fs_err::read_to_string(manifest_dir.join("Cargo.toml")).unwrap();
let cargo_toml: CargoToml = toml_edit::easy::from_str(&cargo_toml_str).unwrap();
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_str).unwrap();
let cargo_metadata = MetadataCommand::new()
.manifest_path(manifest_dir.join("Cargo.toml"))
.exec()
Expand All @@ -802,7 +802,7 @@ mod test {
fn test_implicit_readme() {
let manifest_dir = PathBuf::from("test-crates").join("pyo3-mixed");
let cargo_toml_str = fs_err::read_to_string(manifest_dir.join("Cargo.toml")).unwrap();
let cargo_toml = toml_edit::easy::from_str(&cargo_toml_str).unwrap();
let cargo_toml = toml::from_str(&cargo_toml_str).unwrap();
let cargo_metadata = MetadataCommand::new()
.manifest_path(manifest_dir.join("Cargo.toml"))
.exec()
Expand All @@ -820,7 +820,7 @@ mod test {
fn test_merge_metadata_from_pyproject_dynamic_license_test() {
let manifest_dir = PathBuf::from("test-crates").join("license-test");
let cargo_toml_str = fs_err::read_to_string(manifest_dir.join("Cargo.toml")).unwrap();
let cargo_toml: CargoToml = toml_edit::easy::from_str(&cargo_toml_str).unwrap();
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_str).unwrap();
let cargo_metadata = MetadataCommand::new()
.manifest_path(manifest_dir.join("Cargo.toml"))
.exec()
Expand Down
3 changes: 1 addition & 2 deletions src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ fn generate_uniffi_bindings(
let config_file = crate_dir.join("uniffi.toml");
let mut cdylib_name = None;
if config_file.is_file() {
let uniffi_toml: UniFfiToml =
toml_edit::easy::from_str(&fs::read_to_string(&config_file)?)?;
let uniffi_toml: UniFfiToml = toml::from_str(&fs::read_to_string(&config_file)?)?;
cdylib_name = uniffi_toml
.bindings
.get("python")
Expand Down
18 changes: 6 additions & 12 deletions src/pyproject_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl PyProjectToml {
pub fn new(pyproject_file: impl AsRef<Path>) -> Result<PyProjectToml> {
let path = pyproject_file.as_ref();
let contents = fs::read_to_string(path)?;
let pyproject: PyProjectToml = toml_edit::easy::from_str(&contents)
let pyproject: PyProjectToml = toml::from_str(&contents)
.map_err(|err| format_err!("pyproject.toml is not PEP 517 compliant: {}", err))?;
Ok(pyproject)
}
Expand Down Expand Up @@ -357,17 +357,13 @@ mod tests {
fn deserialize_include_exclude() {
let single = r#"include = ["single"]"#;
assert_eq!(
toml_edit::easy::from_str::<ToolMaturin>(single)
.unwrap()
.include,
toml::from_str::<ToolMaturin>(single).unwrap().include,
Some(vec![GlobPattern::Path("single".to_string())])
);

let multiple = r#"include = ["one", "two"]"#;
assert_eq!(
toml_edit::easy::from_str::<ToolMaturin>(multiple)
.unwrap()
.include,
toml::from_str::<ToolMaturin>(multiple).unwrap().include,
Some(vec![
GlobPattern::Path("one".to_string()),
GlobPattern::Path("two".to_string())
Expand All @@ -376,7 +372,7 @@ mod tests {

let single_format = r#"include = [{path = "path", format="sdist"}]"#;
assert_eq!(
toml_edit::easy::from_str::<ToolMaturin>(single_format)
toml::from_str::<ToolMaturin>(single_format)
.unwrap()
.include,
Some(vec![GlobPattern::WithFormat {
Expand All @@ -387,7 +383,7 @@ mod tests {

let multiple_formats = r#"include = [{path = "path", format=["sdist", "wheel"]}]"#;
assert_eq!(
toml_edit::easy::from_str::<ToolMaturin>(multiple_formats)
toml::from_str::<ToolMaturin>(multiple_formats)
.unwrap()
.include,
Some(vec![GlobPattern::WithFormat {
Expand All @@ -398,9 +394,7 @@ mod tests {

let mixed = r#"include = ["one", {path = "two", format="sdist"}, {path = "three", format=["sdist", "wheel"]}]"#;
assert_eq!(
toml_edit::easy::from_str::<ToolMaturin>(mixed)
.unwrap()
.include,
toml::from_str::<ToolMaturin>(mixed).unwrap().include,
Some(vec![
GlobPattern::Path("one".to_string()),
GlobPattern::WithFormat {
Expand Down

0 comments on commit 26d6f91

Please sign in to comment.