
    e"                     4   d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZ ddl
mZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ d Z G d dej        ej        ej        ej                   Z!e"dk    r ej#                     dS dS )z$Tests for distutils.command.install.    N)captured_stdoutrequires_subprocess)	sysconfig)installHAS_USER_SITE)r   )	build_ext)INSTALL_SCHEMES)Distribution)DistutilsOptionError)	Extension)supportc                 0    | t          j        d          z   S )N
EXT_SUFFIX)r   get_config_var)modnames    .  /home/conda/feedstock_root/build_artifacts/python-split_1708115622739/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.11/distutils/tests/test_install.py_make_ext_namer      s    Y-l;;;;    c                        e Zd Z fdZ fdZd Z ej        ed          d             Z	d Z
d Zd Z e            d	             Zd
 Z xZS )InstallTestCasec                     t                                                       t          t          j                  | _        d S N)supersetUpdictr   _config_vars_backup_config_varsself	__class__s    r   r   zInstallTestCase.setUp    s-    #'	(>#?#?   r   c                     t                                                       t          j                                         t          j                            | j                   d S r   )r   tearDownr   r   clearupdater   r   s    r   r"   zInstallTestCase.tearDown$   sN    $$&&&%%d&>?????r   c           	                                            }t          j                            |d          }t	          ddi          }t          j                            |d          |_        t          j        |t          j                            |d                    |j        d<   t          |          }||_
        |                                                      |j        |                                |j        |            fd}t          j                            |dd	          } ||j        |           t          j                            |t           j        d	          } ||j        |            ||j        |            ||j        t          j                            |d
d	d                      ||j        t          j                            |d                      ||j        |           d S )Ninstallationnamefoopkgzsetup.pylib)
build_base	build_libbuildc                     t           j                            |           } t           j                            |          }                    | |           d S r   )ospathnormpathassertEqual)gotexpectedr   s     r   
check_pathzAInstallTestCase.test_home_installation_scheme.<locals>.check_path?   sI    '""3''Cw''11HS(+++++r   pythonincludebin)mkdtempr.   r/   joinr
   script_namer   DummyCommandcommand_objr   homeensure_finalizedr1   install_baseinstall_platbaseinstall_libsys
platlibdirinstall_platlibinstall_purelibinstall_headersinstall_scriptsinstall_data)r   builddirdestinationdistcmdr4   libdirrC   s   `       r   test_home_installation_schemez-InstallTestCase.test_home_installation_scheme)   s    <<>>gll8^<<VX.//7<<*==$+$8gll8U33% % %!
 dmm);777-{;;;	, 	, 	, 	, 	,
 k5(;;
3?F+++W\\+s~xHH

3&
333
3&///
3&7<<Y(KK	M 	M 	M
3&[%(H(HIII
3#[11111r   zneed user sitec                 p    t           j         _        t           j         _                                          _        t          j        	                     j        d           _
        t          j        	                     j        d           _         j
        t           _         j        t           _         j
        t          _         j        t          _         fd}t          j        j         _        |t          j        _         fd}                     |           t           r dD ]}                     |t$                     t'          ddi          }t)          |          }d |j        D             }                     d	|           d
|_                             t          j                             j
                                                  t          j                             j                             |                                                      t          j                             j
                                                  t          j                             j                                                  d|j                                        d|j                   d S )NBSc                     j         S r   )tmpdir)r/   r   s    r   _expanduserz3InstallTestCase.test_user_site.<locals>._expanduser\   s    ;r   c                       j         t          _         j        t          _         j         t
          _         j        t
          _         j        t          j        _	        d S r   )
old_user_basesite	USER_BASEold_user_site	USER_SITEinstall_module
old_expandr.   r/   
expanduser)r   s   r   cleanupz/InstallTestCase.test_user_site.<locals>.cleanupa   s?    !/DN!/DN'+'9N$'+'9N$!%BGr   )nt_user	unix_userr'   xxc                     g | ]\  }}}|	S  rc   ).0r'   shortlables       r   
<listcomp>z2InstallTestCase.test_user_site.<locals>.<listcomp>r   s+     % % %.D%4 % % %r   user   userbaseusersite)rW   rX   rV   rZ   rY   r8   rS   r.   r/   r9   	user_base	user_siter[   r]   r\   
addCleanupr   assertInr	   r
   r   user_optionsrh   assertFalseexistsr>   
assertTrueconfig_vars)r   rT   r^   keyrK   rL   optionss   `      r   test_user_sitezInstallTestCase.test_user_siteN   s:    "^!^llnndk377dk377#'> #'> 	 	 	 	 	',(	1 	1 	1 	1 	1 	    	4/ 4 4c?3333VTN++dmm% %#% % %fg&&&  	7788877888 	 	t~66777t~66777j#/222j#/22222r   c                 &   t          ddd          }t          |          }|                                 |                     |j        ddg           |                     |j        d           |                     |j        d           dg|_        |                                 |                     |j        dg           |                     |j        d           |                     |j        d           d x|_        |_        |                                 |                     |j        d            |                     |j        d           |                     |j        d            d|_        |                     t          |j                   d S )Nra   z	path,dirs)r'   
extra_pathr/   dirs zpath,dirs,again)	r
   r   handle_extra_pathr1   ry   
extra_dirs	path_fileassertRaisesr   r   rK   rL   s      r   test_handle_extra_pathz&InstallTestCase.test_handle_extra_path   s}   TEEFFdmm 	&&)9:::000/// !&222000/// ,0/#....,,,--- +.0EFFFFFr   c                 Z   t          ddi          }t          |          }d|_        d|_        |                     t
          |j                   d |_        d|_        |                     t
          |j                   d |_        d|_        |                     t
          |j                   d S )Nr'   ra   prefixbaser=   rh   )	r
   r   r   r?   r   r   finalize_optionsr=   rh   r   s      r   test_finalize_optionsz%InstallTestCase.test_finalize_options   s    VTN++dmm 
!.0DEEE  .0DEEE 
.0DEEEEEr   c                 0   |                                  }|                     dgdg          \  }}t          j        |           |                     dd           |                     dd           t          |          }||j        d<   ||_        t          j        	                    |d          |_
        |                                 |                                 t          |j
                  }	 |                                }|                                 n# |                                 w xY wd	 |                                D             }dd
t"          j        j        z  ddt"          j        d d         z  g}|                     ||           d S )Nhellosayhi)
py_modulesscriptszhello.pyzdef main(): print('o hai')zfrom hello import main; main()r   filelistc                 L    g | ]!}t           j                            |          "S rc   r.   r/   basenamerd   lines     r   rg   z/InstallTestCase.test_record.<locals>.<listcomp>   (    IIID!!$''IIIr   zhello.%s.pycUNKNOWN-0.0.0-py%s.%s.egg-info   )r8   create_distr.   chdir
write_filer   r<   rootr/   r9   recordr>   runopenreadclose
splitlinesrB   implementation	cache_tagversion_infor1   )	r   install_dirproject_dirrK   rL   fcontentfoundr3   s	            r   test_recordzInstallTestCase.test_record   sv   llnn ,,	6=Y - @ @T

$@AAA!ABBBdmm&)#W\\+z::
				ffhhGGGIIIIAGGIIIIIIG4F4F4H4HIII1C1M M4s7G7KKM 	)))))s   3D D2c                    t          j                    }||                     d|z             |                                 }|                     t          ddg          g          \  }}t          j        |           t          j	        |           t          |          }t          j        |           |                                 t          |          }||j        d<   ||j        d<   ||_        t          j                            |d          |_        |                                 |                                 t)          |j                  }	 |                                }|                                 n# |                                 w xY wd |                                D             }t1          d          d	t2          j        d d
         z  g}	|                     ||	           d S )NzThe %r command is not foundra   z
xxmodule.c)ext_modulesr   r   r   c                 L    g | ]!}t           j                            |          "S rc   r   r   s     r   rg   z:InstallTestCase.test_record_extensions.<locals>.<listcomp>   r   r   r   r   )test_supportmissing_compiler_executableskipTestr8   r   r   r.   r   r   copy_xxmodule_cr   fixup_build_extr>   r   r<   r   r/   r9   r   r   r   r   r   r   r   rB   r   r1   )
r   rL   r   r   rK   buildextcmdr   r   r   r3   s
             r   test_record_extensionsz&InstallTestCase.test_record_extensions   s   688?MM7#=>>>llnn ,,d\N++:-, . .T
,,,oo,,,$$&&&dmm&)#(3%W\\+z::
				ffhhGGGIIIIAGGIIIIIIG4F4F4H4HIII"4((4s7G7KKM)))))s   E? ?Fc                 H   t          | j                  }dt          _        	 t	                      5  |                                  d d d            n# 1 swxY w Y   dt          _        n# dt          _        w xY w|                     t          | j                  |           d S )NTF)lenlogsr[   DEBUGr   r   assertGreater)r   old_logs_lens     r   test_debug_modezInstallTestCase.test_debug_mode   s    49~~#	) "" # #  """# # # # # # # # # # # # # # # $)N  5N ((((3ty>><88888s.   A) AA) AA) AA) )A7)__name__
__module____qualname__r   r"   rN   unittest
skipUnlessr   rw   r   r   r   r   r   r   __classcell__)r    s   @r   r   r      s        
@ @ @ @ @@ @ @ @ @
#2 #2 #2J X(89963 63 :963pG G G8F F F** * *6 * * *B	9 	9 	9 	9 	9 	9 	9r   r   __main__)$__doc__r.   rB   r   rW   test.supportr   r   	distutilsr   distutils.command.installr   r   distutils.commandr[   distutils.command.build_extr   r	   distutils.corer
   distutils.errorsr   distutils.extensionr   distutils.testsr   testr   r   TempdirManagerEnvironGuardLoggingSilencerTestCaser   r   mainrc   r   r   <module>r      s~   * * 				 



   = = = = = = = =       < < < < < < < < 7 7 7 7 7 7 1 1 1 1 1 1 5 5 5 5 5 5 ' ' ' ' ' ' 1 1 1 1 1 1 ) ) ) ) ) ) # # # # # # ( ( ( ( ( (< < <c9 c9 c9 c9 c9g,*-'c9 c9 c9L zHMOOOOO r   