Re@sdZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl Z gZ ddZdd Zd d Zd d ZddZddZddZddZddZdS)z Monkey patching of distutils. N) import_module)sixcCs-tjdkr |f|jStj|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)clsr /builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/monkey.py_get_mros rcCsFt|tjrtn!t|tjr0tn dd}||S)NcSsdS)Nr )itemr r r *szget_unpatched..) isinstancer class_typesget_unpatched_classtypes FunctionTypeget_unpatched_function)rlookupr r r get_unpatched&s rcCsQddt|D}t|}|jjdsMd|}t||S)zProtect against re-patching the distutils if reloaded Also ensures that no other distutils extension monkeypatched the distutils first. css'|]}|jjds|VqdS) setuptoolsN) __module__ startswith).0r r r r 6sz&get_unpatched_class.. distutilsz(distutils has already been patched by %r)rnextrrAssertionError)r Zexternal_basesbasemsgr r r r/s    rcCsNtjtj_tjd k}|r3tjtj_tjd kpd tjko\dknpdtjko{dknpdtjkodkn}|rd }|tjj _ t t x/tj tjtjfD]}tj j|_qWtjjtj_tjjtj_d tjkrCtjjtjd _tdS)N rzhttps://upload.pypi.org/legacy/zdistutils.command.build_ext)r#r$r#)r%r&r')r#r)r#r#r&)r#r()r#r(r))r#r$)r#r$r#)rCommandrcoresys version_infofindallfilelistconfig PyPIRCCommandDEFAULT_REPOSITORY+_patch_distribution_metadata_write_pkg_file+_patch_distribution_metadata_write_pkg_infodistcmd Distribution extension Extensionmodules#patch_for_msvc_specialized_compiler)Zhas_issue_12885Zneeds_warehouseZ warehousemoduler r r patch_allAs(r=cCstjjtjj_dS)zDPatch write_pkg_file to also write Requires-Python/Requires-ExternalN)rr5write_pkg_filerDistributionMetadatar r r r r3ksr3cCsLdtjddko$dkn}|s3dStjjtjj_dS)z Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local encoding to save the pkg_info. Monkey-patch its write_pkg_info method to correct this undesirable behavior. r#Nr%)r#)r#r%r%)r,r-rr5write_pkg_inforr?)Zenvironment_localr r r r4rs)r4cCs9t||}t|jd|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)getattrvars setdefaultsetattr) replacementZ target_mod func_nameoriginalr r r patch_funcsrIcCs t|dS)NrA)rB) candidater r r rsrcstdtjdkr"dSfdd}tj|d}tj|d}y$t|dt|d Wntk rYnXyt|d Wntk rYnXyt|d Wntk rYnXdS) z\ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. zsetuptools.msvcWindowsNcsnd|krdnd}||jd}t|}t|}t||sat||||fS)zT Prepare the parameters for patch_func to patch indicated function. msvc9Zmsvc9_Zmsvc14__)lstriprBrhasattr ImportError)mod_namerGZ repl_prefixZ repl_namereplmod)msvcr r patch_paramss  z9patch_for_msvc_specialized_compiler..patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ _get_vc_envZgen_lib_options)rrsystem functoolspartialrIrP)rUrLZmsvc14r )rTr r;s&     r;)__doc__r,distutils.filelistrrrrWr Z py26compatrZsetuptools.externrr__all__rrrr=r3r4rIrr;r r r r s&          *