
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
U
    V.a                      @   s  d Z zddlZW n ek
r$   Y nX ddlZddlZddlZddlZddlZddlm	Z	 ddl
ZddlmZ ddlmZmZmZ ddlmZ ddlmZ ddlmZ zddlZW n ek
r   ddlZY nX dd	lmZ ddlZed
ZddddddddddddddddddddddddddddddddZdZdZ d Z!d!d" Z"d@d$d%Z#d&d' Z$d(d) Z%d*d+ Z&d,d- Z'd.d/ Z(d0d1 Z)d2d3 Z*d4d5 Z+d6d7 Z,d8d9 Z-d:d; Z.G d<d= d=e	Z/G d>d? d?e0Z1dS )Aa  The code in this module is mostly copy/pasted out of the distutils2 source
code, as recommended by Tarek Ziade.  As such, it may be subject to some change
as distutils2 development continues, and will have to be kept up to date.

I didn't want to use it directly from distutils2 itself, since I do not want it
to be an installation dependency for our packages yet--it is still too unstable
(the latest version on PyPI doesn't even install).
    N)defaultdict)log)DistutilsOptionErrorDistutilsModuleErrorDistutilsFileError)manifest_maker)Distribution)	Extension)extra_filesz\s*(.*?)\s*\((.*)\)\s*$)metadata)r   Z	home_page)r   Zsummary)r   description)r   Z
classifier)r   platform)r   Zrequires_dist)r   Zsetup_requires_dist)r   Zprovides_dist)r   Zobsoletes_dist)filespackages_root)r   )r   modules)globalZcommands)backwards_compatuse_2to3)r   zip_safe)r   tests_require)r   )nameversionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurlr   keywordslong_descriptionzdownload-urlclassifiers	platformslicenseinstall_requiressetup_requiresprovides	obsoletespackage_dirpackagespackage_datanamespace_packages
data_filesscripts
py_modulescmdclassr   r   r   dependency_linksinclude_package_data)r   r   r   r   r    r$   r"   r#   r%   r&   r'   r)   r   r   r(   )r   r   r*   )r   c              	   C   s   |  d}t|d }|d| }|d }|dkrztd||gd}W qW q* tk
r   |dkrh |d8 }|d| }|| }d}Y q*X q*||d D ]0}zt||}W q tk
r   t| Y qX q|S )zResolve a name like ``module.object`` to an object and return it.

    Raise ImportError if the module or name is not found.
    .   Nr   )fromlist )splitlen
__import__joinImportErrorgetattrAttributeError)r   partsZcursormodule_nameZ	attr_nameZretpart r:   9/opt/alt/python38/lib/python3.8/site-packages/pbr/util.pyresolve_name   s*    
r<   	setup.cfgc              	   C   s  t  }tj| s(tdtj|  ||  i }| D ]}t	|
|||< q>t|dd}t|dd}|rtj|}tjd| z|r&dd t|D }|D ]x}t|}z|| W q tk
r   td	 Y q   t d
 }td||f  tt  td
 Y qX qtj| t|}	d|	d< d|	d< t| t|}
|
rh|
|	d< t|}|r~||	d< t|	 t|dd}|rt !t| W 5 |rtjd X |	S )aP   Distutils2 to distutils1 compatibility util.

        This method uses an existing setup.cfg to generate a dictionary of
        keywords that can be used by distutils.core.setup(kwargs**).

        :param file:
            The setup.cfg path.
        :raises DistutilsFileError:
            When the setup.cfg file is not found.

    zfile '%s' does not existr   setup_hooksr   r   r   c                 S   s   g | ]}|d kr|qS )zpbr.hooks.setup_hookr:   ).0hookr:   r:   r;   
<listcomp>   s   zcfg_to_args.<locals>.<listcomp>z)setup hook %s terminated the installationr,   z#setup hook %s raised exception: %s
Tr*   Fr   ext_modulesentry_pointsr
   )"configparserZSafeConfigParserospathexistsr   abspathreadZsectionsdictitemshas_get_optionsysinsertpopsplit_multiliner<   
SystemExitr   errorexc_info	traceback
format_excexitpbrhooksZ
setup_hooksetup_cfg_to_setup_kwargsregister_custom_compilersget_extension_modulesget_entry_pointswrap_commandsr
   Zset_extra_files)rF   parserconfigsectionr>   r!   r@   Zhook_fnekwargsrB   rC   Zfiles_extra_filesr:   r:   r;   cfg_to_args   sd    

rc   c           "   
   C   s  i }i }t D ]}tt | dkr0t | \}}n tt | dkrPt | d }|}t| ||}|s|dkrt| |d}|rt|}d}|D ]0}t|}	z||	  d 7 }W 5 |	  X q|}nq|tkrt	|}|t
krt|}n"|tkr| dkrd	}nd
}|r|dkr$dd |D }|dkrg }
d}|D ]<}t||}|d }|d }|
||f q:|
|d< n|dkrd|i}n|dkrbi }d	}d}|D ]}d|kr|dd\}}| |  }}||kr|| }||  n|  }|| < n&|r0td| n||   d
}q|dkr\| }|}n@|dkri }t }|D ]"}t|}||}||| < qz|}|||< qd| kr$d}| d }|D ]\}g }t|| }|D ]8}t||}|d }|d}|||f q|||< qi }|D ]D} ||  D ]4\}}|rTd| |f }!n| }!||!g | q8q,|dg |d< ||d< |S )zqProcesses the setup.cfg options and converts them to arguments accepted
    by setuptools' setup() function.
       r,   r   r   description_filer/   z

)truet1yesyTF)r   r   c                 S   s   g | ]}t d |qS )z\1\2)_VERSION_SPEC_REsub)r?   Zpredr:   r:   r;   rA   K  s   z-setup_cfg_to_setup_kwargs.<locals>.<listcomp>r   z6(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$package
env_markerr!   )r#   r%   N=z1malformed package_data first line %r (misses "=")r%   r(   extrasz6(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$z%s:(%s)extras_require)D1_D2_SETUP_ARGSr1   rL   rP   opencloserI   strip
CSV_FIELDS	split_csvMULTI_FIELDSBOOL_FIELDSlowerrematchgroupappendr0   extendr   rK   r   r<   get_command_name
setdefaultrO   )"r_   rb   Zall_requirementsargr`   optionZin_cfg_valuevaluefilenamere   r   Zrequirement_patternZrequirementmZrequirement_packagern   r%   	firstlineprevlinekeyr(   distZcls_nameclscmdrp   ZextraZextra_requirementsZrequirementsZextras_valuerq   Z	req_groupZ
extras_keyr:   r:   r;   rY     s    














rY   c                 C   s   t | dd}|rt|}|D ]p}t|}t|dr:|j}n|j}t|drR|j}nd| }|j}tj	j
}||j|f||< tj| tjd| < qdS )zHandle custom compilers; this has no real equivalent in distutils, where
    additional compilers could only be added programmatically, so we have to
    hack it in somehow.
    r   	compilersr   r   zcustom compiler %sz
distutils.N)rL   rP   r<   hasattrr   __name__r   
__module__	distutilsZ	ccompilerZcompiler_classrM   r   )r_   r   Zcompilerr   Zdescr8   Zccr:   r:   r;   rZ     s    

rZ   c           
      C   s(  d}g }| D ]}d|kr(| dd}n| dd}dd |D }t|dkr|d d	kri }|D ]}t| ||}|sxqbt|}|d
krg }|D ]P}	|	 dd}	t|	dkr|	d  df}	n|	d  |	d  f}	||	 q|}|||< qb|rd|kr
|d |d< |t|df| q|S )zHandle extension modules)sourcesZinclude_dirsdefine_macrosZundef_macrosZlibrary_dirsZ	librariesZruntime_library_dirsZextra_objectsZextra_compile_argsZextra_link_argsZexport_symbolsZ	swig_optsZdepends:r,   ro   c                 S   s   g | ]}|  qS r:   ru   )r?   lr:   r:   r;   rA     s     z)get_extension_modules.<locals>.<listcomp>rd   r   	extensionr   Nr   )r0   r1   rL   rP   ru   r~   r	   rO   )
r_   ZEXTENSION_FIELDSrB   r`   labelsZext_argsZfieldr   ZmacrosZmacror:   r:   r;   r[     s>    


r[   c                 C   s&   d| kri S t dd | d  D S )a  Process the [entry_points] section of setup.cfg to handle setuptools
    entry points.  This is, of course, not a standard feature of
    distutils2/packaging, but as there is not currently a standard alternative
    in packaging, we provide support for them.
    rC   c                 s   s   | ]\}}|t |fV  qd S N)rP   )r?   r   r   r:   r:   r;   	<genexpr>  s   z#get_entry_points.<locals>.<genexpr>)rJ   rK   )r_   r:   r:   r;   r\     s
    
r\   c                 C   s   t  }|  | D ]\}}i }|| D ]H\}}|d }|dsT|dr0|dd\}}||i }	||	|< q0|sqd| kr|| d kr| d | }
n
||}
t	||
|}|| di |< qd S )Nr,   z	pre_hook.z
post_hook.r+   r(   )
r   Zparse_config_filesZget_command_listZget_option_dictrK   
startswithr0   r   Zget_command_classwrap_command)rb   r   r   _rX   optvalZ	hook_typealiasZ	hook_dictr(   Znew_cmdclassr:   r:   r;   r]     s"    

r]   c              	   C   s2   |fdd}t | |tf|t|d|ddS )Nc                 S   s"   |  d ||  |  d d S )Npre_hook	post_hook)run_command_hooksrun)selfr(   r:   r:   r;   r   2  s    

zwrap_command.<locals>.runr   r   )r   r   r   r   )typeobjectr   get)r   r(   rX   r   r:   r:   r;   r   1  s    
r   c              	   C   s  |dkrt d| t| |d}|dkr,dS | D ]}t|trzt|}W q tk
r~   t d }t	d||f Y qX n|}t
|dstd| td|||   z||  W q4   t d }td	||f  tt  td Y q4X q4dS )
zRun hooks registered for that command and phase.

    *cmd_obj* is a finalized command object; *hook_kind* is either
    'pre_hook' or 'post_hook'.
    )r   r   zinvalid hook kind: %rNr,   zcannot find hook %s: %s__call__zhook %r is not callablezrunning %s %s for command %szhook %s raised exception: %s
)
ValueErrorr5   values
isinstancestrr<   r4   rM   rS   r   r   r   r   infor   rR   rT   rU   rV   )Zcmd_objZ	hook_kindrX   r@   Zhook_objerrra   r:   r:   r;   r   =  s:    

  r   c                 C   sX   || kr || | kr | | | S || krP| dd| | krP| | | dd S dS d S )Nr   -Freplace)r_   r`   r   r:   r:   r;   rL   f  s
    rL   c                 C   s"   dd dd |  dD D } | S )z3Special behaviour when we have a multi line optionsc                 S   s   g | ]}|r|qS r:   r:   r?   elementr:   r:   r;   rA   r  s    z#split_multiline.<locals>.<listcomp>c                 s   s   | ]}|  V  qd S r   r   )r?   r   r:   r:   r;   r   s  s     z"split_multiline.<locals>.<genexpr>
r0   r   r:   r:   r;   rP   o  s    rP   c                 C   s"   dd dd |  dD D } | S )z8Special behaviour when we have a comma separated optionsc                 S   s   g | ]}|r|qS r:   r:   r   r:   r:   r;   rA   {  s    zsplit_csv.<locals>.<listcomp>c                 s   s   | ]}|  V  qd S r   r   )r?   chunkr:   r:   r;   r   |  s     zsplit_csv.<locals>.<genexpr>,r   r   r:   r:   r;   rw   x  s    rw   c                    s    fdd}|S )z[A function decorator to monkey-patch a method of the same name on the
    given class.
    c                    s:   t  | jd }|r6t|ds6t| d| t | j|  | S )NZ_orig)r5   r   r   setattr)funcZorigr   r:   r;   wrapper  s
    z#monkeypatch_method.<locals>.wrapperr:   )r   r   r:   r   r;   monkeypatch_method  s    r   c                       s"   e Zd ZdZd fdd	Z  ZS )DefaultGetDictzXLike defaultdict, but the get() method also sets and returns the default
    value.
    Nc                    s"   |d kr|   }tt| ||S r   )default_factorysuperr   r   )r   r   default	__class__r:   r;   r     s    zDefaultGetDict.get)N)r   r   __qualname____doc__r   __classcell__r:   r:   r   r;   r     s   r   c                       s(   e Zd ZdZdd Z fddZ  ZS )
IgnoreDictzA dictionary that ignores any insertions in which the key is a string
    matching any string in `ignore`.  The ignore list can also contain wildcard
    patterns using '*'.
    c                 C   s$   t dddd |D  | _d S )Nz(%s)|c                 S   s   g | ]}| d dqS )*z.*r   )r?   Zpatr:   r:   r;   rA     s   z'IgnoreDict.__init__.<locals>.<listcomp>)r{   compiler3   _IgnoreDict__ignore)r   ignorer:   r:   r;   __init__  s
    
zIgnoreDict.__init__c                    s&   | j |rd S tt| || d S r   )r   r|   r   r   __setitem__)r   r   r   r   r:   r;   r     s    zIgnoreDict.__setitem__)r   r   r   r   r   r   r   r:   r:   r   r;   r     s   r   )r=   )2r   Zmultiprocessingr4   ZloggingrE   r{   rM   rT   collectionsr   Zdistutils.ccompilerr   r   distutils.errorsr   r   r   Zsetuptools.command.egg_infor   Zsetuptools.distr   Zsetuptools.extensionr	   ZConfigParserrD   rW   r
   Z	pbr.hooksr   rk   rr   rx   ry   rv   r<   rc   rY   rZ   r[   r\   r]   r   r   rL   rP   rw   r   r   rJ   r   r:   r:   r:   r;   <module>.   s   
' 
V "5)			