Registry / serialization / pyproject-toml

pyproject-toml

JSON →
library0.1.0pypypi✓ verified 85d ago

pyproject-toml is a Python library designed to parse and manage `pyproject.toml` files according to various PEPs, including PEP 517, 518, 621, and 631. It provides a structured way to access project metadata and build system configuration. The current version is 0.1.0, and it follows an infrequent release cadence based on new PEP implementations or bug fixes.

pip install pyproject-toml
INSTALL
IMPORT
SIG · PYPROJECT-TOML
P
pyproject-toml
serializationpythonv0.1.0
Install
3.6s avg
Import
Disk
31MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 29.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 29MB
31MB installed
● package 31MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PyProjectToml
from pyproject_toml import PyProjectToml
from pyproject_toml import PyProjectTOML

This quickstart demonstrates how to programmatically create a dummy `pyproject.toml` file, load it using `PyProjectTOML`, and access common project metadata like name and version. The example cleans up the created file afterwards.

import os from pyproject_toml import PyProjectTOML # Create a dummy pyproject.toml for the example dummy_toml_content = """ [project] name = "my-dummy-project" version = "0.1.0" description = "A short description." requires-python = ">=3.9" authors = [ {name = "Jane Doe", email = "jane@example.com"}, ] """ with open("pyproject.toml", "w") as f: f.write(dummy_toml_content) try: # Initialize and load the pyproject.toml file pyproject = PyProjectTOML() data = pyproject.load() # Access project metadata project_name = data["project"]["name"] project_version = data["project"]["version"] print(f"Project Name: {project_name}") print(f"Project Version: {project_version}") except Exception as e: print(f"An error occurred: {e}") finally: # Clean up the dummy file if os.path.exists("pyproject.toml"): os.remove("pyproject.toml")
Debug
Known issues
gotchaThe PyPI package name `pyproject-toml` (with a hyphen) differs from its Python import name `pyproject_toml` (with an underscore). Using the hyphenated name in import statements will result in a `ModuleNotFoundError`.
fix
Always use `from pyproject_toml import PyProjectTOML` (with an underscore) in your Python code.
affects: all
gotchaWhen `PyProjectTOML().load()` is called without arguments, it implicitly searches for `pyproject.toml` in the current working directory. If your script is executed from a different directory, it might not find the file as expected.
fix
Explicitly specify the path to your `pyproject.toml` file using `PyProjectTOML(filename='/path/to/pyproject.toml').load()` or ensure your script's working directory is correct.
affects: all
breakingAs the library is currently in an early development stage (version 0.1.0) and implements evolving PEPs, future minor versions might introduce breaking changes to its API surface or the structure of the data returned, especially as new PEP features are added or interpretations solidify.
fix
It is recommended to pin the exact library version (e.g., `pyproject-toml==0.1.0`) in your `requirements.txt` or `pyproject.toml` and carefully review changelogs when upgrading to new versions.
affects: 0.x.x
Upgrade
Version history
0.1.0latest on PyPI · released Nov 12, 2024
Audit
Dependencies
tomlrequiredRequired for parsing TOML formatted files.
packagingrequiredUsed for handling version specifiers and other packaging-related metadata conforming to PEPs.
Agent activity
13 hits · last 30 days
node
12
Resources
pyproject-toml — pip install pyproject-toml · libregistry