3 F\%[4@sdZy ddlZWnek r$YnXddlZddlmZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddlZddlmZddlmZy ddlZWnek rddlZYnXddlmZddlZejd ZdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhd#ZdiZdjZdkZfZd1d2Zd3ffd4d5Z ffd6d7Z!d8d9Z"d:d;Z#dd?Z%d@dAZ&dBdCZ'GdDdEdEeZ(dS)laThe 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)errors)log)dist) extension) extra_filesz\s*(.*?)\s*\((.*)\)\s*$metadata home_pagesummary descriptiondescription_content_type classifierplatform requires_distsetup_requires_dist provides_distobsoletes_distfiles packages_rootmodulesglobalcommandsbackwards_compatuse_2to3zip_safe tests_require)#nameversionauthor author_email maintainermaintainer_emailurl project_urlsr keywordslong_descriptionZlong_description_content_type download_url classifiers platformslicenseinstall_requiressetup_requiresZpython_requiresprovidesprovides_extras obsoletes package_dirpackages package_datanamespace_packages data_filesscripts py_modulescmdclassrrrdependency_linksinclude_package_datar'r(r*r,r.r2r0r1r3r4r5r7r+r$r6r-r#r8c Cs|jd}t|d}|d|}|d}xf|dkrytdj||gd}PWq,tk r|dkrh|d8}|d|}||}d}Yq,Xq,Wx@||dD]0}yt||}Wqtk rt|YqXqW|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_nameretpartrK]/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/pbr/pbr/util.py resolve_names*     rMz setup.cfgcCs4tjdkrtj}ntj}tjj|s>tj dtjj |y|j |ddWnt k rn|j |YnXi}xF|j D]:}t||<x*|j|D]\}}||||jdd<qWq~Wt|dd }t|d d }|rtjj |}tjjd |z&|rd dt|D}x|D]} t| } y | |Wnjtk rLtjdYnLtk rtjd} tjd| | ftjtjtjdYnXqWtjj|t ||} d| d<d| d<t!|t"|} | r| | d<t#|}|r|| d<t|d d}|rt$j%t|Wd|r.tjj&d X| S)aDistutils2 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 path: The setup.cfg path. :param script_args: List of commands setup.py was called with. :raises DistutilsFileError: When the setup.cfg file is not found. zfile '%s' does not existzutf-8)encoding-_r setup_hooksrrrcSsg|]}|dkr|qS)zpbr.hooks.setup_hookrK).0hookrKrKrL szcfg_to_args..z)setup hook %s terminated the installationr:z#setup hook %s raised exception: %s Tr8Fr ext_modules entry_pointsrN)rNrO)'sys version_info configparser ConfigParserSafeConfigParserospathexistsrDistutilsFileErrorabspathread TypeErrorsectionsdictitemsreplacehas_get_optioninsertsplit_multilinerM SystemExitrerror Exceptionexc_info traceback format_excexitpbrhooksZ setup_hooksetup_cfg_to_setup_kwargsregister_custom_compilersget_extension_modulesget_entry_pointsrZset_extra_filespop)r_ script_argsparserconfigsectionkvaluerSr/rUZhook_fnekwargsrWrXZfiles_extra_filesrKrKrL cfg_to_argssh              rc( Cszi}i}xtD]}tt|dkr4t|\}}n tt|dkrTt|d}|}t|||}|s|dkrt||d}|rt|}d}x8|D]0} t| } z|| jjd7}Wd| jXqW|}nq|tkrt |}|t krt|}nj|t kr4i} x2t|D]&} | j d d\} }|j| | j<qW| }n"|t krV|jd)krRd}nd}|r|d*krtdd|D}|dkrg}d}xD|D]<}tj||}|jdj}|jdj}|j||fqW||d<n*|dkrd|i}n|d+kri}d}d}x|D]}d |krr|j d d\}}|j|j}}||kr\||}|j|j n|j }||j<n(|rtjd|n|j|jj d}q W|dkr|j}|}nF|dkri}tj}x*|D]"}t|}||}|||j<qW|}|||<qWd|krd}|d}d|krXdd lm} d!j| j| jj d"d#|d<xh|D]`}!g}"t||!}#x@|#D]8}tj||}|jdj}$|jd}|"j|$|fqxW|"||!<q^Wi}%x|D]}&x||&D]z\}}|r.z6(?P[^;]*);?(?P[^#]*?)(?:\s*#.*)?$package env_markerr/r1r3z1malformed package_data first line %r (misses "=")r6extrasz6(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$test) packaging ;: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-markersextras_require)rrrrr)r*r)r1r3)(D1_D2_SETUP_ARGSr?rirkopenrcstripclose CSV_FIELDS split_csv MULTI_FIELDS MAP_FIELDSr> BOOL_FIELDSlowerrematchgroupappendextendrDistutilsOptionErrorrgst_dist DistributionrMget_command_namersrrAparse_requirementsZTEST_REQUIREMENTS_FILESrh pkg_resourcesevaluate_marker SyntaxErrorrrm setdefaultry)(r|rzrZall_requirementsargr}optionZ in_cfg_valuerfilenamerZ in_cfg_mapir~vr*Zrequirement_pattern requirementmZrequirement_packagerr3 firstlineprevlinekeyr6rZcls_nameclscmdrrextraZextra_requirements requirementsZ extras_valuerZ req_groupZ extras_keyrKrKrLru!s                                   rucCst|dd}|rt|}xx|D]p}t|}t|dr<|j}n|j}t|drT|j}nd|}|j}tj j }||j|f||<t j |t j d|<qWdS)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 compilersrr zcustom compiler %sz distutils.N) rirkrMhasattrr__name__r __module__ distutilsZ ccompilerZcompiler_classrYr)r|rcompilerrdescrGccrKrKrLrvs    rvc Cs:d}g}x*|D] }d|kr,|jdd}n |jdd}dd|D}t|dko\|ddkri}x|D]}t|||}|s~qht|}|dkrg}xX|D]P} | jdd} t| dkr| djdf} n| dj| djf} |j| qW|}|||<qhW|rd|kr|d|d<|jtj|jdf|qW|S)zHandle extension modulessources include_dirs define_macros undef_macros library_dirs librariesruntime_library_dirs extra_objectsextra_compile_argsextra_link_argsexport_symbols swig_optsdependsrr:rcSsg|] }|jqSrK)r)rTlrKrKrLrVsz)get_extension_modules..rOrrNr) rrrrrrrrrrrrr) r>r?rirkrrr Extensionry) r|ZEXTENSION_FIELDSrWr}labelsZext_argsfieldrmacrosmacrorKrKrLrwsT           rwcCs&d|kr iStdd|djDS)aProcess the [entry_points] section of setup.cfg. Processes 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. rXcss|]\}}|t|fVqdS)N)rk)rTrrrKrKrL Asz#get_entry_points..)rfrg)r|rKrKrLrx6srxcCs(||kr |||kr |||SdSdS)NFrK)r|r}rrKrKrLriEs ricCs"dddd|jdDD}|S)z3Special behaviour when we have a multi line optionscSs g|]}|r|jd r|qS)#) startswith)rTelementrKrKrLrVOsz#split_multiline..css|]}|jVqdS)N)r)rTrrKrKrLrPsz"split_multiline..r)r>)rrKrKrLrkLsrkcCs"dddd|jdDD}|S)z8Special behaviour when we have a comma separated optionscSsg|] }|r|qSrKrK)rTrrKrKrLrVXszsplit_csv..css|]}|jVqdS)N)r)rTchunkrKrKrLrYszsplit_csv..,)r>)rrKrKrLrUsrcs"eZdZdZdfdd ZZS)DefaultGetDictzDLike defaultdict, but get() also sets and returns the default value.Ncs"|dkr|j}tt|j||S)N)default_factorysuperrr)selfrdefault) __class__rKrLgetbszDefaultGetDict.get)N)rr __qualname____doc__r __classcell__rKrK)rrLr_sr)r)r)r)r)r)r)rr )r)rr )r)rr )rr )r)rr )rr)r)rr)rr)r)rr)r)rr)rr)r)r)r)r)r)rr)rr)rr)rr)rr)r)r)r'r(r*r,r.r2r0r1r3r4r5r7r+rr$r6r-)r#)rrr8))rmultiprocessingrBlogging collectionsrr^rrYrpdistutils.ccompilerrrrr setuptoolsrrrr\r[rsrZ pbr.hookscompilerrrrrrrMrrurvrwrxrirkrrrKrKrKrL5s          ^ >#5