U �Va � @ s� d dl mZ d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dl m Z ejZdd� Z dd � Zejd d kr�eZefZneZeefZdd� Z dS ) � )�core)�errorsN)�dist)�utilc C s t �tj�t_d S �N)r Z_get_unpatchedr �Distribution� r r �/core.py�_monkeypatch_distribution= s r c C s t t_d S r )�_saved_core_distributionr r r r r r �!_restore_distribution_monkeypatchA s r � c s� �z�t� |sW ��rdS t|t�r0tj�|�}ntj�d�}tj�|�sVt� d| ��zt �|�}W nB tk r� t �� d }t�d� t�d||jj|f ��Y nX |�r4|�� D ]|\}}t| jd| �r�t| jd| �|� q�t| j|��rt| j||� q�t| |��rt| ||� q�dt|� }t�|� q�tj�| � t| jjt t!f ��rft"| jj�| j_d d g� t �#� fdd��| _$W 5 t � X dS ) a9 Implements the actual pbr setup() keyword. When used, this should be the only keyword in your setup() aside from `setup_requires`. If given as a string, the value of pbr is assumed to be the relative path to the setup.cfg file to use. Otherwise, if it evaluates to true, it simply assumes that pbr should be used, and the default 'setup.cfg' is used. This works by reading the setup.cfg file, parsing out the supported metadata and command options, and using them to rebuild the `DistributionMetadata` object and set the newly added command options. The reason for doing things this way is that a custom `Distribution` class will not play nicely with setup_requires; however, this implementation may not work well with distributions that do use a `Distribution` subclass. Nz setup.cfgz%The setup.cfg file %s does not exist.� z Error parsingzError parsing %s: %s: %sZset_zUnknown distribution option: %sz pre_hook.*zpost_hook.*c s t �� �S r )r Z IgnoreDictr ��ignorer r �<lambda>� � zpbr.<locals>.<lambda>)%r r � isinstance�string_type�os�path�abspath�existsr ZDistutilsFileErrorr Zcfg_to_args� Exception�sys�exc_info�loggingZ exceptionZDistutilsSetupError� __class__�__name__�items�hasattrZmetadata�getattr�setattr�repr�warnings�warnr r Zfinalize_options�version� integer_types�float�strZDefaultGetDictZcommand_options) r �attr�valuer Zattrs�e�key�val�msgr r r �pbrM sJ � � � r0 )Z distutilsr r r r r r$ Z setuptoolsr r0 r r r r r �version_infor) r �intr'