U Qab@sdZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl Z gZ ddZddZd d Zd d Zd dZddZddZddZdS)z Monkey patching of distutils. N) import_module)sixcCs"tdkr|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)clsr5/usr/lib/python3.8/site-packages/setuptools/monkey.py_get_mros  r cCs0t|tjrtnt|tjr tndd}||S)NcSsdS)Nr)itemrrr *zget_unpatched..) isinstancerZ class_typesget_unpatched_classtypes FunctionTypeget_unpatched_function)r lookuprrr get_unpatched&s rcCs:ddt|D}t|}|jds6d|}t||S)zProtect against re-patching the distutils if reloaded Also ensures that no other distutils extension monkeypatched the distutils first. css|]}|jds|VqdS) setuptoolsN) __module__ startswith).0rrrr 5s z&get_unpatched_class.. distutilsz(distutils has already been patched by %r)r nextrrAssertionError)rZexternal_basesbasemsgrrr r/s rcCstjtj_tjdk}|r"tjtj_tjdkp^dtjko@dknp^dtjkoZdkn}|rrd}|tjj _ t tj tjtj fD]}tj j|_qtjjtj_tjjtj_dtjkrtjjtjd_tdS)N)r) )r)rr$)rr zhttps://upload.pypi.org/legacy/zdistutils.command.build_ext)rZCommandrZcoresys version_infofindallZfilelistZconfigZ PyPIRCCommandZDEFAULT_REPOSITORY_patch_distribution_metadatadistcmdZ Distribution extensionZ Extensionmodules#patch_for_msvc_specialized_compiler)Zhas_issue_12885Zneeds_warehouseZ warehousemodulerrr 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)r1vars setdefaultr2)Z replacementZ target_mod func_nameoriginalrrr patch_funcos r9cCs t|dS)Nr4)r1) candidaterrr rsrcstdtdkrdSfdd}t|d}t|d}zt|dt|d Wntk rlYnXzt|d Wntk rYnXzt|d Wntk rYnXdS) 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__)lstripr1rhasattr ImportError)Zmod_namer7Z repl_prefixZ repl_namereplmodZmsvcrr patch_paramss  z9patch_for_msvc_specialized_compiler..patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ _get_vc_envZgen_lib_options)rrsystem functoolspartialr9r?)rCr;Zmsvc14rrBr r.s&    r.)__doc__r&Zdistutils.filelistrrrrE importlibrrZsetuptools.externrr__all__r rrr0r)r9rr.rrrr s$   '