U âQab�ã@sœdZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl Z gZ dd„Zdd„Zd d „Zd d „Zd d„Zdd„Zdd„Zdd„ZdS)z Monkey patching of distutils. éN)Ú import_module)ÚsixcCs"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ú5/usr/lib/python3.8/site-packages/setuptools/monkey.pyÚ_get_mros  r cCs0t|tjƒrtnt|tjƒr tndd„}||ƒS)NcSsdS)Nr)Úitemrrr Ú*ózget_unpatched..)Ú isinstancerZ class_typesÚ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 Ú 5s þz&get_unpatched_class..Ú distutilsz(distutils has already been patched by %r)r ÚnextrrÚAssertionError)rZexternal_basesÚbaseÚmsgrrr r/sþ rcCsÔtjtj_tjdk}|r"tjtj_tjdkp^dtjko@dknp^dtjkoZdkn}|rrd}|tjj _ t ƒtj tjtj fD]}tj j|_qˆtjjtj_tjjtj_dtjkrÊtjjtjd_tƒdS)N)éé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)Zhas_issue_12885Zneeds_warehouseZ warehouseÚmodulerrr Ú patch_allAs*    þû     ÿ r0cCs*dD] }ttj|ƒ}ttjj||ƒqdS)zDPatch write_pkg_file and read_pkg_file for higher metadata standards)Zwrite_pkg_fileZ read_pkg_fileZget_metadata_versionN)Úgetattrrr*ÚsetattrrZDistributionMetadata)ÚattrZnew_valrrr r)hs 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_nameÚoriginalrrr Ú patch_funcos r9cCs t|dƒS)Nr4)r1)Ú candidaterrr r€srcs¾tdƒ‰t ¡dkrdS‡fdd„}t |d¡}t |d¡}zt|dƒŽt|d ƒŽWntk rlYnXzt|d ƒŽWntk r’YnXzt|d ƒŽWntk r¸YnXdS) z\ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. zsetuptools.msvcZWindowsNcsLd|kr dnd}|| d¡}tˆ|ƒ}t|ƒ}t||ƒsBt|ƒ‚|||fS)zT Prepare the parameters for patch_func to patch indicated function. Úmsvc9Zmsvc9_Zmsvc14_Ú_)Úlstripr1rÚhasattrÚ ImportError)Zmod_namer7Z repl_prefixZ repl_nameÚreplÚmod©Zmsvcrr Ú patch_params�s  z9patch_for_msvc_specialized_compiler..patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ _get_vc_envZgen_lib_options)rrÚsystemÚ functoolsÚpartialr9r?)rCr;Zmsvc14rrBr r.„s&    r.)Ú__doc__r&Zdistutils.filelistrrrrEÚ importlibrrZsetuptools.externrrÚ__all__r rrr0r)r9rr.rrrr Ús$   '