diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2021-12-23 01:19:42 +0000 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-05 14:30:51 +0000 |
| commit | 9672a4883fdb0e24e913d076d01aa9d87bcc6ba1 (patch) | |
| tree | 0a419240acc5020db66d2986a9dbfa2da909aac4 /setuptools/config/pyprojecttoml.py | |
| parent | a8112d962d3908196d352b5d8f0d03e45645037e (diff) | |
| download | python-setuptools-git-9672a4883fdb0e24e913d076d01aa9d87bcc6ba1.tar.gz | |
Add means of applying config read from pyproject.toml to dist
Since the Distrubition and DistributionMetadata classes are modeled
after (an old version of) core metadata, it is necessary to add a
translation layer between them and the configuration read from
pyproject.toml
Diffstat (limited to 'setuptools/config/pyprojecttoml.py')
| -rw-r--r-- | setuptools/config/pyprojecttoml.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index 8029847e..8ce69e21 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -1,15 +1,19 @@ """Load setuptools configuration from ``pyproject.toml`` files""" +import json import os import sys from contextlib import contextmanager +from distutils import log from functools import partial -from typing import Union -import json +from typing import TYPE_CHECKING, Union -from setuptools.errors import OptionError, FileError -from distutils import log +from setuptools.errors import FileError, OptionError from . import expand as _expand +from ._apply_pyprojecttoml import apply + +if TYPE_CHECKING: + from setuptools.dist import Distribution # noqa _Path = Union[str, os.PathLike] @@ -49,6 +53,14 @@ def validate(config: dict, filepath: _Path): raise +def apply_configuration(dist: "Distribution", filepath: _Path) -> "Distribution": + """Apply the configuration from a ``pyproject.toml`` file into an existing + distribution object. + """ + config = read_configuration(filepath) + return apply(dist, config, filepath) + + def read_configuration(filepath, expand=True, ignore_option_errors=False): """Read given configuration file and returns options from it as a dict. |
