
­­­­­­­­­­­­­­­­­­
<!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   	home_page)r   summary)r   description)r   
classifier)r   platform)r   requires_dist)r   setup_requires_dist)r   provides_dist)r   obsoletes_dist)filespackages_root)r   )r   modules)globalcommands)backwards_compatuse_2to3)r   zip_safe)r   tests_require)r   )nameversionauthorauthor_email
maintainermaintainer_email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-   r1   r/   r0   r2   r3   r4   r6   r+   r   r5   )r   r   r7   )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   partscursormodule_name	attr_nameretpart rJ   9/opt/alt/python38/lib/python3.8/site-packages/pbr/util.pyresolve_name   s*    
rL   	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_hookrJ   ).0hookrJ   rJ   rK   
<listcomp>   s   zcfg_to_args.<locals>.<listcomp>z)setup hook %s terminated the installationr9   z#setup hook %s raised exception: %s
Tr7   Fr   ext_modulesentry_pointsr
   )"configparserSafeConfigParserospathexistsr   abspathreadsectionsdictitemshas_get_optionsysinsertpopsplit_multilinerL   
SystemExitr   errorexc_info	traceback
format_excexitpbrhooks
setup_hooksetup_cfg_to_setup_kwargsregister_custom_compilersget_extension_modulesget_entry_pointswrap_commandsr
   set_extra_files)rW   parserconfigsectionrN   r.   rP   hook_fnekwargsrR   rS   files_extra_filesrJ   rJ   rK   cfg_to_args   sd    

ry   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.
       r9   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)rO   predrJ   rJ   rK   rQ   K  s   z-setup_cfg_to_setup_kwargs.<locals>.<listcomp>r*   z6(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$package
env_markerr.   )r0   r2   N=z1malformed package_data first line %r (misses "=")r2   r5   extrasz6(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$z%s:(%s)extras_require)D1_D2_SETUP_ARGSr>   r^   rb   opencloserZ   strip
CSV_FIELDS	split_csvMULTI_FIELDSBOOL_FIELDSlowerrematchgroupappendr=   extendr   r]   r   rL   get_command_name
setdefaultra   )"rs   rw   all_requirementsargrt   optionin_cfg_valuevaluefilenamer{   r*   requirement_patternrequirementmrequirement_packager   r2   	firstlineprevlinekeyr5   distcls_nameclscmdr   extraextra_requirementsrequirementsextras_valuer   	req_group
extras_keyrJ   rJ   rK   rl     s    














rl   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)r^   rb   rL   hasattrr   __name__r   
__module__	distutils	ccompilercompiler_classr_   r   )rs   r   compilerr   descrF   ccrJ   rJ   rK   rm     s    

rm   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)sourcesinclude_dirsdefine_macrosundef_macroslibrary_dirs	librariesruntime_library_dirsextra_objectsextra_compile_argsextra_link_argsexport_symbols	swig_optsdepends:r9   r   c                 S   s   g | ]}|  qS rJ   r   )rO   lrJ   rJ   rK   rQ     s     z)get_extension_modules.<locals>.<listcomp>rz   r   	extensionr   Nr   )r=   r>   r^   rb   r   r   r	   ra   )
rs   EXTENSION_FIELDSrR   rt   labelsext_argsfieldr   macrosmacrorJ   rJ   rK   rn     s>    


rn   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.
    rS   c                 s   s   | ]\}}|t |fV  qd S N)rb   )rO   r   r   rJ   rJ   rK   	<genexpr>  s   z#get_entry_points.<locals>.<genexpr>)r\   r]   )rs   rJ   rJ   rK   ro     s
    
ro   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 )Nr9   z	pre_hook.z
post_hook.r8   r5   )
r   parse_config_filesget_command_listget_option_dictr]   
startswithr=   r   get_command_classwrap_command)rw   r   r   _rj   optval	hook_typealias	hook_dictr5   new_cmdclassrJ   rJ   rK   rp     s"    

rp   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)selfr5   rJ   rJ   rK   r   2  s    

zwrap_command.<locals>.runr   r   )r   r   r   r   )typeobjectr   get)r   r5   rj   r   rJ   rJ   rK   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: %rNr9   zcannot find hook %s: %s__call__zhook %r is not callablezrunning %s %s for command %szhook %s raised exception: %s
)
ValueErrorrB   values
isinstancestrrL   rA   r_   re   r   r   r   r   infor   rd   rf   rg   rh   )cmd_obj	hook_kindrj   rP   hook_objerrrv   rJ   rJ   rK   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)rs   rt   r   rJ   rJ   rK   r^   f  s
    r^   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 rJ   rJ   rO   elementrJ   rJ   rK   rQ   r  s    z#split_multiline.<locals>.<listcomp>c                 s   s   | ]}|  V  qd S r   r   )rO   r   rJ   rJ   rK   r   s  s     z"split_multiline.<locals>.<genexpr>
r=   r   rJ   rJ   rK   rb   o  s    rb   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 rJ   rJ   r   rJ   rJ   rK   rQ   {  s    zsplit_csv.<locals>.<listcomp>c                 s   s   | ]}|  V  qd S r   r   )rO   chunkrJ   rJ   rK   r   |  s     zsplit_csv.<locals>.<genexpr>,r   r   rJ   rJ   rK   r   x  s    r   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 )N_orig)rB   r   r   setattr)funcorigr   rJ   rK   wrapper  s
    z#monkeypatch_method.<locals>.wrapperrJ   )r   r  rJ   r  rK   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__rJ   rK   r     s    zDefaultGetDict.get)N)r   r   __qualname____doc__r   __classcell__rJ   rJ   r  rK   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   )rO   patrJ   rJ   rK   rQ     s   z'IgnoreDict.__init__.<locals>.<listcomp>)r   compiler@   _IgnoreDict__ignore)r   ignorerJ   rJ   rK   __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  rJ   rK   r    s    zIgnoreDict.__setitem__)r   r   r
  r  r  r  r  rJ   rJ   r  rK   r    s   r  )rM   )2r  multiprocessingrA   loggingrV   r   r_   rf   collectionsr   distutils.ccompilerr   r   distutils.errorsr   r   r   setuptools.command.egg_infor   setuptools.distr   setuptools.extensionr	   ConfigParserrT   ri   r
   	pbr.hooksr  r   r   r   r   r   rL   ry   rl   rm   rn   ro   rp   r   r   r^   rb   r   r  r  r\   r  rJ   rJ   rJ   rK   <module>.   s   
' 
V "5)			