29 releases

0.13.7 Oct 9, 2025
0.13.5 Jun 10, 2025
0.13.4 Oct 30, 2024
0.11.0 May 23, 2024
0.1.1 May 30, 2021

#155 in Parser implementations

Download history 129841/week @ 2026-02-16 156170/week @ 2026-02-23 178293/week @ 2026-03-02 190273/week @ 2026-03-09 143894/week @ 2026-03-16 112775/week @ 2026-03-23 124253/week @ 2026-03-30 162153/week @ 2026-04-06 133779/week @ 2026-04-13 139831/week @ 2026-04-20 134386/week @ 2026-04-27 88244/week @ 2026-05-04 81180/week @ 2026-05-11 88554/week @ 2026-05-18 88335/week @ 2026-05-25 104846/week @ 2026-06-01

373,838 downloads per month
Used in 15 crates (7 directly)

MIT license

49KB
1K SLoC

pyproject-toml-rs

Crates.io docs.rs

pyproject.toml parser in Rust.

Installation

Add it to your Cargo.toml:

[dependencies]
pyproject-toml = "0.8"

then you are good to go. If you are using Rust 2015 you have to add extern crate pyproject_toml to your crate root as well.

Extended parsing

If you want to add additional fields parsing, you can do it with serde's flatten feature and implement the Deref trait, for example:

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PyProjectToml {
    #[serde(flatten)]
    inner: pyproject_toml::PyProjectToml,
    tool: Option<Tool>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct Tool {
    maturin: Option<ToolMaturin>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct ToolMaturin {
    sdist_include: Option<Vec<String>>,
}

impl std::ops::Deref for PyProjectToml {
    type Target = pyproject_toml::PyProjectToml;

    fn deref(&self) -> &Self::Target {
        &self.inner
    }
}

impl PyProjectToml {
    pub fn new(content: &str) -> Result<Self, toml::de::Error> {
        toml::from_str(content)
    }
}

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Dependencies

~9–13MB
~215K SLoC