
    e                         d Z ddlZddlZddl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  G d d	ej        ej        ej                  Zed
k    r ej                     dS dS )z%Tests for distutils.command.build_py.    N)build_py)Distribution)DistutilsFileError)support)requires_subprocessc                       e Zd Zd Zd Z ej        ej        d           e	            d                         Z
 ej        ej        d           e	            d                         Zd Zd ZdS )	BuildPyTestCasec                 "   |                                  }t          t          j                            |d          d          }	 |                    d           |                                 n# |                                 w xY wt          t          j                            |d          d          }	 |                    d           |                                 n# |                                 w xY w|                                  }t          dgd|id          }t          j                            |d          |_        t          j
        d	|
          |j        d<   dg|_        ddgi|_        d|i|_        t          |          }d|_        |                                 |                     |j        |j                   |                                 |                     t)          |                                          d           t          j                            |d          }t          j        |          }t          j                            |d          }|                     d|           |                     d|           t0          j        r4|                     t          j                            |                     d S t          j        |          }	|                     dt0          j        j        z  |	           d S )N__init__.pywz# Pretend this is a package.z
README.txtzInfo about this packagepkg)packagespackage_dirsetup.pyr   )force	build_libbuild      __pycache__z__init__.%s.pyc)mkdtempopenospathjoinwritecloser   script_namer   DummyCommandcommand_objr   package_datar   r   compileensure_finalizedassertEqualrunlenget_outputslistdirassertInsysdont_write_bytecodeassertFalseexistsimplementation	cache_tag)
selfsourcesfdestinationdistcmdpkgdestfilespycache_dir	pyc_filess
             /  /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_build_py.pytest_package_dataz!BuildPyTestCase.test_package_data   s   ,,..g}55s;;	GG2333GGIIIIAGGIIIIg|44c::	GG-...GGIIIIAGGIIIIllnn%-2G,<> > ? ? 7<<<<$+$8!%# %# %#! "\N3!7+tnn)4+<===			
 	S__..//333',,{E22
7##gll7M::mU+++lE***" 	%RW^^K8899999
;//IMM+c.@.JJ#% % % % %s   A. .B6C   C6c                    |                                  }t          t          j                            |d          d                                           t          j                            |d          }t          j        |           t          t          j                            |d          d                                           t          j        |           t          dgddiddgid          }t          j                            |d	          |_	        d
g|_
        |                                 	 |                                 d S # t          $ r |                     d           Y d S w xY w)Nr   r   doctestfiler    doc/*)r   r   r!   r   r   z/failed package_data test when package_dir is '')r   r   r   r   r   r   mkdirchdirr   r   script_argsparse_command_linerun_commandsr   fail)r0   r1   testdirr4   s       r:   test_empty_package_dirz&BuildPyTestCase.test_empty_package_dirD   s]   ,,..RW\\'=11377==???',,w..
RW\\':..44::<<<
%-2BK.3gY-?A A B B 7<<<<#9!!!	I! 	I 	I 	IIIGHHHHHH	Is   8E E10E1zbyte-compile disabledc                 T   |                      dg          \  }}t          j        |           |                     dd           t	          |          }d|_        d|_        |                                 |                                 t          j	        |j                  }| 
                    t          |          ddg           t          j	        t          j                            |j        d                    }| 
                    |dt          j        j        z  g           d S )	N
boiledeggs
py_modulesboiledeggs.pyimport antigravityr   herer   zboiledeggs.%s.pyc)create_distr   rB   
write_filer   r"   r   finalize_optionsr%   r(   r$   sortedr   r   r*   r.   r/   )r0   project_dirr4   r5   founds        r:   test_byte_compilez!BuildPyTestCase.test_byte_compile[   s    !,,,GGT
)=>>>tnn			
3=))(HIII
27<<}EEFF-0B0LLM	O 	O 	O 	O 	O    c                    |                      dg          \  }}t          j        |           |                     dd           t	          |          }d|_        d|_        d|_        |                                 |	                                 t          j
        |j                  }|                     t          |          ddg           t          j
        t          j                            |j        d                    }d	                    t           j        j                  }|                     t          |          |g           d S )
NrJ   rK   rM   rN   r   r   rO   r   zboiledeggs.{}.opt-1.pyc)rP   r   rB   rQ   r   r"   optimizer   rR   r%   r(   r$   rS   r   r   formatr*   r.   r/   )r0   rT   r4   r5   rU   expects         r:   test_byte_compile_optimizedz+BuildPyTestCase.test_byte_compile_optimizedm   s    !,,,GGT
)=>>>tnn			
3=))(HIII
27<<}EEFF*11#2D2NOO11111rW   c                    |                                  }t          j                            |d          }t          j        |           t          t          j                            |d          d                                           t          j                            |d          }t          j        |           t          t          j                            |d          d                                           t          j        t          j                            |d                     t          j        |           t          dgddgid          }t          j                            |d	          |_	        d
g|_
        |                                 	 |                                 dS # t          $ r |                     d           Y dS w xY w)zR
        A directory in package_data should not be added to the filelist.
        r   r   r   r=   r>   otherdirr@   )r   r!   r   r   z0failed package_data when data dir includes a dirN)r   r   r   r   rA   r   r   rB   r   r   rC   rD   rE   r   rF   )r0   r1   pkg_dirdocdirr4   s        r:   test_dir_in_package_dataz(BuildPyTestCase.test_dir_in_package_data   s   
 ,,..',,w..
RW\\'=11377==???gu--
RW\\&*--s3399;;; 	fj11222
%.3gY-?A A B B 7<<<<#9!!!	J! 	J 	J 	JIIHIIIIII	Js   F1 1GGc                    |                                  d         }t          |          }d|_        d|_        t          j        }dt          _        	 |                    g            |t          _        n# |t          _        w xY w|                     d| j        d         d         | j        d         d         z             d S )Nr   Tzbyte-compiling is disabledr      )	rP   r   r"   rY   r*   r+   byte_compiler)   logs)r0   r4   r5   old_dont_write_bytecodes       r:   test_dont_write_bytecodez(BuildPyTestCase.test_dont_write_bytecode   s    !!!$tnn"%"9"&	>R   &=C##&=C#====2il1o	!Q7	9 	9 	9 	9 	9s   A3 3BN)__name__
__module____qualname__r;   rH   unittestskipIfr*   r+   r   rV   r\   ra   rg    rW   r:   r	   r	      s        /% /% /%bI I I. X_S,.EFFO O  GFO  X_S,.EFF2 2  GF2"J J J>9 9 9 9 9rW   r	   __main__)__doc__r   r*   rk   distutils.command.build_pyr   distutils.corer   distutils.errorsr   distutils.testsr   test.supportr   TempdirManagerLoggingSilencerTestCaser	   rh   mainrm   rW   r:   <module>ry      s    + + 				 



  / / / / / / ' ' ' ' ' ' / / / / / / # # # # # # , , , , , ,_9 _9 _9 _9 _9g,-'_9 _9 _9D zHMOOOOO rW   