o [d@sdZddlZddlZddlZddlZddlmmZ ddl mm Z ddl m Z mZmZddlmZGddde jZGddde j Z d d Zd d Zd dZddZddZddZedS)a Apply Debian-specific patches to distutils commands. Extracts the customized behavior from patches as reported in pypa/distutils#2 and applies those customizations (except for scheme definitions) to those commands. Place this module somewhere in sys.path to take effect. N) to_filename safe_name safe_version)DistutilsOptionErrorcsFeZdZeejjdgZfddZfddZfddZ Z S)install)zinstall-layout=Nz7installation layout to choose (known values: deb, unix)ctd|_d|_dSNsuperinitialize_options prefix_optioninstall_layoutself __class__,/usr/lib/python3.10/_distutils_system_mod.pyr   zinstall.initialize_optionscs|dkrH|jr|jdvrd}n7|jdvrd}n-td|jr+tj|jdks.tr1d}ntj|jdkrFd|_|_ d|_ |_ d}t |dS) N posix_prefix)deb deb_system)unix"unknown value for --install-layout /usr/local/usr posix_local)r lowerrr ospathnormpathprefixis_virtual_environment exec_prefix install_baseinstall_platbaser select_scheme)rnamerrrr&%s&  zinstall.select_schemecs|j|_tdSr)r!r r finalize_unixrrrrr(:szinstall.finalize_unix) __name__ __module__ __qualname__list orig_installr user_optionsr r&r( __classcell__rrrrrs   rcsFeZdZeejjdgZfddZfddZe ddZ Z S)install_egg_info)zinstall-layoutNzcustom installation layoutcrrr rrrrr Drz#install_egg_info.initialize_optionscs&|dd|ddtdS)Nr)r r )r r )set_undefined_optionsr finalize_optionsrrrrr2Is  z!install_egg_info.finalize_optionscCs|jr|jdvrtd|jdk}n|jrd}nd}|r6dtt|jtt|j f}|Sdtt|jtt|j gt j ddR}|S) N)rrrrFTz%s-%s.egg-infoz%s-%s-py%d.%d.egg-info) r rrr rr distributionget_namer get_versionsys version_info)rno_pyverbasenamerrrr:Ns,  zinstall_egg_info.basename) r)r*r+r,orig_install_egg_infor0r.r r2propertyr:r/rrrrr0?s   r0cCstjtjkp ttdS)N real_prefix)r7 base_prefixr!hasattrrrrrr"gsr"cCsH| p tj|dv}|r|S|rtstj|dddStj|dS)N)rrlibpython3z dist-packagesz site-packages)rrr r"join) standard_lib libpython early_prefixr!is_default_prefixrrr _posix_libks  rGcCsPd|vr&|dkr |d}ntjdd}|dkr"d|vr"|dd}||d<|S)aN Given a scheme name and the resolved scheme, if the scheme does not include headers, resolve the fallback scheme for the name and use headers from it. pypa/distutils#88 headers: module headers install location (posix_local is /local/ prefixed) include: cpython headers (Python.h) See also: bpo-44445 headersrincluderz/local/z /include/z/local/include/)r-INSTALL_SCHEMESreplace)r'schemerHrrr_inject_headersus   rMcsfdd}|S)z Implement the _inject_headers modification, above, but before _inject_headers() was introduced, upstream. So, slower and messier. cs&}|D] \}}t||q|Sr)itemsrMschemesr'rL _load_schemesrrwrapped_load_schemess z2load_schemes_wrapper..wrapped_load_schemesr)rRrSrrQrload_schemes_wrappers rTcCs2dD]}||vrtj|dd}t||||<qdS)zR Ensure that the custom schemes we refer to above are present in schemes. )rrrF)expandN) sysconfig get_pathsrMrOrrradd_debian_schemess rXcCsPtt_tt_ttj_ttdrtt_dSttdr!t tj t_ dSt tj dS)NrMrR) rr-r0r;rG distutilsrVr?rMrTrRrXrJrrrrapply_customizationss   rZ)__doc__rr7rVdistutils.sysconfigrYdistutils.command.installcommandrr-"distutils.command.install_egg_infor0r;rrrdistutils.errorsrr"rGrMrTrXrZrrrrs$  %(