o
    LK&hh                  	   @   s  d 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 ddlmZ ddlm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 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#Z#ddl$m%Z% dddgddgidej&'ddgfgdZ(de(dZ)edej&'ddgej&'ddgdZ*e*j+e*j, Z-ej.dd Z/dd  Z0d!d" Z1d#d$ Z2d%d& Z3ej4j5e3 d'd(Z6ej4j7d)d*d(Z8ej4j7e#j9:d+ d,d(Z;d-d. Z<d/d0 Z=G d1d2 d2Z>d3d4 Z?G d5d6 d6Z@d7d8 ZAd9d: ZBdS );zsdist tests    Ncleandoc)Path)mock)CommandSetuptoolsDeprecationWarning)metadata)manifest_maker)sdist)Distribution)	Extension)fail_on_ascii   )	Filenames)	run_setup
sdist_testz0.0z*.txtdatade.dat)nameversionpackagespackage_data
data_filesz&from setuptools import setup

setup(**z)
sdist_test.fzf.cf.hr   sourcesdependsc               	   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_stderr r'   N/var/www/html/venv/lib/python3.10/site-packages/setuptools/tests/test_sdist.pyquiet6   s   "r)   c                 C   s,   t | ts| tjddS | tjdS )Nascii   //)
isinstancestrreplaceossepencodepathr'   r'   r(   posixA   s   
r5   c                 C   sR   t | trtd| S z| d} td| } | d} W | S  ty(   Y | S w )NNFDutf-8)r-   r.   unicodedata	normalizedecoder2   UnicodeErrorr3   r'   r'   r(   	decomposeI   s   

r<   c                 C   s6   t | d}| W  d    S 1 sw   Y  d S )Nrb)openread)filenamefpr'   r'   r(   read_all_bytesU   s   $rB   c                  C   sB   zt jtjd\} }t|  t| W d S  ty    Y dS w )N)suffixT)tempfilemkstempr   latin_1r0   closeremove	Exception)descr@   r'   r'   r(   latin1_failZ   s   
rK   z)System does not support latin-1 filenames)reasonz%os.environ.get('PYTEST_XDIST_WORKER')zpytest-dev/pytest-xdist#843
setuptoolsz/the test is not supported with stdlib distutilsc                 C   s   t | d  | S )Nwb)r>   rG   r3   r'   r'   r(   touchs   s   rO   c              	   C   s6   z	t | | W |S  ttfy   td Y d S w )Nzsymlink not supported in OS)r0   symlinkOSErrorNotImplementedErrorpytestskip)srcdstr'   r'   r(   symlink_or_skip_testx   s   
rW   c                   @   s  e Zd Zejd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 dd dd dd dZeejde dd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Z eed2d3 Z!e"d4d5 Z#eed6d7 Z$d8d9d:d;d<Z%ejd=e% ej&d>d?d@ Z'dAdB Z(dCdD Z)dEdF Z*ej+dGdHdI Z,dJS )KTestSdistTestT)autousec                 c   s    |d }|   |d jtdd |d }|   |d }|   dD ]}t||  q$t|d  tD ]}t||  q5|  |V  W d    d S 1 sQw   Y  d S )	Nproject_rootsetup.pyr7   encodingr   r   )z__init__.pya.txtb.txtc.rstr   )mkdir
write_textSETUP_PYrO   EXTENSION_SOURCESas_cwd)selftmpdirtest_pkgdata_folderfnamer'   r'   r(   
source_dir   s    
"zTestSdistTest.source_dirc                 C   sd   |j j}tjdd|v sJ tjdd|v sJ tjdd|vs%J tjdd|v s0J d S )Nr   r^   r_   r`   r   r   )filelistfilesr0   r4   join)rf   cmdmanifestr'   r'   r(   assert_package_data_in_manifest   s
   z-TestSdistTest.assert_package_data_in_manifestc                 C   sd   i t dtgi}t|}d|_t|}|  t  |  W d    |S 1 s+w   Y  |S )Next_modulesr[   )SETUP_ATTRS	EXTENSIONr   script_namer
   ensure_finalizedr)   runrf   setup_attrsdistro   r'   r'   r(   setup_with_extension   s   

z"TestSdistTest.setup_with_extensionc                 C   sZ   t t}d|_t|}|  t  |  W d   n1 s!w   Y  | | dS )zRegression test for pull request #4: ensures that files listed in
        package_data are included in the manifest even if they're not added to
        version control.
        r[   N)r   rs   ru   r
   rv   r)   rw   rq   )rf   rz   ro   r'   r'   r(   test_package_data_in_sdist   s   
z(TestSdistTest.test_package_data_in_sdistc                 C   sv   i t ddi}|d sJ t|}d|_t|}|  t  |  W d   n1 s/w   Y  | | dS )zU
        Ensure package_data and include_package_data work
        together.
        include_package_dataTr   r[   N)rs   r   ru   r
   rv   r)   rw   rq   rx   r'   r'   r(   3test_package_data_and_include_package_data_in_sdist   s   
zATestSdistTest.test_package_data_and_include_package_data_in_sdistc                 C   s4   |   }| | |jj}tD ]}||v sJ qdS )z
        Ensure that the files listed in Extension.sources and Extension.depends
        are automatically included in the manifest.
        N)r{   rq   rl   rm   rd   )rf   ro   rp   r4   r'   r'   r(   test_extension_sources_in_sdist   s   
z-TestSdistTest.test_extension_sources_in_sdistc                 C   sH   t D ]}t| q|  }| | |jj}t D ]}||vs!J qdS )z
        Similar to test_extension_sources_in_sdist but the referenced files don't exist.
        Missing files should not be included in distribution (with no error raised).
        N)rd   r0   rH   r{   rq   rl   rm   )rf   r4   ro   rp   r'   r'   r(   test_missing_extension_sources   s   
z,TestSdistTest.test_missing_extension_sourcesc                 C   s   g }t D ]$}tj|\}}|d | }t|| ttj|| || q|  }| 	| |j
j}t D ]}||v s@J q8|D ]}||vsKJ qCdS )z
        Similar to test_extension_sources_in_sdist but the referenced files are
        instead symbolic links to project-local files. Referenced file paths
        should be included. Symlink targets themselves should NOT be included.
        z_target.N)rd   r0   r4   splitextrenamerW   basenameappendr{   rq   rl   rm   )rf   	symlinkedr4   baseexttargetro   rp   r'   r'   r(    test_symlinked_extension_sources   s   
z.TestSdistTest.test_symlinked_extension_sourcesc                   C   s   t jt jddS )Nr   r   )r0   r4   abspathrn   r'   r'   r'   r(   <lambda>  s   zTestSdistTest.<lambda>c                   C   s   t jddddS )Nr   ..r   r0   r4   rn   r'   r'   r'   r(   r     s   c                   C   s   t jddS )Nr   zthis_file_does_not_exist.hr   r'   r'   r'   r(   r     s   c                   C   s   t ttjdddS )Nr   zoutside_of_project_root.hz	symlink.h)rW   rO   r0   r4   rn   r'   r'   r'   r(   r     s   )zmust be relativezcan't have `..` segmentszdoesn't existzmust be inside the project rootrL   c           	   	      s   | j |   tdg  gd}i td|gi}t|}d|_t|}|  t " |t	j
 |  W d   n1 s?w   Y  W d   n1 sNw   Y  | | |jj} |vsbJ  fdd|jD }t|dkstJ |\}||v s}J dS )	a  
        Due to backwards compatibility reasons, `Extension.depends` should accept
        invalid/weird paths, but then ignore them when building a sdist.

        This test verifies that the source distribution is still built
        successfully with such paths, but that instead of adding these paths to
        the manifest, we emit an informational message, notifying the user that
        the invalid path won't be automatically included.
        r   r   rr   r[   Nc                    s0   g | ]\}}}|d kr|t jkr |v r|qS )root)loggingINFO).0loggerlevelmessageinvalid_pathr'   r(   
<listcomp>3  s    
z@TestSdistTest.test_invalid_extension_depends.<locals>.<listcomp>r   )_INVALID_PATHSr   rs   r   ru   r
   rv   r)   at_levelr   r   rw   rq   rl   rm   record_tupleslen)	rf   rL   caplog	extensionry   rz   ro   rp   expected_messager'   r   r(   test_invalid_extension_depends  s2   
 

	z,TestSdistTest.test_invalid_extension_dependsc              	      s  ddl m} t  G  fddd|}i tddi}|d s"J t|}d|_t|}|  d	|i|_	d	|i|j
_	|j
d	|ksFJ d
}t # tjt|d |  W d   n1 sbw   Y  W d   n1 sqw   Y     | | dS )zq
        Ensure projects defining custom build_py don't break
        when creating sdists (issue #2849)
        r   )build_pyc                       s"   e Zd ZdZ fddZ  ZS )z9TestSdistTest.test_custom_build_py.<locals>.CustomBuildPyzX
            Some projects have custom commands inheriting from `distutils`
            c                    s     t   S r   )superget_data_filesrf   )	__class__using_custom_command_guardr'   r(   r   N  s   
zHTestSdistTest.test_custom_build_py.<locals>.CustomBuildPy.get_data_files)__name__
__module____qualname____doc__r   __classcell__r'   r   )r   r(   CustomBuildPyI  s    r   r}   Tr   r[   r   zsetuptools instead of distutils)matchN)distutils.command.build_pyr   r   Mockrs   r   ru   r
   rv   cmdclassdistributionget_command_classr)   rS   warnsr   rw   assert_calledrq   )rf   OrigBuildPyr   ry   rz   ro   msgr'   r   r(   test_custom_build_py@  s(   	

 z"TestSdistTest.test_custom_build_pyc                 C   sd   t t}d|_t|}|  t  |  W d    n1 s!w   Y  |jj}d|v s0J d S Nfoo.pyr[   )	r   rs   ru   r
   rv   r)   rw   rl   rm   rf   rz   ro   rp   r'   r'   r(   test_setup_py_existsf  s   
z"TestSdistTest.test_setup_py_existsc                 C   sz   t t}d|_t|}|  tjdrtd t	  |
  W d    n1 s,w   Y  |jj}d|vs;J d S r   )r   rs   ru   r
   rv   r0   r4   existsrH   r)   rw   rl   rm   r   r'   r'   r(   test_setup_py_missingr  s   

z#TestSdistTest.test_setup_py_missingc                 C   s   t dddd}|d W d    n1 sw   Y  tt}d|_t|}|  t  |  W d    n1 s=w   Y  |j	j
}d|vsLJ d S )NMANIFEST.inwr7   r\   zexclude setup.pyr   r[   )r>   writer   rs   ru   r
   rv   r)   rw   rl   rm   )rf   manifest_filerz   ro   rp   r'   r'   r(   test_setup_py_excluded  s   
z$TestSdistTest.test_setup_py_excludedc                 C   s   t |d  t |d  tt}d|_t|}|  t  |  W d   n1 s-w   Y  tdd |j	j
}d|vsCJ |d|vsKJ |d|vsSJ |dS )	z
        Make sure default files (README.*, etc.) are added in a case-sensitive
        way to avoid problems with packages built on Windows.
        z
readme.rstz	SETUP.cfgzsetup.PYNc                 S   s   |   S r   )lower)xr'   r'   r(   r     s    z>TestSdistTest.test_defaults_case_sensitivity.<locals>.<lambda>r[   z	setup.cfg)rO   r   rs   ru   r
   rv   r)   rw   maprl   rm   rf   rk   rz   ro   rp   r'   r'   r(   test_defaults_case_sensitivity  s   
z,TestSdistTest.test_defaults_case_sensitivityc           	      C   s   dddddddd}dddd}i ||  D ]\}}t||jjddd t||j|dd q|  }| | d	d
 |jjD }|D ]}t	j
|sPJ ||vsZJ ||fqF|D ]}t	j
|sgJ ||v sqJ ||fq]d S )NzJglobal-include LICEN[CS]E* COPYING* NOTICE* AUTHORS*
global-include *.txt
 )r   zBtest/.venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rstzDsrc/.nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txtzEdoc/.tox/default/lib/python3.11/site-packages/foo-4.dist-info/LICENSEz.venv-requirements.txtz.tox-coveragerc.txtz.noxy/coveragerc.txt)zA.tox/release/lib/python3.11/site-packages/foo-4.dist-info/LICENSEz@.nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txtz=.venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rstT)parentsexist_okr7   r\   c                 S   s   h | ]	}| tjd qS )r,   )r/   r0   r1   )r   fr'   r'   r(   	<setcomp>  s    zDTestSdistTest.test_exclude_dev_only_cache_folders.<locals>.<setcomp>)itemsr   parentra   rb   r{   rq   rl   rm   r0   r4   r   )	rf   rk   includedexcludedfilecontentro   rp   r4   r'   r'   r(   #test_exclude_dev_only_cache_folders  s2   
z1TestSdistTest.test_exclude_dev_only_cache_foldersc                 C   s   t t}d|_t|}tjdd|_td tjdd}t	| t
  |  |j| |  W d    n1 s?w   Y  t|j}|d}t||v sVJ d S )Nr[   sdist_test.egg-infoSOURCES.txtr   u   smörbröd.pyUTF-8)r   rs   ru   r	   r0   r4   rn   rp   ra   rO   r)   rw   rl   r   write_manifestrB   r:   r5   )rf   rz   mmr@   contents
u_contentsr'   r'   r(   +test_manifest_is_written_with_utf8_encoding  s   



z9TestSdistTest.test_manifest_is_written_with_utf8_encodingc                 C   s   t t}d|_t|}tjdd|_td tjdt	j
}t| t  |  |d}|jj| |  W d    n1 sFw   Y  t|j}|d t||v s]J ||jjv seJ d S )Nr[   r   r   
   sdist_testr7   r   )r   rs   ru   r	   r0   r4   rn   rp   ra   r   utf_8rO   r)   rw   r:   rl   rm   r   r   rB   r5   rf   rz   r   r@   
u_filenamer   r'   r'   r(   )test_write_manifest_allows_utf8_filenames  s"   




z7TestSdistTest.test_write_manifest_allows_utf8_filenamesc                 C   s   t t}d|_t|}tjdd|_td tjdt	j
}t  |  |dd}|j| |  W d   n1 sBw   Y  t|j}|d t||vsYJ ||jjvsaJ dS )	a  
        Files that cannot be encoded to UTF-8 (specifically, those that
        weren't originally successfully decoded and have surrogate
        escapes) should be omitted from the manifest.
        See https://bitbucket.org/tarek/distribute/issue/303 for history.
        r[   r   r   r   r7   surrogateescapeNr   )r   rs   ru   r	   r0   r4   rn   rp   ra   r   rF   r)   rw   r:   rl   r   r   rB   r5   rm   r   r'   r'   r(   ,test_write_manifest_skips_non_utf8_filenames  s    



z:TestSdistTest.test_write_manifest_skips_non_utf8_filenamesc                 C   s   t t}d|_t|}|  t  |  W d    n1 s!w   Y  tj	dt
j}tj	dd|_t|jd}|d|  |  t| g |j_t  |  W d    n1 saw   Y  |d}||jjv ssJ d S )Nr[   r   r   r   ab   
r7   )r   rs   ru   r
   rv   r)   rw   r0   r4   rn   r   r   rp   r>   r   rG   rO   rl   rm   read_manifestr:   rf   rz   ro   r@   rp   r'   r'   r(   (test_manifest_is_read_with_utf8_encoding5  &   


z6TestSdistTest.test_manifest_is_read_with_utf8_encodingc                 C   s   t t}d|_t|}|  t  |  W d    n1 s!w   Y  tj	dt
j}tj	dd|_t|jd}|d|  |  t| g |j_t  |  W d    n1 saw   Y  |d}||jjvssJ d S )Nr[   r   r   r   r   r   latin-1)r   rs   ru   r
   rv   r)   rw   r0   r4   rn   r   rF   rp   r>   r   rG   rO   rl   rm   r   r:   r   r'   r'   r(   +test_read_manifest_skips_non_utf8_filenamesT  r   z9TestSdistTest.test_read_manifest_skips_non_utf8_filenamesc                 C   s   t | t}d|_t|}|  tjdt	j
}t| t  |  W d    n1 s0w   Y  tjdkr>t|}t }tjdkri|dkrZ|d}||jjv sXJ d S |d}||jjv sgJ d S |d}||jjv svJ d S )Nr[   r   darwinwin32cp1252mbcsr7   )r   make_stringsrs   ru   r
   rv   r0   r4   rn   r   r   rO   r)   rw   r    platformr<   getfilesystemencodingr:   rl   rm   rf   rz   ro   r@   fs_encr'   r'   r(   %test_sdist_with_utf8_encoded_filenames  s(   





z3TestSdistTest.test_sdist_with_utf8_encoded_filenamec                    sB   t |tr fdd| D S t |trtt j|S t|S )Nc                    s   i | ]
\}}|  |qS r'   )r   )r   keyvalueclsr'   r(   
<dictcomp>  s    z.TestSdistTest.make_strings.<locals>.<dictcomp>)r-   dictr   listr   r   r.   )r   itemr'   r   r(   r     s
   

zTestSdistTest.make_stringsc                 C   s   t | t}d|_t|}|  tjdt	j
}t| tj|s&J t  |  W d    n1 s8w   Y  tjdkr[t }|dkrLd}||}||jjv sYJ d S |d}||jjvshJ d S )Nr[   r   r   r   r   )r   r   rs   ru   r
   rv   r0   r4   rn   r   rF   rO   isfiler)   rw   r    r   r   r:   rl   rm   r   r'   r'   r(   'test_sdist_with_latin1_encoded_filename  s$   



z5TestSdistTest.test_sdist_with_latin1_encoded_filenamez
            [metadata]
            name = testing
            version = file: src/VERSION.txt
            license_files = DOWHATYOUWANT
            long_description = file: README.rst, USAGE.rst
            a
  
            [project]
            name = "testing"
            readme = "USAGE.rst"
            license-files = ["DOWHATYOUWANT"]
            dynamic = ["version"]
            [tool.setuptools.dynamic]
            version = {file = ["src/VERSION.txt"]}
            a  
            [project]
            name = "testing"
            readme = "USAGE.rst"
            license-files = ["DOWHATYOUWANT"]
            dynamic = ["version"]
            [tool.setuptools.dynamic]
            version = {file = "src/VERSION.txt"}
            a	  
            [project]
            name = "testing"
            readme = "USAGE.rst"
            license = {file = "DOWHATYOUWANT"}
            dynamic = ["version"]
            [tool.setuptools.dynamic]
            version = {file = "src/VERSION.txt"}
            )z(setup.cfg - long_description and versionz@pyproject.toml - static readme/license files and dynamic versionz3pyproject.toml - directive with str instead of listz9pyproject.toml - deprecated license table with file entryconfigz6ignore:.project.license. as a TOML table is deprecatedc                 C   s8  | d\}}}| j| }|d   |d jddd |d jddd |d	 jddd |d
 jddd || j|dd tdg i}d|_|  t|}|  t	  |
  W d    n1 sgw   Y  d|jjv szd|jjv szJ d	|jjv sJ d
|jjv sJ d|jjvsJ d|jjvsJ d S )Nz - rU   zsrc/VERSION.txtz0.42r7   r\   z
README.rstzhello world!z	USAGE.rstDOWHATYOUWANTr   r[   zsrc\VERSION.txtr,   \)	partition_EXAMPLE_DIRECTIVESra   rb   r   ru   parse_config_filesr
   rv   r)   rw   rl   rm   )rf   rk   r   config_file_config_textrz   ro   r'   r'   r(   .test_add_files_referenced_by_config_directives  s,   

z<TestSdistTest.test_add_files_referenced_by_config_directivesc                 C   sp   t |d  tt}d|_t|}|  t  |  W d   n1 s'w   Y  |jj	}d|v s6J dS )zW
        Check if pyproject.toml is included in source distribution if present
        pyproject.tomlr[   N)
rO   r   rs   ru   r
   rv   r)   rw   rl   rm   r   r'   r'   r(   test_pyproject_toml_in_sdist   s   
z*TestSdistTest.test_pyproject_toml_in_sdistc                 C   s   t |d  tdddd}td|d W d   n1 sw   Y  tt}d	|_t|}|  t  |	  W d   n1 sDw   Y  |j
j}d|vsSJ dS )
zH
        Check that pyproject.toml can excluded even if present
        r	  r   r   r7   r\   zexclude pyproject.toml)r   Nr[   )rO   r>   printr   rs   ru   r
   rv   r)   rw   rl   rm   )rf   rk   mtsrz   ro   rp   r'   r'   r(   test_pyproject_toml_excluded  s   
z*TestSdistTest.test_pyproject_toml_excludedc                 C   s  t |d  ti tddi}t|}|  t  |  W d    n1 s*w   Y  |jj}d|vs9J ti tddi}|	d}g |j
d|_
G dd dt}|jj|d t|}d	|_|  t  |  W d    n1 s|w   Y  |jj}d|v sJ d S )
N.myfile~ru   r[   build)build_customNc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
zFTestSdistTest.test_build_subcommand_source_files.<locals>.build_customc                 S      d S r   r'   r   r'   r'   r(   initialize_options0      zYTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.initialize_optionsc                 S   r  r   r'   r   r'   r'   r(   finalize_options2  r  zWTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.finalize_optionsc                 S   r  r   r'   r   r'   r'   r(   rw   4  r  zJTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.runc                 S   s   dgS )Nr  r'   r   r'   r'   r(   get_source_files6  s   zWTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.get_source_filesN)r   r   r   r  r  rw   r  r'   r'   r'   r(   r  /  s
    r  )r  T)rO   r   rs   r
   rv   r)   rw   rl   rm   get_command_objsub_commandsr   r   updateuse_defaults)rf   rk   rz   ro   rp   r  r  r'   r'   r(   "test_build_subcommand_source_files  s,   



z0TestSdistTest.test_build_subcommand_source_filesz6os.environ.get('SETUPTOOLS_USE_DISTUTILS') == 'stdlib'c                 C   sh   t i tdddtdiid}t|}|  t  |  W d   dS 1 s-w   Y  dS )zS
        Ensure if build_base is a pathlib.Path, the build still succeeds.
        r[   r  
build_base)ru   optionsN)r   rs   pathlibr   r
   rv   r)   rw   )rf   rk   rz   ro   r'   r'   r(   test_build_base_pathlibC  s   

"z%TestSdistTest.test_build_base_pathlibN)-r   r   r   rS   fixturerk   rq   r{   r|   r~   r   r   r   r   skip_under_stdlib_distutilsmarkparametrizekeysr   r   r   r   r   r   r   r   r   r   skip_under_xdistr   r    fail_on_latin1_encoded_filenamesr   r   classmethodr   r   r  filterwarningsr  r
  r  r  skipifr  r'   r'   r'   r(   rX      sr    

+&(

 
#


		%
%rX   c                  C   s(   t jd\} |  }t|dsJ dS )a  
    When _default_revctrl was removed from the `setuptools.command.sdist`
    module in 10.0, it broke some systems which keep an old install of
    setuptools (Distribute) around. Those old versions require that the
    setuptools package continue to implement that interface, so this
    function provides that interface, stubbed. See #320 for details.

    This interface must be maintained until Ubuntu 12.04 is no longer
    supported (by Setuptools).
    zg
        [setuptools.file_finders]
        svn_cvs = setuptools.command.sdist:_default_revctrl
        __iter__N)r   EntryPoints
_from_textloadhasattr)epresr'   r'   r(   test_default_revctrlS  s
   r0  c                   @   sT   e Zd ZdZedd Zejdddd Z	edd	 Z
ejdd
dd ZdS )TestRegressionszp
    Can be removed/changed if the project decides to change how it handles symlinks
    or external files.
    c                 C   s&   dddiit d|dddddS )	Ndirfile.hr   [  
                    from setuptools import Extension, setup
                    setup(
                        name="myproj",
                        version="42",
                        ext_modules=[
                            Extension(
                                "hello", sources=["hello.pyx"],
                                depends=[e]
                            )
                        ],
                    )
                    global-include *.hr[   z	hello.pyxr   externalprojectr   )tmp_pathdep_pathr'   r'   r(   &files_for_symlink_in_extension_dependsn  s   z6TestRegressions.files_for_symlink_in_extension_dependsr<  )zmyheaders/dir/file.hzmyheaders/dir/../dir/file.hc                 C   sZ   |  ||}tjj|t|d t|d |d  t||d }dD ]}||v s*J q"d S )Nprefixr9  zproject/myheadersr:  )zmyproj-42/hello.pyxzmyproj-42/myheaders/dir/file.h)r=  jaracor4   r  r.   rW   	run_sdist)rf   monkeypatchr;  r<  rm   membersexpectedr'   r'   r(   !test_symlink_in_extension_depends  s   z1TestRegressions.test_symlink_in_extension_dependsc                 C   sJ   | d\}}}|r| | n|}dddiitdt|ddddd	S )
Nz$tmp_path$/r2  r3  r   r4  r5  r6  r7  r8  )r  r   r.   )r;  r<  headr  tailr'   r'   r(   ,files_for_external_path_in_extension_depends  s   z<TestRegressions.files_for_external_path_in_extension_depends)z$tmp_path$/external/dir/file.hz../external/dir/file.hc                 C   sH   |  ||}tjj|t|d t||d }|D ]}d|vs!J qd S )Nr>  r:  r3  )rH  r@  r4   r  r.   rA  )rf   rB  r;  r<  rm   rC  r   r'   r'   r(   'test_external_path_in_extension_depends  s   z7TestRegressions.test_external_path_in_extension_dependsN)r   r   r   r   staticmethodr=  rS   r!  r"  rE  rH  rI  r'   r'   r'   r(   r1  h  s    


r1  c                 C   s   |  | t  tddg W d   n1 sw   Y  t|d d}tt|}t|	 W  d   S 1 s?w   Y  dS )z@Given a project directory, run the sdist and return its contentsr[   r
   Nrz   z*.tar.gz)
chdirr)   r   nextglobtarfiler>   r.   setgetnames)rB  r:  archivetarr'   r'   r(   rA    s   

$rA  c                 C   s^   t | }| }W d    n1 sw   Y  dd |D }t|dks-J d| d S )Nc                 S   s   g | ]}d |v r|qS )z.toxr'   )r   r   r'   r'   r(   r     s    z:test_sanity_check_setuptools_own_sdist.<locals>.<listcomp>r   z
not empty )rN  r>   rP  r   )setuptools_sdistrR  rm   	tox_filesr'   r'   r(   &test_sanity_check_setuptools_own_sdist  s
   
rU  )Cr   
contextlibr#   r   r0   r  r    rN  rD   r8   inspectr   r   unittestr   jaraco.pathr@  rS   rM   r   r   setuptools._importlibr   setuptools.command.egg_infor	   setuptools.command.sdistr
   setuptools.distr   setuptools.extensionr   setuptools.testsr   textr   	distutilsdistutils.corer   r4   rn   rs   rc   rt   r   r   rd   contextmanagerr)   r5   r<   rB   rK   r!  xfailr%  r(  r$  __package__
startswithr   rO   rW   rX   r0  r1  rA  rU  r'   r'   r'   r(   <module>   s    

		     W_