o
    5‘ði‚H  ã                   @  sH  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZ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	e	jv Zd
d„ ZdddgdœZde›d�Zejdd„ ƒZdd„ Ze e!eg d¢ƒƒZ"ddgddgfddgg d¢fdddgdgfdg d ¢d!gfd"d#gg fd$d%gd&gfd'g d(¢d)gfd*d+d,gd-gfd.g d/¢g fd0g d1¢d2d3gfd4d5d6gg d7¢fd8g d9¢d:gfd;d<gg d=¢fgZ#d>e$d?< 	 ej% &d@dA„ e#D ƒ¡Z'ej(e'dB�dCdD„ ƒZ)ej% &dEdA„ e#D ƒ¡Z*ej(e*dB�dFdG„ ƒZ+dHdI„ Z,dJdK„ Z-G dLdM„ dMƒZ.G dNdO„ dOe.ƒZ/G dPdQ„ dQe.ƒZ0dS )Rzsdist testsé    )ÚannotationsN)ÚFileListÚegg_infoÚtranslate_pattern)ÚDistribution)ÚDALS)Úlog)ÚDistutilsTemplateErrorÚ__pypy__c                 C  s   |   dtj¡S )z"Converts '/' in a string to os.sepú/)ÚreplaceÚosÚsep)Ús© r   ú]/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/tests/test_manifest.pyÚmake_local_path   s   r   Úappz0.0)ÚnameÚversionÚpackagesz&from setuptools import setup

setup(**z)
c               	   c  sR   � t jt j} }t ¡ t ¡ t _t _zd V  W | |t _t _d S | |t _t _w ©N)ÚsysÚstdoutÚstderrÚioÚStringIO)Ú
old_stdoutÚ
old_stderrr   r   r   Úquiet,   s   €"r   c                 C  s   t | dƒ ¡  d S )NÚwb)ÚopenÚclose)Úfilenamer   r   r   Útouch6   s   r$   )ú
README.rstúMANIFEST.inúsetup.pyzapp.egg-info/PKG-INFOzapp.egg-info/SOURCES.txtz!app.egg-info/dependency_links.txtzapp.egg-info/top_level.txtzapp/__init__.pyÚfooÚbarÚfoobarúfoo/bar)zfoo/bar/bazz	./foo/barr(   z*.txtzfoo.txtzbar.txtzfoo/foo.txtz	dir/*.txt)zdir/foo.txtzdir/bar.txtzdir/.txtznotdir/foo.txtz*/*.pyzbin/start.pyzdocs/page-?.txtzdocs/page-9.txtzdocs/page-10.txtz
foo/**/bar)zfoo/bing/barzfoo/bing/bang/barr+   zfoo/abarzfoo/**zfoo/bar/bing.pyzfoo/xz/foo/xz**)Úxzabc/xyzz@nythingzpre[one]post)ÚpreopostÚprenpostÚpreepostÚprepostÚ
preonepostzhello[!one]worldÚhelloxworldÚhelloyworld)ÚhellooworldÚ
helloworldÚhellooneworldz
[]one].txt)zo.txtz].txtze.txtzone].txtzfoo[!]one]barÚfooybar)zfoo]barÚfooobarÚfooebarz&list[tuple[str, list[str], list[str]]]Útranslate_specsc                 c  s&   � | ]\}}}t t |¡|ƒV  qd S r   ©ÚzipÚ	itertoolsÚrepeat©Ú.0ÚpatternÚmatchesÚ
mismatchesr   r   r   Ú	<genexpr>€   ó
   € ÿ
ÿrD   )Úparamsc                 C  ó   t t| jƒS r   ©Úmapr   Úparam©Úrequestr   r   r   Úpattern_match†   ó   rM   c                 c  s&   � | ]\}}}t t |¡|ƒV  qd S r   r;   r?   r   r   r   rD   ‹   rE   c                 C  rG   r   rH   rK   r   r   r   Úpattern_mismatch‘   rN   rO   c                 C  s   | \}}t |ƒ |¡sJ ‚d S r   ©r   Úmatch)rM   rA   Útargetr   r   r   Útest_translated_pattern_match–   ó   rS   c                 C  s   | \}}t |ƒ |¡rJ ‚d S r   rP   )rO   rA   rR   r   r   r   Ú test_translated_pattern_mismatch›   rT   rU   c                   @  s   e Zd Zdd„ Zdd„ ZdS )ÚTempDirTestCasec                 C  s$   t  ¡ | _t ¡ | _t | j¡ d S r   )ÚtempfileÚmkdtempÚtemp_dirr   ÚgetcwdÚold_cwdÚchdir©ÚselfÚmethodr   r   r   Úsetup_method¡   s   

zTempDirTestCase.setup_methodc                 C  s   t  | j¡ t | j¡ d S r   )r   r\   r[   ÚshutilÚrmtreerY   r]   r   r   r   Úteardown_method¦   s   zTempDirTestCase.teardown_methodN)Ú__name__Ú
__module__Ú__qualname__r`   rc   r   r   r   r   rV       s    rV   c                      s|   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚTestManifestTestc                   sÆ   t ƒ  |¡ ttj | jd¡ddd�}| t¡ | 	¡  	 dD ]}t
tj | j|¡ƒ qtj | jd¡}t |¡ dD ]}t
tj ||¡ƒ q;tj |d¡}t |¡ d	D ]}t
tj ||¡ƒ qUd S )
Nr'   Úwúutf-8©Úencoding)r%   ú.hidden.rstútesting.rstÚLICENSEr   )z__init__.pyúa.txtúb.txtzc.rstÚstatic)zapp.jsz
app.js.mapzapp.csszapp.css.map)Úsuperr`   r!   r   ÚpathÚjoinrY   ÚwriteÚSETUP_PYr"   r$   Úmkdir)r^   r_   ÚfÚfnameÚtest_pkgrq   ©Ú	__class__r   r   r`   ¬   s    


ÿzTestManifestTest.setup_methodc                 C  sR   t j | jd¡}t|ddd��}| t|ƒ¡ W d  ƒ dS 1 s"w   Y  dS )zWrite a MANIFEST.in.r&   rh   ri   rj   N)r   rs   rt   rY   r!   ru   r   )r^   ÚcontentsÚmanifestrx   r   r   r   Úmake_manifestÓ   s   "ÿzTestManifestTest.make_manifestc                 C  s2   t tƒ}d|_t|ƒ}| ¡  | ¡  t|jjƒS )z7Run egg_info and get all the files to include, as a setr'   )	r   ÚSETUP_ATTRSÚscript_namer   Úensure_finalizedÚrunÚsetÚfilelistÚfiles)r^   ÚdistÚcmdr   r   r   Ú	get_filesÙ   s   zTestManifestTest.get_filesc                 C  s   t tdgƒ |  ¡ ksJ ‚dS )z=Check a missing MANIFEST.in includes only the standard files.r&   N)Údefault_filesr„   r‰   ©r^   r   r   r   Útest_no_manifestä   s   z!TestManifestTest.test_no_manifestc                 C  s   |   d¡ t|  ¡ ksJ ‚dS )z<Check an empty MANIFEST.in includes only the standard files.Ú N)r   rŠ   r‰   r‹   r   r   r   Útest_empty_filesè   s   
z!TestManifestTest.test_empty_filesc                 C  s.   |   d¡ ttddgƒB }||  ¡ ksJ ‚dS )z,Include extra rst files in the project root.zinclude *.rstrm   rl   N)r   rŠ   r„   r‰   )r^   r†   r   r   r   Útest_includeí   s   
zTestManifestTest.test_includec                 C  s4   t }|  d¡ tt|dƒgƒB }||  ¡ ksJ ‚dS )z0Include everything in app/ except the text fileszE
            include app/*
            exclude app/*.txt
            ú	app/c.rstN©r   r   rŠ   r„   r‰   ©r^   Úmlr†   r   r   r   Útest_excludeó   s   ÿzTestManifestTest.test_excludec              	   C  sR   t }|  d¡ tt|dƒ|dƒ|dƒ|dƒ|dƒ|dƒgƒB }||  ¡ ks'J ‚dS )	zInclude with multiple patterns.zinclude app/*.txt app/static/*ú	app/a.txtú	app/b.txtúapp/static/app.jsúapp/static/app.js.mapúapp/static/app.cssúapp/static/app.css.mapNr‘   r’   r   r   r   Útest_include_multipleÿ   s   
úz&TestManifestTest.test_include_multiplec                 C  óF   t }|  d¡ tt|dƒ|dƒ|dƒ|dƒgƒB }||  ¡ ks!J ‚dS )ú(Include the whole app/static/ directory.zgraft app/staticr—   r˜   r™   rš   Nr‘   r’   r   r   r   Ú
test_graft  ó   
üzTestManifestTest.test_graftc                 C  rœ   )r�   zgraft */staticr—   r˜   r™   rš   Nr‘   r’   r   r   r   Útest_graft_glob_syntax  rŸ   z'TestManifestTest.test_graft_glob_syntaxc                 C  s:   t }|  d¡ tt|dƒ|dƒgƒB }||  ¡ ksJ ‚dS )z'Exclude all *.map files in the project.zK
            graft app/static
            global-exclude *.map
            r—   r™   Nr‘   r’   r   r   r   Útest_graft_global_exclude%  s   ÿz*TestManifestTest.test_graft_global_excludec                 C  sD   t }|  d¡ ttdd|dƒ|dƒ|dƒgƒB }||  ¡ ks J ‚dS )z;Include all *.rst, *.js, and *.css files in the whole tree.z9
            global-include *.rst *.js *.css
            rl   rm   r�   r—   r™   Nr‘   r’   r   r   r   Útest_global_include1  s   ÿûz$TestManifestTest.test_global_includec                 C  s@   t }|  d¡ tt|dƒ|dƒ|dƒgƒB }||  ¡ ksJ ‚dS )z@Include all files in app/, except for the whole app/static/ dir.z@
            graft app
            prune app/static
            r•   r–   r�   Nr‘   r’   r   r   r   Útest_graft_pruneB  s   ÿz!TestManifestTest.test_graft_prune)rd   re   rf   r`   r   r‰   rŒ   rŽ   r�   r”   r›   rž   r    r¡   r¢   r£   Ú__classcell__r   r   r{   r   rg   «   s    'rg   c                   @  s®   e Zd ZdZeje d¡dkd�dd„ ƒZdd„ Z	d	d
„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'S )(ÚTestFileListTestz•
    A copy of the relevant bits of distutils/tests/test_filelist.py,
    to ensure setuptools' version of FileList keeps parity with distutils.
    ÚSETUPTOOLS_USE_DISTUTILSÚstdlib)Úautousec                   s    ‡ fdd„}|  tjd|¡ dS )z Account for stdlib compatibilityc              	     s.   t  ¡ }t d|dd|||¡}ˆ j |¡ d S )NÚ	distutilsr�   r   )r   Úexc_infoÚloggingÚ	LogRecordÚrecordsÚappend)Ú_loggerÚlevelÚmsgÚargsÚexcÚrec©Úcaplogr   r   Ú_logY  s   z2TestFileListTest._compat_record_logs.<locals>._logr·   N)Úsetattrr   ÚLog)r^   Úmonkeypatchr¶   r·   r   rµ   r   Ú_compat_record_logsU  s   z$TestFileListTest._compat_record_logsc                   s   ‡ fdd„|j D ƒS )Nc                   s   g | ]	}|j ˆ v r|‘qS r   )Úlevelno)r@   Úr©Úlevelsr   r   Ú
<listcomp>a  s    z0TestFileListTest.get_records.<locals>.<listcomp>)r­   )r^   r¶   r¿   r   r¾   r   Úget_records`  s   zTestFileListTest.get_recordsc                 C  s"   |   |tj¡g ksJ ‚| ¡  d S r   )rÁ   r   ÚWARNÚclear©r^   r¶   r   r   r   ÚassertNoWarningsc  s   z!TestFileListTest.assertNoWarningsc                 C  s>   t r|jst d¡ d S t|  |tj¡ƒdksJ ‚| ¡  d S )Nz'caplog checks may not work well in PyPyr   )	ÚIS_PYPYr­   ÚpytestÚxfailÚlenrÁ   r   rÂ   rÃ   rÄ   r   r   r   ÚassertWarningsg  s   
zTestFileListTest.assertWarningsc                 C  sD   |D ]}t j | j|¡}t j |¡\}}t j|dd� t|ƒ qd S )NT)Úexist_ok)r   rs   rt   rY   ÚsplitÚmakedirsr$   )r^   r†   ÚfileÚdirnameÚ	_basenamer   r   r   Ú
make_filesn  s   
üzTestFileListTest.make_filesc                 C  sÊ   t ƒ }t}|  ddddd|dƒ|dƒ|dƒ|d	ƒ|d
ƒ|dƒ|dƒ|dƒ|dƒ|dƒg¡ tdƒ}| d¡D ]
}|s;q6| |¡ q6ddd|dƒ|dƒ|dƒ|dƒ|dƒ|dƒg	}| ¡  |j|kscJ ‚d S )Nzfoo.tmpÚokÚxozfour.txtzbuildout.cfgz.hg/last-message.txtzglobal/one.txtzglobal/two.txtzglobal/files.xzglobal/here.tmpzf/o/f.oozdir/graft-onezdir/dir2/graft2zdir3/okzdir3/sub/ok.txta6          include ok
        include xo
        exclude xo
        include foo.tmp
        include buildout.cfg
        global-include *.x
        global-include *.txt
        global-exclude *.tmp
        recursive-include f *.oo
        recursive-exclude global *.x
        graft dir
        prune dir3
        Ú
)r   r   rÑ   r   rÌ   Úprocess_template_lineÚsortr†   )r^   Ú	file_listr“   ÚMANIFEST_INÚlineÚwantedr   r   r   Útest_process_template_lineu  sL   ïÿ÷z+TestFileListTest.test_process_template_linec                 C  sh   t ƒ }| d¡r
J ‚t ƒ }ddg|_| d¡sJ ‚t ƒ }ddg|_| d¡ | ¡  |jdgks2J ‚d S )Nú*.pyúa.pyzb.pyro   )r   Úexclude_patternr†   rÖ   ©r^   r×   r   r   r   Útest_exclude_pattern´  s   


z%TestFileListTest.test_exclude_patternc                 C  s|   t ƒ }|  g ¡ | d¡rJ ‚t ƒ }|  ddg¡ | d¡s J ‚t ƒ }|  ddg¡ | d¡ | ¡  |jddgks<J ‚d S )NrÜ   rÝ   rp   Ú*)r   rÑ   Úinclude_patternrÖ   r†   rß   r   r   r   Útest_include_patternÅ  s   

z%TestFileListTest.test_include_patternc              	   C  sH   t ƒ }dD ]}t t¡� | |¡ W d   ƒ n1 sw   Y  qd S )N)	ÚincludeÚexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludeÚgraftÚpruneÚblarg)r   rÇ   Úraisesr	   rÕ   )r^   r×   Úactionr   r   r   Ú"test_process_template_line_invalid×  s   ÿ€õz3TestFileListTest.test_process_template_line_invalidc                 C  s†   |  tj¡ t}tƒ }|  dd|dƒg¡ | d¡ | ¡  |jdgks&J ‚|  	|¡ | d¡ | ¡  |jdgks<J ‚|  
|¡ d S )NrÝ   rp   úd/c.pyzinclude *.pyzinclude *.rb©Ú	set_levelr«   ÚDEBUGr   r   rÑ   rÕ   rÖ   r†   rÅ   rÊ   ©r^   r¶   r“   r×   r   r   r   r�   è  s   


zTestFileListTest.test_includec                 C  sŽ   |  tj¡ t}tƒ }dd|dƒg|_| d¡ | ¡  |jd|dƒgks'J ‚|  |¡ | d¡ | ¡  |jd|dƒgks@J ‚|  	|¡ d S )NrÝ   rp   rì   zexclude *.pyzexclude *.rb©
rî   r«   rï   r   r   r†   rÕ   rÖ   rÅ   rÊ   rð   r   r   r   r”   ù  s   


zTestFileListTest.test_excludec                 C  s’   |  tj¡ t}tƒ }|  dd|dƒg¡ | d¡ | ¡  |jd|dƒgks)J ‚|  	|¡ | d¡ | ¡  |jd|dƒgksBJ ‚|  
|¡ d S )NrÝ   rp   rì   zglobal-include *.pyzglobal-include *.rbrí   rð   r   r   r   r¢   
  s   


z$TestFileListTest.test_global_includec                 C  s‚   |  tj¡ t}tƒ }dd|dƒg|_| d¡ | ¡  |jdgks$J ‚|  |¡ | d¡ | ¡  |jdgks:J ‚|  	|¡ d S )NrÝ   rp   rì   zglobal-exclude *.pyzglobal-exclude *.rbrñ   rð   r   r   r   Útest_global_exclude  s   


z$TestFileListTest.test_global_excludec                 C  s¤   |  tj¡ t}tƒ }|  d|dƒ|dƒ|dƒg¡ | d¡ | ¡  |j|dƒ|dƒgks0J ‚|  	|¡ | d¡ | ¡  |j|dƒ|dƒgksKJ ‚|  
|¡ d S )NrÝ   úd/b.pyúd/c.txtúd/d/e.pyzrecursive-include d *.pyzrecursive-include e *.pyrí   rð   r   r   r   Útest_recursive_include,  ó   


z'TestFileListTest.test_recursive_includec                 C  s˜   |  tj¡ t}tƒ }d|dƒ|dƒ|dƒg|_| d¡ | ¡  |jd|dƒgks,J ‚|  |¡ | d¡ | ¡  |jd|dƒgksEJ ‚|  	|¡ d S )NrÝ   ró   rô   rõ   zrecursive-exclude d *.pyzrecursive-exclude e *.pyrñ   rð   r   r   r   Útest_recursive_exclude=  ó   


z'TestFileListTest.test_recursive_excludec                 C  s¤   |  tj¡ t}tƒ }|  d|dƒ|dƒ|dƒg¡ | d¡ | ¡  |j|dƒ|dƒgks0J ‚|  	|¡ | d¡ | ¡  |j|dƒ|dƒgksKJ ‚|  
|¡ d S )NrÝ   ró   rõ   úf/f.pyzgraft dzgraft erí   rð   r   r   r   rž   N  r÷   zTestFileListTest.test_graftc                 C  s˜   |  tj¡ t}tƒ }d|dƒ|dƒ|dƒg|_| d¡ | ¡  |jd|dƒgks,J ‚|  |¡ | d¡ | ¡  |jd|dƒgksEJ ‚|  	|¡ d S )NrÝ   ró   rõ   rú   zprune dzprune erñ   rð   r   r   r   Ú
test_prune_  rù   zTestFileListTest.test_pruneN)rd   re   rf   Ú__doc__rÇ   Úfixturer   Úgetenvr»   rÁ   rÅ   rÊ   rÑ   rÛ   rà   rã   rë   r�   r”   r¢   rò   rö   rø   rž   rû   r   r   r   r   r¥   O  s(    

?r¥   )1rü   Ú
__future__r   Ú
contextlibr   r=   r«   r   ra   r   rW   rÇ   Úsetuptools.command.egg_infor   r   r   Úsetuptools.distr   Úsetuptools.tests.textwrapr   r©   r   Údistutils.errorsr	   Úbuiltin_module_namesrÆ   r   r€   rv   Úcontextmanagerr   r$   Ú	frozensetrI   rŠ   r:   Ú__annotations__ÚchainÚfrom_iterableÚmatch_paramsrý   rM   Úmismatch_paramsrO   rS   rU   rV   rg   r¥   r   r   r   r   Ú<module>   s¬    
ýý
	þÿ
ýýýýýýýØ.þ

þ

 %