File: //usr/local/lib/python3.7/site-packages/setuptools/config/__pycache__/pyprojecttoml.cpython-37.pyc
B
N��g�C � @ sv d Z ddlZddlZddlmZ ddlmZ ddlmZm Z m
Z
mZmZm
Z
mZ ddlmZmZ ddlmZ d d
lmZ d dlmZmZ d dlmZ er�dd
lmZ eeejf Z e�!e"�Z#e e$d�dd�Z%e$e e&d�dd�Z'd+de dd�dd�Z(d,e ed d�dd�Z)d-e$ee e&ed e$d�dd�Z*G d d!� d!�Z+d"d#� Z,ee&d$�d%d&��Z-G d'd(� d(ej.�Z/G d)d*� d*e�Z0dS ).ac
Load setuptools configuration from ``pyproject.toml`` files.
**PRIVATE MODULE**: API reserved for setuptools internal usage only.
To read project metadata, consider using
``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).
For simple scenarios, you can also try parsing the file directly
with the help of ``tomllib`` or ``tomli``.
� N)�contextmanager)�partial)�
TYPE_CHECKING�Callable�Dict�Mapping�Optional�Set�Union� )� FileError�OptionError)�SetuptoolsWarning� )�expand)�_PREVIOUSLY_DEFINED�_WouldIgnoreField)�apply)�Distribution)�filepath�returnc C s, ddl m} t| d��}|�|�S Q R X d S )Nr )�tomli�rb)Zsetuptools.externr �open�load)r r �file� r �C/tmp/pip-unpacked-wheel-yrlplx0q/setuptools/config/pyprojecttoml.py� load_file s r )�configr r c
C s� ddl m} |j�d�}t|d�r*|�� y
|�| �S |jk
r� } zXd|j� �}|j �
d�dkrzt�|� t�|j
� d|j � d �}t|� d
|� ��d �W d d }~X Y nX d S )Nr )�_validate_pyprojectztrove-classifier�_disable_downloadzconfiguration error: �`�projectzinvalid pyproject.toml config: �.�
)� r ZFORMAT_FUNCTIONS�get�hasattrr! �validateZValidationError�summary�name�strip�_logger�debug�details�
ValueError)r r Z validatorZtrove_classifier�exr* �errorr r r r) % s
r) Fr )�distr r c C s t |d|| �}t| ||�S )zeApply the configuration from a ``pyproject.toml`` file into an existing
distribution object.
T)�read_configuration�_apply)r3 r �ignore_option_errorsr r r r �apply_configuration: s r7 T)r r3 c
C s t j�| �} t j�| �s(td| �d���t| �p2i }|�di �}|�di �}|�di �}|rd|sh|shi S |rtt�� |r�t |dd�dk r�|�
d|j� n|�
dd � ||d<