
    h                         d Z ddl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d Z e             dS )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                   d     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                 d    t                                                       d | _        d | _        d S Nsuperinitialize_optionsprefix_optioninstall_layoutself	__class__s    ,/usr/lib/python3.11/_distutils_system_mod.pyr   zinstall.initialize_options    /    ""$$$!"    c                    |dk    r| j         rK| j                                         dv rd}n| j                                         dv rd}nt          d          | j        r(t          j                            | j                  dk    st                      rd}nFt          j                            | j                  dk    rdx| _        | _	        dx| _
        | _        d}t                                          |           d S )	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9'DD(..00H<<)DD.<> > >% %7##DK00L@@+-- A%7##DK00L@@5;;DK$"2@FFD%(=$d#####r   c                 `    | j         | _        t                                                       d S r
   )r#   r   r   finalize_unixr   s    r   r+   zinstall.finalize_unix:   s)    ![r   )__name__
__module____qualname__listorig_installr   user_optionsr   r(   r+   __classcell__r   s   @r   r   r      s        4,9::	D> L
# # # # #
$ $ $ $ $*                 r   r   c                   p     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                 d    t                                                       d | _        d | _        d S r
   r   r   s    r   r   z#install_egg_info.initialize_optionsD   r   r   c                     |                      dd           |                      dd           t                                                       d S )Nr   )r   r   )r   r   )set_undefined_optionsr   finalize_optionsr   s    r   r9   z!install_egg_info.finalize_optionsI   sM    ""9-PQQQ""9-NOOO  """""r   c                    | j         rH| j                                         dvrt          d          | j                                         dk    }n| j        rd}nd}|rkt	          t          | j                                                            dt	          t          | j        	                                                    d}n~dt	          t          | j                                                            t	          t          | j        	                                                    gt          j        d d	         R 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.basenameN   sF    	&,,../AA*8: : :+1133u<HH 	HHH 
	Id&7&@&@&B&BCCDDDDL):)F)F)H)HIIJJJJHH
 0Id&7&@&@&B&BCCDDL):)F)F)H)HIIJJ3 !"1"%3 3 H
 r   )r,   r-   r.   r/   orig_install_egg_infor5   r1   r   r9   propertyrC   r2   r3   s   @r   r5   r5   ?   s        4->KLL>P L# # # # #
# # # # #
   X    r   r5   c                  `    t           j        t           j        k    pt          t           d          S )Nreal_prefix)r@   base_prefixr#   hasattr r   r   r$   r$   g   s     ?cj(GGC,G,GGr   c                     | p t           j                            |          dv }| r|S |r0t                      s"t           j                            |ddd          S t           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   k   sz    ((dBG,<,<\,J,JNd,d 8	 8#9#;#; 8w||FE9oFFFw||I777r   c                     d|vrL| dk    r	|d         }nt           j        d         d         }| dk    rd|vr|                    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   u   sp     >!!Y'GG"2>B9MG=  Yg%=%=ook3DE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                  p                 } |                                  D ]\  }}t          ||           | S r
   )itemsrZ   )schemesr)   rY   _load_schemess      r   wrapped_load_schemesz2load_schemes_wrapper.<locals>.wrapped_load_schemes   sA    -//#MMOO 	* 	*LD&D&))))r   rJ   )r_   r`   s   ` r   load_schemes_wrapperra      s$    
    
  r   c                 j    dD ]/}|| vr)t          j        |d          }t          ||          | |<   0dS )zR
    Ensure that the custom schemes we refer to above are present in schemes.
    )r   r   r   F)expandN)	sysconfig	get_pathsrZ   )r^   r)   rY   s      r   add_debian_schemesrf      sQ     > : :w(e<<<F+D&99GDM: :r   c                  l   t           t          _         t          t          _        t          t
          j        _        t          t          d          rt          t          _        d S t          t          d          r%t          t          j
                  t          _
        d S t          t          j                   d S )NrZ   r_   )r   r0   r5   rD   rS   	distutilsrd   rI   rZ   ra   r_   rf   rW   rJ   r   r   apply_customizationsri      s    "L-=*%/I"|.// 
9'6$$$		/	/ 9%9,:T%U%U"""
 	<788888r   )__doc__r    r@   rd   distutils.sysconfigrh   distutils.command.installcommandr   r0   "distutils.command.install_egg_infor5   rD   r   r   r   distutils.errorsr   r$   rS   rZ   ra   rf   ri   rJ   r   r   <module>rp      s    
			 



         0 0 0 0 0 0 0 0 0 B B B B B B B B B         
 2 1 1 1 1 1"  "  "  "  " l" "  "  " J% % % % %,= % % %PH H H8 8 8  ,
  
  
 : : :9 9 9$       r   