3 K”Re�ã@s¤dZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl Z gZ dd„Zdd„Zd d „Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„ZdS)z Monkey patching of distutils. éN)Ú import_module)ÚsixcCs"tjƒdkr|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)ÚplatformÚpython_implementationÚ __bases__ÚinspectÚgetmro)Úcls©r ú‡/builddir/build/BUILDROOT/alt-python36-setuptools-38.5.2-7.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/setuptools/monkey.pyÚ_get_mros  r cCs0t|tjƒrtnt|tjƒr tndd„}||ƒS)NcSsdS)Nr )Úitemr r r Ú*szget_unpatched..)Ú isinstancerÚ class_typesÚget_unpatched_classÚtypesÚ FunctionTypeÚget_unpatched_function)rÚlookupr r r Ú get_unpatched&srcCs:dd„t|ƒDƒ}t|ƒ}|jjdƒs6d|}t|ƒ‚|S)z•Protect against re-patching the distutils if reloaded Also ensures that no other distutils extension monkeypatched the distutils first. css|]}|jjdƒs|VqdS)Ú setuptoolsN)Ú __module__Ú startswith)Ú.0r r r r ú 6sz&get_unpatched_class..Ú distutilsz(distutils has already been patched by %r)r ÚnextrrÚAssertionError)r Zexternal_basesÚbaseÚmsgr r r r/s  rcCsútjtj_tjd k}|r"tjtj_tjd kpxd tjko@dknpxdtjkoZdknpxdtjkotdkn}|rŒd }|tjj _ t ƒt ƒx"tj tjtjfD]}tj j|_qªWtjjtj_tjjtj_d tjk�rðtjjtjd _tƒdS)Nééééé réézhttps://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")rÚCommandrÚcoreÚsysÚ version_infoÚfindallÚfilelistÚconfigÚ PyPIRCCommandÚDEFAULT_REPOSITORYÚ+_patch_distribution_metadata_write_pkg_fileÚ+_patch_distribution_metadata_write_pkg_infoÚdistÚcmdÚ DistributionÚ extensionÚ ExtensionÚmodulesÚ#patch_for_msvc_specialized_compiler)Zhas_issue_12885Zneeds_warehouseZ warehouseÚmoduler r r Ú patch_allAs(        r<cCstjjtjj_dS)zDPatch write_pkg_file to also write Requires-Python/Requires-ExternalN)rr4Úwrite_pkg_filerÚDistributionMetadatar r r r r2ksr2cCs<dtjdd…kodkn}|s*dStjjtjj_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,rr4Úwrite_pkg_inforr>)Zenvironment_localr r r r3rs"r3cCs*t||ƒ}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)ÚgetattrÚvarsÚ setdefaultÚsetattr)Ú replacementZ target_modÚ func_nameÚoriginalr r r Ú patch_func�s rHcCs t|dƒS)Nr@)rA)Ú candidater r r r’srcs¾tdƒ‰tjƒdkrdS‡fdd„}tj|dƒ}tj|dƒ}yt|dƒŽt|d ƒŽWntk rlYnXyt|d ƒŽWntk r’YnXyt|d ƒŽWntk r¸YnXdS) z\ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. zsetuptools.msvcÚWindowsNcsLd|kr dnd}||jdƒ}tˆ|ƒ}t|ƒ}t||ƒsBt|ƒ‚|||fS)zT Prepare the parameters for patch_func to patch indicated function. Úmsvc9Zmsvc9_Zmsvc14_Ú_)ÚlstriprArÚhasattrÚ ImportError)Úmod_namerFZ repl_prefixZ repl_nameÚreplÚmod)Úmsvcr r Ú patch_params¢s  z9patch_for_msvc_specialized_compiler..patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ _get_vc_envZgen_lib_options)rrÚsystemÚ functoolsÚpartialrHrO)rTrKZmsvc14r )rSr r:–s&    r:)Ú__doc__r+Údistutils.filelistrrrrVÚ importlibrrZsetuptools.externrrÚ__all__r rrr<r2r3rHrr:r r r r Ús&   *