o
    Ni~z                     @   s  d dl mZ d dl mZ zd dlZW n	 ey   Y nw d dlZd dlZd dlZ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mZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ 	 edZdZ i 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,d-d.d/d0d1d2d2d3d4Z!d5Z"d6d7iZ#d8Z$d9Z%d:d; Z&d<d= Z'dQd?d@Z(dAdB Z)dRdCdDZ*dEdF Z+dGdH Z,dIdJ Z-dKdL Z.dMdN Z/dOdP ZdS )S    )absolute_import)print_functionN)errors)log)dist)	extension)ConfigParser)integer_types)string_type	packaging)extra_files)hooksz\s*(.*?)\s*\((.*)\)\s*$)#))metadatanamer   ))r   versionr   ))r   authorr   ))r   author_emailr   ))r   
maintainerr   ))r   maintainer_emailr   )r   	home_pageurl))r   project_urlsr   )r   summarydescription))r   keywordsr   )r   r   long_description))r   description_content_typelong_description_content_type))r   download_urlr"   )r   
classifierclassifiers)r   platform	platforms))r   licenser)   )r   requires_distinstall_requires)r   setup_requires_distsetup_requires)r   python_requiresr1   )r   requires_pythonr1   )r   provides_distprovides)r   provides_extrasr8   )r   obsoletes_dist	obsoletes)filespackages_rootpackage_dir)r=   packagesrA   )r=   package_datarC   )r=   namespace_packagesrE   )r=   
data_filesrG   )r=   scriptsrI   )r=   modules
py_modules))globalcommandscmdclass)backwards_compatzip_saferR   )rQ   tests_requirerT   )rQ   dependency_linksrV   )rQ   include_package_datarX   r   zMUse '[metadata] url' (setup.cfg) or '[project.urls]' (pyproject.toml) insteadr   z\Use '[metadata] description' (setup.cfg) or '[project] description' (pyproject.toml) instead)r   description_filez\Use '[metadata] long_description' (setup.cfg) or '[project] readme' (pyproject.toml) insteadr#   z\Use '[metadata] classifiers' (setup.cfg) or '[project] classifiers' (pyproject.toml) insteadr&   z`Use '[metadata] platforms' (setup.cfg) or '[tool.setuptools] platforms' (pyproject.toml) insteadr*   zaUse '[options] install_requires' (setup.cfg) or '[project] dependencies' (pyproject.toml) insteadr-   z`Use '[options] setup_requires' (setup.cfg) or '[build-system] requires' (pyproject.toml) insteadr0   zcUse '[options] python_requires' (setup.cfg) or '[project] requires-python' (pyproject.toml) insteadr2   r4   zThis option is ignored by pipr7   r9   r<   zdUse '[options] package_dir' (setup.cfg) or '[tools.setuptools] package_dir' (pyproject.toml) insteadr@   z^Use '[options] packages' (setup.cfg) or '[tools.setuptools] packages' (pyproject.toml) insteadrB   zeUse '[options.package_data]' (setup.cfg) or '[tool.setuptools.package-data]' (pyproject.toml) insteadrD   zeUse '[options] namespace_packages' (setup.cfg) or migrate to PEP 420-style namespace packages insteadrF   aM  For package data files, use '[options] package_data' (setup.cfg) or '[tools.setuptools] package_data' (pyproject.toml) instead. Support for non-package data files is deprecated in setuptools and their use is discouraged. If necessary, use '[options] data_files' (setup.cfg) or '[tools.setuptools] data-files'(pyproject.toml) instead.zMigrate to using the console_scripts entrypoint and use '[options.entry_points]' (setup.cfg) or '[project.scripts]' (pyproject.toml) insteadzbUse '[options] py_modules' (setup.cfg) or '[tools.setuptools] py-modules' (pyproject.toml) insteadzFThis option is obsolete as it was only relevant in the context of eggsz4This option is ignored by pip starting from pip 19.0zvUse '[options] include_package_data' (setup.cfg) or '[tools.setuptools] include-package-data' (pyproject.toml) instead)rH   rJ   rP   rU   rS   rW   )r%   r(   r,   r6   r;   rE   rA   rC   rG   rI   rL   rV   r/   rT   r   rO   r8   tests_requiresz72.0.0)r   )rR   rX   c                 C   s4   t jdkr| dd} dd t| D S t| S )Nnt\/c                 S   s   g | ]}| d dqS )r]   r\   )replace).0x ra   @/home/ubuntu/.local/lib/python3.10/site-packages/pbr/setupcfg.py
<listcomp>  s    zshlex_split.<locals>.<listcomp>)osr   r^   shlexsplit)pathra   ra   rb   shlex_split  s   

rh   c              	   C   s   |  d}t|d }|d| }|d }|dkrHztd||gd}W n" tyC   |dkr1 |d8 }|d| }|| }d}Y nw |dks||d D ]}zt||}W qN tyb   t| w |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 )rf   len
__import__joinImportErrorgetattrAttributeError)r   partscursormodule_name	attr_nameretpartra   ra   rb   resolve_name  s0   
rz   	setup.cfgc              	   C   s$  |du rd}t  }tj| stdtj|  z	|j| dd W n ty1   ||  Y nw i }|	 D ]}i ||< |
|D ]\}}||| |dd< qCq8t|dd	}t|d
d}|rntj|}tjd| z|rdd t|D }|D ]=}	t|	}
z|
| W q| ty   td Y q| ty   t d }td|	|f  tt  td Y q|w t| t||}d|d< d|d< t|ddrtdt t|}|r||d< t |}|r||d< t|d
d}|rt!"t| W |rtj#d |S |rtj#d w w )a  Parse setup.cfg file.

    Parse a setup.cfg file and tranform pbr-specific options to the underlying
    setuptools opts.

    :param path: The setup.cfg path.
    :param script_args: List of commands setup.py was called with.
    :returns: A dictionary of kwargs to set on the underlying Distribution
        object.
    :raises DistutilsFileError: When the setup.cfg file is not found.
    Nra   zfile '%s' does not existutf-8encoding-_rM   setup_hooksr=   r>   r   c                 S   s   g | ]}|d kr|qS )zpbr.hooks.setup_hookra   )r_   hookra   ra   rb   rc   [  s
    z%setup_cfg_to_args.<locals>.<listcomp>z)setup hook %s terminated the installationrj   z#setup hook %s raised exception: %s
TrX   FrR   	compilerszgSupport for custom compilers was removed in pbr 7.0 and the '[global] compilers' option is now ignored.ext_modulesentry_pointsr   )$r   rd   rg   existsr   DistutilsFileErrorabspathread	TypeErrorsectionsitemsr^   has_get_optionsysinsertsplit_multilinerz   
SystemExitr   error	Exceptionexc_info	traceback
format_excexitr   
setup_hooksetup_cfg_to_setup_kwargswarningswarnDeprecationWarningget_extension_modulesget_entry_pointsr   set_extra_filespop)rg   script_argsparserconfigsectionkvaluer   r?   r   hook_fnekwargsr   r   files_extra_filesra   ra   rb   setup_cfg_to_args+  s   

	
r   c              	   C   sz   t | dd}|r
dS t | dd}|sdS t|}d}|D ]}tj|dd}z||  d 7 }W |  q|  w |S )	z,Handle the legacy 'description_file' option.r   r   NrY   rm   r|   r}   z

)r   r   ioopenr   stripclose)r   r   description_filesdatafilenamerY   ra   ra   rb   _read_description_file  s   r   c           *   
   C   sn  |du rd}i }i }d}t | ddr2t | ddst | ddr2t | dd|d< t| }|r0||d< d}tD ]V\}}|\}}	|rD|d	v rDq4t | ||	}
|d
krT|
sTt| }
|
sWq4|tv rltd|d |d t| f t |tv rut|
}
n/|t	v ri }t|
D ]}|
dd\}}| || < q|}
n|tv r|
 dv rd}
nd}
|
r|tv rttjtt| krq4|dv rdd |
D }
|dkrg }d}|
D ]}t||}|d }|d }|||f q||d< n|dkrd|
i}
n|dv rfi }d}d}|
D ]P}d|v rA|
dd\}}t| d }|| }}||v r6|| }|t| nt| }|| < n|rKtd| |t|  d}q|dkrct| }|}
n!|dkri }t }|
D ]}t|}||} |||   < qs|}
|
||< q4d| v rd}| d }!d|!vrdd l!m"}" d!#|"$|"j%&d"d#|!d< |!D ].}#g }$t|!|# }%|%D ]}t||}|d }&|d}|$|&|f q|$||#< qi }'|D ]B}(||( D ]:\}}|rd$|(|f })d%|vrzt'd&| r	|(})W n t(y   t)*d'  w n|(})|'+|)g | qq|',dg |d< |'|d(< |S ))zConvert config options to kwargs.

    Processes the setup.cfg options and converts them to arguments accepted
    by setuptools' setup() function.
    Nra   Fr   r   r   rY   T)r   r   r   z&The '[%s] %s' option is deprecated: %sr   rj   =)truet1yesy)r,   rT   c                 S   s   g | ]}t d |qS )z\1\2)_VERSION_SPEC_REsub)r_   predra   ra   rb   rc     s    
z-setup_cfg_to_setup_kwargs.<locals>.<listcomp>r,   z6(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$package
env_markerrm   r?   )rC   rG   z1malformed package_data first line %r (misses "=")rG   rO   extrasz6(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$testr   
;:z%s:(%s)bdist_wheelz(%s)zMarker evaluation failed, see the following error.  For more information see: http://docs.openstack.org/pbr/latest/user/using.html#environment-markersextras_require)-r   r   CFG_TO_PY_SETUP_ARGSDEPRECATED_CFGr   r   r   MULTI_FIELDSr   
MAP_FIELDSrf   r   BOOL_FIELDSlowerREMOVED_KEYWORDSpackaging_compatparse_version
setuptools__version__rematchgroupappendrh   extendr   DistutilsOptionErrorsortedr   st_distDistributionrz   get_command_namepbrr   rp   parse_requirementsTEST_REQUIREMENTS_FILESr^   evaluate_markerSyntaxErrorr   r   
setdefaultr   )*r   r   r   all_requirementsskip_description_normalizationr   aliasargr   optionin_cfg_value
in_cfg_mapir   vr,   requirement_patternrequirementmrequirement_packager   rG   	firstlineprevlinekeyr   key_unquotedrO   r   cls_nameclscmdr   r   extraextra_requirementsrequirementsextras_valuer   	req_group
extras_keyra   ra   rb   r     s"  

















r   c           
      C   s*  d}g }| D ]}d|v r| dd}n| dd}dd |D }t|dkr|d d	kri }|D ]F}t| ||}|s;q0t|}|d
krrg }|D ](}	|	 dd}	t|	dkr^|	d  df}	n|	d  |	d  f}	||	 qG|}|||< q0|rd|vr|d |d< |tj|dfi | 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dependsr   rj   r   c                 S   s   g | ]}|  qS ra   r   )r_   labelra   ra   rb   rc     s    z)get_extension_modules.<locals>.<listcomp>   r   r   r   Nr   )	rf   rn   r   r   r   r   r   	Extensionr   )
r   EXTENSION_FIELDSr   r   labelsext_argsfieldr   macrosmacrora   ra   rb   r     s@   
r   c                 C   s.   d| vri S t dt dd | d  D S )z0Process the [entry_points] section of setup.cfg.r   zThe 'entry_points' section has been deprecated in favour of the '[options.entry_points]' section (if using 'setup.cfg') or the '[project.scripts]' and/or '[project.entry-points.{name}]' sections (if using 'pyproject.toml')c                 S   s   i | ]	\}}|t |qS ra   )r   )r_   r   r   ra   ra   rb   
<dictcomp>  s    z$get_entry_points.<locals>.<dictcomp>)r   r   r   r   )r   ra   ra   rb   r     s   
r   c                 C   s$   || v r|| | v r| | | S dS )NFra   )r   r   r   ra   ra   rb   r     s   r   c                 C   "   dd dd |  dD D } | S )z3Special behaviour when we have a multi line optionsc                 S   s   g | ]}|r| d s|qS )#)
startswithr_   elementra   ra   rb   rc     s    z#split_multiline.<locals>.<listcomp>c                 s       | ]}|  V  qd S Nr	  )r_   r   ra   ra   rb   	<genexpr>      z"split_multiline.<locals>.<genexpr>r   rf   r   ra   ra   rb   r        r   c                 C   r  )z8Special behaviour when we have a comma separated optionsc                 S   s   g | ]}|r|qS ra   ra   r  ra   ra   rb   rc     s    zsplit_csv.<locals>.<listcomp>c                 s   r  r  r	  )r_   chunkra   ra   rb   r    r  zsplit_csv.<locals>.<genexpr>,r  r  ra   ra   rb   	split_csv  r  r"  c           
   	   C   s  t | drdS d| _|sdS t|trtj|}ntjd}tj|s-t	d| zt
|| j}W n tyS   t d }td td||jj|f w d	}|r| D ]H\}}t | jd
| rst| jd
| | q\t | j|rt| j|| q\t | |rt| || q\||v rt| j|| q\dt| }	t|	 q\z
t| j|   W n ty   | jjd |  Y nw t| jjt t!f rt"| jj| j_dS dS )a6  Implements the 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.
    _pbr_initializedNTr{   z%The setup.cfg file %s does not exist.rj   zError parsingzError parsing %s: %s: %s)r!   r   r8   set_zUnknown distribution option: %srk   )#hasattrr#  
isinstancer
   rd   rg   r   r   r   r   r   r   r   r   r   logging	exceptionDistutilsSetupError	__class____name__r   r   rr   setattrreprr   r   superfinalize_optionsr   	__bases__r   r	   floatstr)
r   attrr   rg   attrsr   _DISTUTILS_UNSUPPORTED_METADATAr   valmsgra   ra   rb   r     sT   



r   )r{   Nr  )0
__future__r   r   multiprocessingrq   r'  r   rd   r   re   r   r   r   	distutilsr   r   r   r   r   r   pbr._compat.fiver   r	   r
   pbr._compatr   r   r   r   r   compiler   r   r   r   r   r   r   rh   rz   r   r   r   r   r   r   r   r"  ra   ra   ra   rb   <module>   s   0
-	!%&'(,048AZ

h
 ]8

