Viewing File: /opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/monkey.cpython-35.pyc



\@sdZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlZgZ
ddZdd	Zd
dZd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.
    ZJython)platformZpython_implementation	__bases__inspectZgetmro)clsr	
/monkey.py_get_mros	rcCsFt|tjrtn!t|tjr0tn	dd}||S)NcSsdS)Nr	)itemr	r	r
<lambda>*szget_unpatched.<locals>.<lambda>)
isinstancerZclass_typesget_unpatched_classtypesFunctionTypeget_unpatched_function)rlookupr	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).0rr	r	r
	<genexpr>6sz&get_unpatched_class.<locals>.<genexpr>	distutilsz(distutils has already been patched by %r)rnextrrAssertionError)rZexternal_basesbasemsgr	r	r
r/s	
rcCsNtjtj_tjdk}|r3tjtj_tjdkpd
tjko\dknpdtjko{dknpdtjkodkn}|rd	}|tjj	_
ttx/tj
tjtjfD]}tj
j|_qWtjjtj_tjjtj_d
tjkrCtjjtjd
_tdS)N
rzhttps://upload.pypi.org/legacy/zdistutils.command.build_ext)rr r)r!r"r#)rr)rrr")rr$)rr$r%)rr )rr r)rZCommandrZcoresysversion_infofindallZfilelistconfigZ
PyPIRCCommandZDEFAULT_REPOSITORY+_patch_distribution_metadata_write_pkg_file+_patch_distribution_metadata_write_pkg_infodistcmdZDistribution	extensionZ	Extensionmodules#patch_for_msvc_specialized_compiler)Zhas_issue_12885Zneeds_warehouseZ	warehousemoduler	r	r
	patch_allAs(r2cCstjjtjj_dS)zDPatch write_pkg_file to also write Requires-Python/Requires-ExternalN)rr,Zwrite_pkg_filerDistributionMetadatar	r	r	r
r*ksr*cCsLdtjddko$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.
    rNr!)r)rr!r!)r&r'rr,Zwrite_pkg_inforr3)Zenvironment_localr	r	r
r+rs)r+cCs9t||}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)ZreplacementZ
target_mod	func_nameZoriginalr	r	r

patch_funcsr:cCs
t|dS)Nr4)r5)	candidater	r	r
rsrcstdtjdkr"dSfdd}tj|d}tj|d}y$t|dt|d	Wntk
rYnXyt|d
Wntk
rYnXyt|dWntk
rYnXdS)z\
    Patch functions in distutils to use standalone Microsoft Visual C++
    compilers.
    zsetuptools.msvcZWindowsNcsnd|krdnd}||jd}t|}t|}t||sat||||fS)zT
        Prepare the parameters for patch_func to patch indicated function.
        msvc9Zmsvc9_Zmsvc14__)lstripr5rhasattrImportError)Zmod_namer9Zrepl_prefixZ	repl_namereplmod)msvcr	r
patch_paramssz9patch_for_msvc_specialized_compiler.<locals>.patch_paramszdistutils.msvc9compilerzdistutils._msvccompilerZfind_vcvarsallZquery_vcvarsallZ_get_vc_envZgen_lib_options)rrsystem	functoolspartialr:r@)rDr<Zmsvc14r	)rCr
r0s&



r0)__doc__r&Zdistutils.filelistrrrrFrZ
py26compatrZsetuptools.externrr__all__rrrr2r*r+r:rr0r	r	r	r
<module>s&	*
Back to Directory File Manager