U V.a @sdZz ddlZWnek r$YnXddlZddlZddlZddlZddlZddlm Z ddl Z ddl m Z ddl mZmZmZddlmZddlmZddlmZz ddlZWnek rddlZYnXdd lmZddlZed Zd d d d d d d d d dd ddd ddddddddddddddddddZdZdZ d Z!d!d"Z"d@d$d%Z#d&d'Z$d(d)Z%d*d+Z&d,d-Z'd.d/Z(d0d1Z)d2d3Z*d4d5Z+d6d7Z,d8d9Z-d:d;Z.Gdd?d?e0Z1dS)AaThe 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)DistutilsOptionErrorDistutilsModuleErrorDistutilsFileError)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)rmodules)globalcommands)backwards_compatuse_2to3)rzip_safe)r tests_require)r)nameversionauthor author_email maintainermaintainer_emailurlrkeywordslong_descriptionz download-url classifiers platformslicenseinstall_requiressetup_requiresprovides obsoletes package_dirpackages package_datanamespace_packages data_filesscripts py_modulescmdclassrrrdependency_linksinclude_package_data)r'r(r*r,r-r1r/r0r2r3r4r6r+rr5)rrr7)r%c Cs|d}t|d}|d|}|d}|dkrztd||gd}WqWq*tk r|dkrh|d8}|d|}||}d}Yq*Xq*||dD]0}zt||}Wqtk rt|YqXq|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)splitlen __import__join ImportErrorgetattrAttributeError)rpartscursor module_name attr_nameretpartrJ9/opt/alt/python38/lib/python3.8/site-packages/pbr/util.py resolve_names*     rL setup.cfgc Cst}tj|s(tdtj|||i}|D]}t | |||<q>t |dd}t |dd}|rtj|}t j d|z|r&ddt|D}|D]x}t|}z ||Wqtk rtd Yqt d }td ||fttt d YqXqtj|t|} d | d <d| d<t|t|} | rh| | d<t|} | r~| | d<t| t |dd} | rt !t| W5|rt jdX| 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. zfile '%s' does not existr setup_hooksrrrcSsg|]}|dkr|qS)zpbr.hooks.setup_hookrJ).0hookrJrJrK szcfg_to_args..z)setup hook %s terminated the installationr9z#setup hook %s raised exception: %s Tr7Fr ext_modules entry_pointsr )" configparserSafeConfigParserospathexistsrabspathreadsectionsdictitemshas_get_optionsysinsertpopsplit_multilinerL SystemExitrerrorexc_info traceback format_excexitpbrhooks setup_hooksetup_cfg_to_setup_kwargsregister_custom_compilersget_extension_modulesget_entry_points wrap_commandsr set_extra_files) rWparserconfigsectionrNr.rPhook_fnekwargsrRrSfiles_extra_filesrJrJrK cfg_to_argssd           ryc" Csi}i}tD]}tt|dkr0t|\}}n tt|dkrPt|d}|}t|||}|s|dkr t||d}|rt|}d}|D]0}t|} z|| d7}W5| Xq|}nq |tkrt |}|t krt|}n"|t kr| dkrd }nd }|r|d kr$d d |D}|dkrg} d} |D]<} t | | } | d}| d}| ||fq:| |d<n|dkrd|i}n|dkrbi}d }d}|D]}d|kr|dd\}}||}}||kr||}||n|}||<n&|r0td|n||d }q|dkr\|}|}n@|dkri}t}|D]"}t|}||}|||<qz|}|||<q d|kr$d} |d}|D]\}g}t||}|D]8} t | | } | d}| d}|||fq|||<qi}|D]D} || D]4\} }|rTd| |f}!n| }!||!g| q8q,|dg|d<||d<|S)zqProcesses the setup.cfg options and converts them to arguments accepted by setuptools' setup() function. r9rr&description_filer<z )truet1yesyTF)r*rcSsg|]}td|qS)z\1\2)_VERSION_SPEC_REsub)rOpredrJrJrKrQKsz-setup_cfg_to_setup_kwargs..r*z6(?P[^;]*);?(?P[^#]*?)(?:\s*#.*)?$package env_markerr.)r0r2N=z1malformed package_data first line %r (misses "=")r2r5extrasz6(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$z%s:(%s)extras_require)D1_D2_SETUP_ARGSr>r^rbopencloserZstrip CSV_FIELDS split_csv MULTI_FIELDS BOOL_FIELDSlowerrematchgroupappendr=extendrr]rrLget_command_name setdefaultra)"rsrwall_requirementsargrtoption in_cfg_valuevaluefilenamer{r*requirement_pattern requirementmrequirement_packagerr2 firstlineprevlinekeyr5distcls_nameclscmdrextraextra_requirements requirements extras_valuer req_group extras_keyrJrJrKrls                      rlcCst|dd}|rt|}|D]p}t|}t|dr:|j}n|j}t|drR|j}nd|}|j}tj j }||j|f||<t j |t j d|<qdS)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 compilersrrzcustom compiler %sz distutils.N) r^rbrLhasattrr__name__r __module__ distutils ccompilercompiler_classr_r)rsrcompilerrdescrFccrJrJrKrms   rmc Cs(d}g}|D]}d|kr(|dd}n |dd}dd|D}t|dkr |dd kr i}|D]}t|||}|sxqbt|}|d krg}|D]P} | dd} t| dkr| dd f} n| d| df} || q|}|||<qb|r d |kr |d|d <|t|d f|q |S) zHandle extension modules) sources include_dirs define_macros undef_macros library_dirs librariesruntime_library_dirs extra_objectsextra_compile_argsextra_link_argsexport_symbols swig_optsdepends:r9rcSsg|] }|qSrJr)rOlrJrJrKrQsz)get_extension_modules..rzr extensionrNr)r=r>r^rbrrr ra) rsEXTENSION_FIELDSrRrtlabelsext_argsfieldrmacrosmacrorJrJrKrns>         rncCs&d|kr iStdd|dDS)aProcess 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. rScss|]\}}|t|fVqdSN)rb)rOrrrJrJrK sz#get_entry_points..)r\r])rsrJrJrKros  roc Cst}||D]\}}i}||D]H\}}|d}|dsT|dr0|dd\}}||i} || |<q0|sqd|kr||dkr|d|} n ||} t || |} | |di|<qdS)Nr9z pre_hook.z post_hook.r8r5) rparse_config_filesget_command_listget_option_dictr] startswithr=rget_command_class wrap_command) rwrr_rjoptval hook_typealias hook_dictr5 new_cmdclassrJrJrKrps"    rpc Cs2|fdd}t||tf|t|d|ddS)NcSs"|d|||ddS)Npre_hook post_hook)run_command_hooksrun)selfr5rJrJrKr2s  zwrap_command..runrr)rrrr)typeobjectrget)rr5rjrrJrJrKr1s  rc Cs|dkrtd|t||d}|dkr,dS|D]}t|trz t|}Wqtk r~td}t d||fYqXn|}t |dst d|t d|||z ||Wq4td}t d ||ft ttdYq4Xq4dS) zRun hooks registered for that command and phase. *cmd_obj* is a finalized command object; *hook_kind* is either 'pre_hook' or 'post_hook'. )rrzinvalid hook kind: %rNr9zcannot find hook %s: %s__call__zhook %r is not callablezrunning %s %s for command %szhook %s raised exception: %s ) ValueErrorrBvalues isinstancestrrLrAr_rerrrrinforrdrfrgrh)cmd_obj hook_kindrjrPhook_objerrrvrJrJrKr=s:          rcCsX||kr |||kr |||S||krP|dd||krP|||ddSdSdS)Nr-Freplace)rsrtrrJrJrKr^fs  r^cCs"dddd|dDD}|S)z3Special behaviour when we have a multi line optionscSsg|] }|r|qSrJrJrOelementrJrJrKrQrsz#split_multiline..css|]}|VqdSrr)rOrrJrJrKrssz"split_multiline.. r=rrJrJrKrbosrbcCs"dddd|dDD}|S)z8Special behaviour when we have a comma separated optionscSsg|] }|r|qSrJrJrrJrJrKrQ{szsplit_csv..css|]}|VqdSrr)rOchunkrJrJrKr|szsplit_csv..,rrrJrJrKrxsrcsfdd}|S)z[A function decorator to monkey-patch a method of the same name on the given class. cs:t|jd}|r6t|ds6t|d|t|j||S)N_orig)rBrrsetattr)funcorigrrJrKwrappers  z#monkeypatch_method..wrapperrJ)rrrJrrKmonkeypatch_methods rcs"eZdZdZdfdd ZZS)DefaultGetDictzXLike defaultdict, but the get() method also sets and returns the default value. Ncs"|dkr|}tt|||Sr)default_factorysuperrr)rrdefault __class__rJrKrszDefaultGetDict.get)N)rr __qualname____doc__r __classcell__rJrJrrKrsrcs(eZdZdZddZfddZZS) 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 '*'. cCs$tdddd|D|_dS)Nz(%s)|cSsg|]}|ddqS)*z.*r)rOpatrJrJrKrQsz'IgnoreDict.__init__..)rcompiler@_IgnoreDict__ignore)rignorerJrJrK__init__s  zIgnoreDict.__init__cs&|j|rdStt|||dSr)rrrr  __setitem__)rrrrrJrKrs zIgnoreDict.__setitem__)rrr r rrr rJrJrrKr sr )rM)2r multiprocessingrAloggingrVrr_rf collectionsrdistutils.ccompilerrrdistutils.errorsrrrsetuptools.command.egg_inforsetuptools.distrsetuptools.extensionr ConfigParserrTrir pbr.hooksrrrrrrrLryrlrmrnrorprrr^rbrrrr\r rJrJrJrK.s          ' V"5 )