a „oe¯ã@sˆdZddlZddlZddlZddlZddlZddlmZddlZ gZ dd„Z dd„Z dd „Z d d „Zd d „Zdd„Zdd„Zdd„ZdS)z Monkey patching of distutils. éN)Ú import_modulecCs"t ¡dkr|f|jSt |¡S)am Returns the bases classes for cls sorted by the MRO. Works around an issue on Jython where inspect.getmro will not return all base classes if multiple classes share the same name. Instead, this function will return a tuple containing the class itself, and the contents of cls.__bases__. See https://github.com/pypa/setuptools/issues/1024. ZJython)ÚplatformZpython_implementationÚ __bases__ÚinspectZgetmro)Úcls©rú2C:\Program Files\Certbot\pkgs\setuptools\monkey.pyÚ_get_mros  r cCs.t|tƒrtnt|tjƒrtndd„}||ƒS)NcSsdS)Nr)ÚitemrrrÚ*ózget_unpatched..)Ú isinstanceÚtypeÚget_unpatched_classÚtypesÚ FunctionTypeÚget_unpatched_function)r ÚlookuprrrÚ get_unpatched$sÿ ÿûrcCs:dd„t|ƒDƒ}t|ƒ}|j d¡s6d|}t|ƒ‚|S)z•Protect against re-patching the distutils if reloaded Also ensures that no other distutils extension monkeypatched the distutils first. css|]}|j d¡s|VqdS)Ú setuptoolsN)Ú __module__Ú startswith)Ú.0rrrrÚ 5sz&get_unpatched_class..Ú distutilsz(distutils has already been patched by %r)r ÚnextrrÚAssertionError)rZexternal_basesÚbaseÚmsgrrrr/sÿ rcCsÒddl}|jtj_tjdk}|r*|jtj_dtjko>dknp\dtjkoXdkn}|rpd}|tjj _ t ƒtj tjtj fD]}|j j|_q†|jjtj_|jjtj_dtjvrÈ|jjtjd_tƒdS)Nr)éér)ré)rr!é)rr zhttps://upload.pypi.org/legacy/zdistutils.command.build_ext)rZCommandrZcoreÚsysÚ version_infoÚfindallZfilelistZconfigZ PyPIRCCommandZDEFAULT_REPOSITORYÚ_patch_distribution_metadataÚdistÚcmdZ DistributionÚ extensionZ ExtensionÚmodulesÚ#patch_for_msvc_specialized_compiler)rZhas_issue_12885Zneeds_warehouseZ warehouseÚmodulerrrÚ patch_all?s0   ýý      þÿr-cCs4ddlm}dD]}t||ƒ}ttjj||ƒqdS)Né)Ú_core_metadata)Zwrite_pkg_infoZwrite_pkg_fileZ read_pkg_fileZget_metadata_version)Úr/ÚgetattrÚsetattrrr'ZDistributionMetadata)r/ÚattrÚnew_valrrrr&es  r&cCs*t||ƒ}t|ƒ d|¡t|||ƒdS)zž Patch func_name in target_mod with replacement Important - original must be resolved by name to avoid patching an already patched function. Ú unpatchedN)r1ÚvarsÚ setdefaultr2)Z replacementZ target_modÚ func_nameZoriginalrrrÚ patch_funcss r9cCs t|dƒS)Nr5)r1)Ú candidaterrrr„srcsXtdƒ‰t ¡dkrdS‡fdd„}t |d¡}zt|dƒŽWntyRYn0dS)z\ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. zsetuptools.msvcZWindowsNcs@d}|| d¡}tˆ|ƒ}t|ƒ}t||ƒs6t|ƒ‚|||fS)zT Prepare the parameters for patch_func to patch indicated function. Zmsvc14_Ú_)Úlstripr1rÚhasattrÚ ImportError)Úmod_namer8Z repl_prefixZ repl_nameÚreplÚmod©ZmsvcrrÚ patch_params”s  z9patch_for_msvc_specialized_compiler..patch_paramszdistutils._msvccompilerZ _get_vc_env)rrÚsystemÚ functoolsÚpartialr9r>)rCZmsvc14rrBrr+ˆs   r+)Ú__doc__rErrr#rÚ importlibrZdistutils.filelistrÚ__all__r rrr-r&r9rr+rrrrÚs   &