~fUdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl Z e dZgZded< d Zdd Zd Zd Zd ZdZdZdZy)z Monkey patching of distutils. ) annotationsN) import_module)TypeVar_Tz list[str]__all__cztjdk(r|f|jzStj|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. Jython)platformpython_implementation __bases__inspectgetmro)clss Z/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/setuptools/monkey.py_get_mrors5%%'83v %% >># ct|trtn"t|tjrt nd}||S)NcyN)items rzget_unpatched../s$r) isinstancetypeget_unpatched_classtypes FunctionTypeget_unpatched_function)rlookups r get_unpatchedr )s> dD !  dE.. /$    $<rcdt|D}t|}|jjdsd|z}t ||S)zProtect against re-patching the distutils if reloaded Also ensures that no other distutils extension monkeypatched the distutils first. c3XK|]"}|jjdr|$yw) setuptoolsN) __module__ startswith).0rs r z&get_unpatched_class..:s&CNN,E,El,Ss ** distutilsz(distutils has already been patched by %r)rnextr$r%AssertionError)rexternal_basesbasemsgs rrr4sM }N  D ?? % %k 283>S!! Krc0ddl}|jtj_t tj tjtj fD]}|j j|_|jjtj_ |jjtj_ dtjvr,|jjtjd_ ty)Nrzdistutils.command.build_ext) r#Commandr(core_patch_distribution_metadatadistcmd Distribution extension Extensionsysmodules#patch_for_msvc_specialized_compiler)r#modules r patch_allr;Ds(//INN "..)..)--?(oo::@ *33==INN$.$8$8$B$BI!$ 3!**44 ) ')rcddlm} dD]3}t||}ttj j ||5y)N)_core_metadata)write_pkg_infowrite_pkg_file read_pkg_fileget_metadata_version get_fullname)r>getattrsetattrr(r2DistributionMetadata)r>attrnew_vals rr1r1[s8 N.$/ 33T7Crclt||}t|jd|t|||y)z Patch func_name in target_mod with replacement Important - original must be resolved by name to avoid patching an already patched function. unpatchedN)rEvars setdefaultrF) replacement target_mod func_nameoriginals r patch_funcrRjs5z9-H   h7 J ;/rc|jSr)rK) candidates rrr{s   rcddlmtjdk7ryfd}t j |d} t |dy#t$rYywxYw)z\ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. r=)msvcWindowsNcd}||jdz}t|}t|}t||s t ||||fS)zT Prepare the parameters for patch_func to patch indicated function. msvc14__)lstriprErhasattr ImportError)mod_namerP repl_prefix repl_namereplmodrVs r patch_paramsz9patch_for_msvc_specialized_compiler..patch_paramssW )"2"23"77 tY'H%sI&i( (S)##rzdistutils._msvccompiler _get_vc_env)rDrVr system functoolspartialrRr])rcmsvc14rVs @rr9r9sX I% $  |-F GF F=)*    sA AA)rrreturnr)__doc__ __future__rrfr r r7r importlibrtypingrdistutils.filelistr(rr__annotations__rr rr;r1rRrr9rrrrpsj# # T]   *. D0" r