B
7x
@ s d Z ddlZddlZddlZddlZddlZddlmZ ddl Z ddl
Z
g Zdd Zdd Z
dd Zd
d Zdd
Zdd Zdd Zdd ZdS )z
Monkey patching of distutils.
N)
import_modulec C s" t dkr| f| j S t| 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)cls r
/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el9.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/monkey.py_get_mro s r c C s. t | trtnt | tjrtndd }|| S )Nc S s d S )Nr
)itemr
r
r ( zget_unpatched..)
isinstancetypeget_unpatched_classtypesFunctionTypeget_unpatched_function)r
lookupr
r
r
get_unpatched$ s r c C s: dd t | D }t|}|jds6d| }t||S )zProtect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
c s s | ]}|j d s|V qdS )
setuptoolsN)
__module__
startswith).0r r
r
r 4 s z&get_unpatched_class.. distutilsz(distutils has already been patched by %r)r nextr r AssertionError)r Zexternal_basesbasemsgr
r
r r - s r c C s t jtj_tjdk} | r"t jtj_tjdk p^dtj k o@dk n p^dtj k oZdkn }|rrd}|tjj _
t x"tjtjtj
fD ]}t jj|_qW t jjtj_t jjtj_dtjkrt jjtjd _t d S )N) r" )
)r" )r" r' )r" r# zhttps://upload.pypi.org/legacy/zdistutils.command.build_ext)r Commandr coresysversion_infofindallfilelistconfig
PyPIRCCommandDEFAULT_REPOSITORY_patch_distribution_metadatadistcmdDistribution extension Extensionmodules#patch_for_msvc_specialized_compiler)Zhas_issue_12885Zneeds_warehouseZ warehousemoduler
r
r patch_all? s$
r; c C s. x(dD ] } t tj| }ttjj| | qW dS )zDPatch write_pkg_file and read_pkg_file for higher metadata standards)write_pkg_file
read_pkg_fileZget_metadata_versionN)getattrr r3 setattrr DistributionMetadata)attrnew_valr
r
r r2 f s
r2 c C s* 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)r> vars
setdefaultr? )replacementZ
target_mod func_nameoriginalr
r
r
patch_funcm s
rI c C s
t | dS )NrC )r> ) candidater
r
r r ~ s r c s t d t dkrdS fdd} t| d}t| d}yt|d t|d W n tk
rl Y nX yt|d
W n tk
r Y nX yt|d W n tk
r Y nX dS )z\
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
zsetuptools.msvcWindowsNc sL d| krdnd}|| d }t |}t| }t||sBt||||fS )zT
Prepare the parameters for patch_func to patch indicated function.
msvc9Zmsvc9_Zmsvc14__)lstripr> r hasattrImportError)mod_namerG Zrepl_prefixZ repl_namereplmod)msvcr
r patch_params s
z9patch_for_msvc_specialized_compiler..patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ_get_vc_envZgen_lib_options)r r system functoolspartialrI rP )rU rL Zmsvc14r
)rT r r9 s&