wads.toml_util¶
Utilities for reading and writing pyproject.toml files.
Functions
|
Get the [project] section from pyproject.toml. |
|
Get the project name from pyproject.toml. |
|
Get the version from pyproject.toml. |
|
The |
|
Read pyproject.toml from the specified package directory. |
|
Set the version in pyproject.toml. |
|
Update project metadata in pyproject.toml. |
|
Update or add a URL in the [project.urls] section of pyproject.toml. |
|
Write data to pyproject.toml in the specified package directory. |
- wads.toml_util.get_project_metadata(pkg_dir)[source]¶
Get the [project] section from pyproject.toml.
- wads.toml_util.pep639_license(license_name)[source]¶
The
[project].licensevalue forlicense_name, PEP 639 when possible.A name that canonicalizes to a valid SPDX expression becomes that string (
license = "MIT"). Anything else keeps the deprecated{"text": ...}table, because Hatchling rejects alicensestring that is not valid SPDX – so this never produces an unbuildable project. Needspackaging>=24.2for SPDX support and falls back to the table without it.>>> pep639_license("mit") 'MIT' >>> pep639_license("Apache Software License") 'Apache-2.0' >>> pep639_license("Proprietary") {'text': 'Proprietary'}
- wads.toml_util.read_pyproject_toml(pkg_dir)[source]¶
Read pyproject.toml from the specified package directory.
- Parameters:
pkg_dir (
str) – Path to the package directory- Return type:
- Returns:
Dictionary containing the parsed TOML data
- Raises:
ImportError – If tomli/tomllib is not available
FileNotFoundError – If pyproject.toml doesn’t exist
- wads.toml_util.update_project_metadata(pkg_dir, **kwargs)[source]¶
Update project metadata in pyproject.toml.
- wads.toml_util.update_project_url(pkg_dir, url, url_key='Homepage')[source]¶
Update or add a URL in the [project.urls] section of pyproject.toml.