
    RhT                         d Z ddlZddlZddlZddlmc mZ ddl	mc m
Z ddl	mZmZmZ ddlmZ  G d dej                        Z G d dej                        Z
d	 Zd
 Zd Zd Zd Z e        y)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)DistutilsOptionErrorc                   r     e Zd Z eej
                  j                        dgz   Z fdZ fdZ fdZ	 xZ
S )install)zinstall-layout=Nz7installation layout to choose (known values: deb, unix)c                 >    t         |           d | _        d | _        y Nsuperinitialize_optionsprefix_optioninstall_layoutself	__class__s    ,/usr/lib/python3.12/_distutils_system_mod.pyr   zinstall.initialize_options       "$!"    c                    |dk(  r| j                   rI| j                   j                         dv rd}n| j                   j                         dv rd}nt        d      | j                  r,t        j
                  j                  | j                        dk7  s
t               rd}nJt        j
                  j                  | j                        dk(  rdx| _        | _	        dx| _
        | _        d}t        | 5  |       y )	Nposix_prefix)deb
deb_system)unix"unknown value for --install-layout
/usr/local/usrposix_local)r   lowerr   r   ospathnormpathprefixis_virtual_environmentexec_prefixinstall_baseinstall_platbaser   select_scheme)r   namer   s     r   r(   zinstall.select_scheme$   s    >!""&&,,.'9'D((..0H<)D.<> >%%77##DKK0L@+-%77##DKK0L@5;;DK$"2@FFD%(=$d#r   c                 D    | j                   | _        t        |           y r
   )r#   r   r   finalize_unixr   s    r   r+   zinstall.finalize_unix9   s    ![[r   )__name__
__module____qualname__listorig_installr   user_optionsr   r(   r+   __classcell__r   s   @r   r   r      s=    ,,99:	D> L
#
$*   r   r   c                   x     e Zd Z eej
                  j                        dgz   Z fdZ fdZe	d        Z
 xZS )install_egg_info)zinstall-layoutNzcustom installation layoutc                 >    t         |           d | _        d | _        y r
   r   r   s    r   r   z#install_egg_info.initialize_optionsC   r   r   c                 j    | j                  dd       | j                  dd       t        | 	          y )Nr   )r   r   )r   r   )set_undefined_optionsr   finalize_optionsr   s    r   r9   z!install_egg_info.finalize_optionsH   s0    ""9-PQ""9-NO "r   c                 h   | j                   rE| j                   j                         dvrt        d      | j                   j                         dk(  }n| j                  rd}nd}|r^t	        t        | j                  j                                     dt	        t        | j                  j                                     d}|S dt	        t        | j                  j                                     t	        t        | j                  j                                     gt        j                  d d	 z  }|S )
N)r   r   r   r   FT-z	.egg-infoz%s-%s-py%d.%d.egg-info   )r   r   r   r   r   r   distributionget_namer   get_versionsysversion_info)r   no_pyverbasenames      r   rC   zinstall_egg_info.basenameM   s   &&,,./A*8: :++113u<HHHId&7&7&@&@&BCDL):):)F)F)HIJH  0Id&7&7&@&@&BCDL):):)F)F)HIJ3 !!"1%3 H
 r   )r,   r-   r.   r/   orig_install_egg_infor5   r1   r   r9   propertyrC   r2   r3   s   @r   r5   r5   >   sF    ->>KKL>P L#
#
  r   r5   c                  h    t         j                  t         j                  k7  xs t        t         d      S )Nreal_prefix)r@   base_prefixr#   hasattr r   r   r$   r$   f   s!    ??cjj(GGC,GGr   c                     | xs! t         j                  j                  |      dv }| r|S |r,t               s"t         j                  j	                  |ddd      S t         j                  j	                  |d      S )N)r   r   libpython3zdist-packageszsite-packages)r    r!   r"   r$   join)standard_lib	libpythonearly_prefixr#   is_default_prefixs        r   
_posix_librS   j   se    ((dBGG,<,<\,JNd,d	#9#;ww||FE9oFFww||I77r   c                     d|vrA| dk(  r|d   }nt         j                  d   d   }| dk(  rd|vr|j                  dd      }||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
    headersr   includer   z/local/z	/include/z/local/include/)r0   INSTALL_SCHEMESreplace)r)   schemerU   s      r   _inject_headersrZ   t   sb     >!Y'G"22>B9MG= Yg%=ook3DEG#yMr   c                       fd}|S )z
    Implement the _inject_headers modification, above, but before
    _inject_headers() was introduced, upstream. So, slower and messier.
    c                  ^            } | j                         D ]  \  }}t        ||        | S r
   )itemsrZ   )schemesr)   rY   _load_schemess      r   wrapped_load_schemesz2load_schemes_wrapper.<locals>.wrapped_load_schemes   s2    /#MMO 	*LD&D&)	*r   rJ   )r_   r`   s   ` r   load_schemes_wrapperra      s    

  r   c                     t         t        _         t        t        _        t        t
        j                  _        t        t        d      rt        t        _        y t        t        d      r#t        t        j                        t        _
        y y )NrZ   r_   )r   r0   r5   rD   rS   	distutils	sysconfigrI   rZ   ra   r_   rJ   r   r   apply_customizationsre      sV    "L-=*%/I"|./'6$		/%9,:T:T%U" 
0r   )__doc__r    r@   distutils.sysconfigrc   distutils.command.installcommandr   r0   "distutils.command.install_egg_infor5   rD   r   r   r   distutils.errorsr   r$   rS   rZ   ra   re   rJ   r   r   <module>rl      sz    
 
  0 0 B B 
 2" l"" " J%,== %PH8,
 
V  r   