o
    5‘ðiâ  ã                   @   sp   d 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ZddlZe
jG dd„ de
jƒƒZdS )	z%Tests for distutils.command.build_py.é    N)Úbuild_py)ÚDistribution)ÚDistutilsFileError)Úsupportc                   @   s\   e Zd Zdd„ Zdd„ Zej d¡dd„ ƒZej d¡dd	„ ƒZ	d
d„ Z
dd„ Zdd„ ZdS )ÚTestBuildPyc           	      C   s:  |   ¡ }tj dddœ|¡ |   ¡ }tdgd|idœƒ}tj |d¡|_tj	d|d�|j
d	< dg|_dd
gi|_d|i|_t|ƒ}d|_| ¡  |j|jksPJ ‚| ¡  t| ¡ ƒdks^J ‚tj |d¡}t |¡}tj |d¡}d|v swJ ‚d
|v s}J ‚tjrŠtj |¡rˆJ ‚d S t |¡}dtjj› d�|v s›J ‚d S )Nz# Pretend this is a package.zInfo about this package)ú__init__.pyú
README.txtÚpkg)ÚpackagesÚpackage_dirúsetup.pyF)ÚforceÚ	build_libÚbuildr   Té   Ú__pycache__r   z	__init__.ú.pyc)ÚmkdtempÚjaracoÚpathr   r   ÚosÚjoinÚscript_namer   ÚDummyCommandÚcommand_objr
   Úpackage_datar   r   ÚcompileÚensure_finalizedÚrunÚlenÚget_outputsÚlistdirÚsysÚdont_write_bytecodeÚexistsÚimplementationÚ	cache_tag)	ÚselfÚsourcesÚdestinationÚdistÚcmdÚpkgdestÚfilesÚpycache_dirÚ	pyc_files© r0   úh/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/tests/test_build_py.pyÚtest_package_data   s>   þûÿ


zTestBuildPy.test_package_datac                 C   s”   |   ¡ }tj dddidœ|¡ t |¡ tdgddiddgidœƒ}tj |d¡|_dg|_	| 
¡  z| ¡  W d S  tyI   |  d	¡ Y d S w )
NÚ Útestfile©r   Údocr	   údoc/*)r
   r   r   r   r   z/failed package_data test when package_dir is ''©r   r   r   r   r   Úchdirr   r   r   Úscript_argsÚparse_command_lineÚrun_commandsr   Úfail©r'   r(   r*   r0   r0   r1   Útest_empty_package_dir<   s    
ýÿz"TestBuildPy.test_empty_package_dirzsys.dont_write_bytecodec                 C   s    | j dgd�\}}t |¡ |  dd¡ t|ƒ}d|_d|_| ¡  | ¡  t 	|j¡}t
|ƒddgks6J ‚t 	tj |jd¡¡}|dtjj› d	�gksNJ ‚d S )
NÚ
boiledeggs©Ú
py_modulesúboiledeggs.pyúimport antigravityTÚherer   úboiledeggs.r   )Úcreate_distr   r9   Ú
write_filer   r   r   Úfinalize_optionsr   r!   Úsortedr   r   r"   r%   r&   )r'   Úproject_dirr*   r+   Úfoundr0   r0   r1   Útest_byte_compileQ   s   
zTestBuildPy.test_byte_compilec                 C   s®   | j dgd�\}}t |¡ |  dd¡ t|ƒ}d|_d|_d|_| ¡  | 	¡  t 
|j¡}t|ƒddgks9J ‚t 
tj |jd¡¡}d	tjj› d
�}t|ƒ|gksUJ ‚d S )Nr@   rA   rC   rD   Fé   rE   r   rF   z
.opt-1.pyc)rG   r   r9   rH   r   r   Úoptimizer   rI   r   r!   rJ   r   r   r"   r%   r&   )r'   rK   r*   r+   rL   Úexpectr0   r0   r1   Útest_byte_compile_optimizeda   s   
z'TestBuildPy.test_byte_compile_optimizedc                 C   s”   |   ¡ }tj dddi dœdœi|¡ t |¡ tdgddgidœƒ}tj |d¡|_dg|_	| 
¡  z| ¡  W d
S  tyI   |  d	¡ Y d
S w )zR
        A directory in package_data should not be added to the filelist.
        r	   r3   )r4   Úotherdirr5   r7   )r
   r   r   r   z0failed package_data when data dir includes a dirNr8   r>   r0   r0   r1   Útest_dir_in_package_datas   s*   ýþÿ
õ
ÿz$TestBuildPy.test_dir_in_package_datac                 C   sb   |   ¡ d }t|ƒ}d|_d|_tj}dt_z
| g ¡ W |t_n|t_w d|jd jv s/J ‚d S )NrN   Tzbyte-compiling is disabledr   )	rG   r   r   rO   r"   r#   Úbyte_compileÚrecordsÚmessage)r'   Úcaplogr*   r+   Úold_dont_write_bytecoder0   r0   r1   Útest_dont_write_bytecode“   s   z$TestBuildPy.test_dont_write_bytecodec                 C   s´   |   ¡ }tj ddddiii|¡ t |¡ dddgddœ}t|ƒ}| d¡}| ¡  | 	¡ }t
|ƒd	ks7J ‚|d
 d }| tjd¡dksHJ ‚| ¡  tdd„ |jD ƒƒrXJ ‚dS )aU  
        Originally distutils implementation did not account for PEP 420
        and included warns for package directories that did not contain
        ``__init__.py`` files.
        After the acceptance of PEP 420, these warnings don't make more sense
        so we want to ensure there are not displayed to not confuse the users.
        Únsr	   z	module.pyr3   zns.pkgr   )Únamer
   r   r   rN   r   éÿÿÿÿú/zns/pkg/module.pyc                 s   s    � | ]}d |v od|v V  qdS )zpackage init filez	not foundNr0   )Ú.0Úmsgr0   r0   r1   Ú	<genexpr>Â   s   € 
ÿzCTestBuildPy.test_namespace_package_does_not_warn.<locals>.<genexpr>N)r   r   r   r   r   r9   r   Úget_command_objrI   Úfind_all_modulesr   ÚreplaceÚsepr   ÚanyÚmessages)r'   rW   ÚtmpÚattrsr*   r+   ÚmodulesÚmodule_pathr0   r0   r1   Ú$test_namespace_package_does_not_warn£   s$   	
ý
ÿz0TestBuildPy.test_namespace_package_does_not_warnN)Ú__name__Ú
__module__Ú__qualname__r2   r?   ÚpytestÚmarkÚskipifrM   rQ   rS   rY   rk   r0   r0   r0   r1   r      s    ,



 r   )Ú__doc__r   r"   Údistutils.command.build_pyr   Údistutils.corer   Údistutils.errorsr   Údistutils.testsr   Újaraco.pathr   ro   Úcombine_markersÚTempdirManagerr   r0   r0   r0   r1   Ú<module>   s    