pyproject#
Tools for loading, inspecting, and updating pyproject.toml.
- class Pyproject(document: PyprojectTOML, source: IO | Path | None = None)[source]#
Bases:
objectRead-only representation of a
pyproject.tomlfile.- classmethod load(source: IO | Path | str = PosixPath('pyproject.toml')) Self[source]#
Load a
pyproject.tomlfile from a file, I/O stream, orstr.
- final get_package_name() str | None[source]#
- final get_package_name(*, raise_on_missing: Literal[False]) str | None
- final get_package_name(*, raise_on_missing: Literal[True]) str
- class ModifiablePyproject(document: PyprojectTOML, source: IO | Path | None = None, changelog: list[str] = NOTHING)[source]#
Bases:
Pyproject,AbstractContextManagerStateful representation of a
pyproject.tomlfile.Use this class to apply multiple modifications to a
pyproject.tomlfile in separate sub-hooks. The modifications are dumped once the context is exited.- classmethod load(source: IO | Path | str = PosixPath('pyproject.toml')) Self[source]#
Load a
pyproject.tomlfile from a file, I/O stream, orstr.
- complies_with_subset(settings: Mapping, minimal_settings: Mapping, *, exact_value_match: bool = True) bool[source]#
Compare if a nested mapping fits inside another nested mapping.
>>> complies_with_subset( ... {"channels": ["conda-forge"]}, ... {"channels": ["conda-forge"], "platforms": ["linux-64"]}, ... ) False >>> complies_with_subset( ... {"channels": ["conda-forge"], "platforms": ["linux-64"]}, ... {"channels": ["conda-forge"]}, ... ) True >>> complies_with_subset( ... {"channels": ["conda-forge", "default"]}, ... {"channels": ["conda-forge"]}, ... exact_value_match=False, ... ) True
- get_constraints_file(python_version: Literal['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']) Path | None[source]#
- load_pyproject_toml(source: IO | Path | str, modifiable: bool) PyprojectTOML[source]#
Load a
pyproject.tomlfile from a file, I/O stream, orstr.The
modifiableflag determines which parser to use:
Submodules and Subpackages