
    ,hh              	       ~   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jL                  jO                  dd      gfgdZ(de(dZ) edejL                  jO                  dd      gejL                  jO                  dd      g      Z*e*jV                  e*jX                  z   Z-ej\                  d        Z/d Z0d Z1d  Z2d! Z3ejh                  jk                   e3       d"#      Z6ejh                  jo                  d$d%#      Z8ejh                  jo                  e#jr                  ju                  d&       d'#      Z;d( Z<d) Z= G d* d+      Z>d, Z? G d- d.      Z@d/ ZAd0 ZBy)1z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               #   2  K   t         j                  t         j                  }} t        j                         t        j                         ct         _        t         _        	 d  | |ct         _        t         _        y # | |ct         _        t         _        w xY wwN)sysstdoutstderrioStringIO)
old_stdout
old_stderrs     ]/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/tests/test_sdist.pyquietr*   6   s[      ZZ
J[[]BKKMCJ
8!+Z
CJZ
CJs   ABA; #B;BBc                     t        | t              s/| j                  t        j                  j                  d      d      S | j                  t        j                  d      S )Nascii   //)
isinstancestrreplaceossepencodepaths    r)   posixr7   A   s?    dC ||BFFMM'2D99||BFFC((    c                     t        | t              rt        j                  d|       S 	 | j	                  d      } t        j                  d|       } | j                  d      } | S # t        $ r Y | S w xY w)NNFDutf-8)r/   r0   unicodedata	normalizedecoder4   UnicodeErrorr5   s    r)   	decomposer@   I   sr    $$$UD11{{7#$$UD1{{7# K  Ks   8A" "	A/.A/c                 f    t        | d      5 }|j                         cd d d        S # 1 sw Y   y xY w)Nrb)openread)filenamefps     r)   read_all_bytesrG   U   s,    	h	 wwy  s   '0c                      	 t        j                  t        j                        \  } }t	        j
                  |        t	        j                  |       y # t        $ r Y yw xY w)N)suffixT)tempfilemkstempr   latin_1r2   closeremove	Exception)descrE   s     r)   latin1_failrQ   Z   sJ    !))1B1BCh

		( s   AA 	A A 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                 :    t        | d      j                          | S )Nwb)rC   rM   r5   s    r)   touchrV   s   s    tKr8   c                     	 t        j                  | |       |S # t        t        f$ r t	        j
                  d       Y y w xY w)Nzsymlink not supported in OS)r2   symlinkOSErrorNotImplementedErrorpytestskip)srcdsts     r)   symlink_or_skip_testr_   x   sC    


3 J () 12s    $A Ac                      e Zd Z ej                  d      d        Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd d d d dZeej                  j!                  dej#                               d               Zd Zd Zd Zd Zd Zd Zed        Zed        Zed        Zed        Zed        Z eed               Z!e"d        Z#eed               Z$d d!d"d#d$Z%ej                  j!                  d%e%j#                               ej                  jM                  d&      d'               Z'd( Z(d) Z)d* Z*ej                  jW                  d+      d,        Z,y-).TestSdistTestT)autousec              #     K   |dz  }|j                          |dz  j                  t        d       |dz  }|j                          |dz  }|j                          dD ]  }t        ||z          t        |dz         t        D ]  }t        ||z          |j                         5  | d d d        y # 1 sw Y   y xY ww)	Nproject_rootsetup.pyr;   encodingr   r   )z__init__.pya.txtb.txtc.rstr   )mkdir
write_textSETUP_PYrV   EXTENSION_SOURCESas_cwd)selftmpdirtest_pkgdata_folderfnames        r)   
source_dirzTestSdistTest.source_dir   s     .(	*	((G(D L(sl @ 	$E(U"#	$kG#$ ' 	"E&5.!	" ]]_ 	L	 	 	s   B&C(B6-	C6B?;Cc                 P   |j                   j                  }t        j                  j	                  dd      |v sJ t        j                  j	                  dd      |v sJ t        j                  j	                  dd      |vsJ t        j                  j	                  dd      |v sJ y )Nr   rh   ri   rj   r   r   )filelistfilesr2   r6   join)rp   cmdmanifests      r)   assert_package_data_in_manifestz-TestSdistTest.assert_package_data_in_manifest   s|    <<%%ww||L'2h>>ww||L'2h>>ww||L'2(BBww||C)X555r8   c                     i t         dt        gi}t        |      }d|_        t	        |      }|j                          t               5  |j                          d d d        |S # 1 sw Y   |S xY w)Next_modulesre   )SETUP_ATTRS	EXTENSIONr   script_namer   ensure_finalizedr*   runrp   setup_attrsdistrz   s       r)   setup_with_extensionz"TestSdistTest.setup_with_extension   sh    AAmi[AK(%DkW 	GGI	 
	 
s   	A$$A.c                     t        t              }d|_        t        |      }|j	                          t               5  |j                          ddd       | j                  |       y# 1 sw Y   xY w)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.
        re   N)r   r   r   r   r   r*   r   r|   )rp   r   rz   s      r)   test_package_data_in_sdistz(TestSdistTest.test_package_data_in_sdist   s^     K(%DkW 	GGI	 	,,S1	 	s   A''A0c                    i t         ddi}|d   sJ t        |      }d|_        t        |      }|j	                          t               5  |j                          ddd       | j                  |       y# 1 sw Y   xY w)zU
        Ensure package_data and include_package_data work
        together.
        include_package_dataTr   re   N)r   r   r   r   r   r*   r   r|   r   s       r)   3test_package_data_and_include_package_data_in_sdistzATestSdistTest.test_package_data_and_include_package_data_in_sdist   s|    
 DC&<dC>**K(%DkW 	GGI	 	,,S1	 	s   A66A?c                     | j                         }| j                  |       |j                  j                  }t        D ]  }||v rJ  y)z
        Ensure that the files listed in Extension.sources and Extension.depends
        are automatically included in the manifest.
        N)r   r|   rw   rx   rn   )rp   rz   r{   r6   s       r)   test_extension_sources_in_sdistz-TestSdistTest.test_extension_sources_in_sdist   sI    
 ''),,S1<<%%% 	$D8##	$r8   c                     t         D ]  }t        j                  |        | j                         }| j	                  |       |j
                  j                  }t         D ]  }||vrJ  y)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)rn   r2   rN   r   r|   rw   rx   )rp   r6   rz   r{   s       r)   test_missing_extension_sourcesz,TestSdistTest.test_missing_extension_sources   se    
 & 	DIIdO	 ''),,S1<<%%% 	(Dx''	(r8   c                    g }t         D ]|  }t        j                  j                  |      \  }}|dz   |z   }t        j                  ||       t        t        j                  j                  |      |       |j                  |       ~ | j                         }| j                  |       |j                  j                  }t         D ]  }||v rJ  |D ]  }||vrJ  y)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)rn   r2   r6   splitextrenamer_   basenameappendr   r|   rw   rx   )rp   	symlinkedr6   baseexttargetrz   r{   s           r)    test_symlinked_extension_sourcesz.TestSdistTest.test_symlinked_extension_sources   s     	% 	%D((.ID#J&,FIIdF# !1!1&!94@V$	% ''),,S1<<%%% 	$D8##	$ 	(Dx''	(r8   c                  |    t         j                  j                  t         j                  j                  dd            S )Nr   r   )r2   r6   abspathry    r8   r)   <lambda>zTestSdistTest.<lambda>  s&    GGOOBGGLLu=> r8   c                  F    t         j                  j                  dddd      S )Nr   ..r   r2   r6   ry   r   r8   r)   r   zTestSdistTest.<lambda>  s    GGLLt\5A r8   c                  B    t         j                  j                  dd      S )Nr   zthis_file_does_not_exist.hr   r   r8   r)   r   zTestSdistTest.<lambda>  s    GGLL'CD r8   c                  h    t        t        t        j                  j	                  dd            d      S )Nr   zoutside_of_project_root.hz	symlink.h)r_   rV   r2   r6   ry   r   r8   r)   r   zTestSdistTest.<lambda>  s*     bggll4)DEF r8   )zmust be relativezcan't have `..` segmentszdoesn't existzmust be inside the project rootrR   c                     | j                   |          }t        dg |g      }i t        d|gi}t        |      }d|_        t        |      }|j                          t               5  |j                  t        j                        5  |j                          ddd       ddd       | j                  |       |j                  j                  }||vsJ |j                  D 	
cg c]$  \  }	}
}|	dk(  r|
t        j                  k(  r||v r|& }}
}	}t!        |      dk(  sJ |\  }||v sJ y# 1 sw Y   xY w# 1 sw Y   xY wc c}}
}	w )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   r~   re   Nrootr   )_INVALID_PATHSr   r   r   r   r   r   r*   at_levelloggingINFOr   r|   rw   rx   record_tupleslen)rp   rR   caploginvalid_path	extensionr   r   rz   r{   loggerlevelmessageexpected_messages                r)   test_invalid_extension_dependsz,TestSdistTest.test_invalid_extension_depends  sX    3t**624!N
	
 BAmi[AK(%DkW 	foogll3 	GGI	 	 	,,S1<<%%8++ -3,@,@
 
(& W\\) G+ 
 
 #$)).	))))%	 	 	 	
s*   ( D:D.D:&)E.D7	3D::Ec                 P   ddl m} t        j                          G fdd|      }i t        ddi}|d   sJ t        |      }d|_        t        |      }|j                          d	|i|_	        d	|i|j                  _	        |j                  j                  d	      |k(  sJ d
}t               5  t        j                  t        |      5  |j!                          ddd       ddd       j#                          | j%                  |       y# 1 sw Y   3xY w# 1 sw Y   7xY w)zq
        Ensure projects defining custom build_py don't break
        when creating sdists (issue #2849)
        r   )build_pyc                   &     e Zd ZdZ fdZ xZS )9TestSdistTest.test_custom_build_py.<locals>.CustomBuildPyzX
            Some projects have custom commands inheriting from `distutils`
            c                 .             t         |          S r!   )superget_data_files)rp   	__class__using_custom_command_guards    r)   r   zHTestSdistTest.test_custom_build_py.<locals>.CustomBuildPy.get_data_filesN  s    *,w-//r8   )__name__
__module____qualname____doc__r   __classcell__)r   r   s   @r)   CustomBuildPyr   I  s    0 0r8   r   r   Tr   re   r   zsetuptools instead of distutils)matchN)distutils.command.build_pyr   r   Mockr   r   r   r   r   cmdclassdistributionget_command_classr*   r[   warnsr   r   assert_calledr|   )rp   OrigBuildPyr   r   r   rz   msgr   s          @r)   test_custom_build_pyz"TestSdistTest.test_custom_build_py@  s   
 	G%)YY["	0K 	0 DC&<dC>**K(%Dk #M2%/$?!11*=NN/W 	fll#?sK 	GGI	 	 	#002,,S1		 	 	 	s$   1DDDD	DD%c                     t        t              }d|_        t        |      }|j	                          t               5  |j                          d d d        |j                  j                  }d|v sJ y # 1 sw Y   &xY wNfoo.pyre   )	r   r   r   r   r   r*   r   rw   rx   rp   r   rz   r{   s       r)   test_setup_py_existsz"TestSdistTest.test_setup_py_existsf  sk    K(#DkW 	GGI	 <<%%X%%%		 	s   A22A;c                 d   t        t              }d|_        t        |      }|j	                          t
        j                  j                  d      rt        j                  d       t               5  |j                          d d d        |j                  j                  }d|vsJ y # 1 sw Y   &xY wr   )r   r   r   r   r   r2   r6   existsrN   r*   r   rw   rx   r   s       r)   test_setup_py_missingz#TestSdistTest.test_setup_py_missingr  s    K(#Dk77>>*%IIj!W 	GGI	 <<%%)))		 	s   0B&&B/c                 d   t        ddd      5 }|j                  d       d d d        t        t              }d|_        t        |      }|j                          t               5  |j                          d d d        |j                  j                  }d|vsJ y # 1 sw Y   zxY w# 1 sw Y   2xY w)NMANIFEST.inwr;   rf   zexclude setup.pyr   re   )rC   writer   r   r   r   r   r*   r   rw   rx   )rp   manifest_filer   rz   r{   s        r)   test_setup_py_excludedz$TestSdistTest.test_setup_py_excluded  s    -w7 	4= 23	4 K(#DkW 	GGI	 <<%%)))	4 	4	 	s   B$B&B#&B/c                    t        |dz         t        |dz         t        t              }d|_        t	        |      }|j                          t               5  |j                          ddd       t        d |j                  j                        }d|vsJ |       d|vsJ |       d|vsJ |       y# 1 sw Y   LxY w)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                 "    | j                         S r!   )lower)xs    r)   r   z>TestSdistTest.test_defaults_case_sensitivity.<locals>.<lambda>  s     r8   re   z	setup.cfg)rV   r   r   r   r   r   r*   r   maprw   rx   rp   ru   r   rz   r{   s        r)   test_defaults_case_sensitivityz,TestSdistTest.test_defaults_case_sensitivity  s     	j<'(j;&'K( &DkW 	GGI	 *CLL,>,>?8+5X5)383(*4H4*	 	s   B44B=c                    dddddddd}dddd}i ||j                         D ]I  \  }}t        ||      j                  j                  dd       t        ||      j	                  |d       K | j                         }| j                  |       |j                  j                  D ch c]"  }|j                  t        j                  d	      $ }}|D ]0  }	t        j                  j                  |	      sJ |	|vr)J |	|f        |D ]0  }	t        j                  j                  |	      sJ |	|v r)J |	|f        y c c}w )
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_okr;   rf   r.   )itemsr   parentrk   rl   r   r|   rw   rx   r1   r2   r3   r6   r   )
rp   ru   includedexcludedfilecontentrz   fr{   r6   s
             r)   #test_exclude_dev_only_cache_foldersz1TestSdistTest.test_exclude_dev_only_cache_folders  s\   )
 SUTVUW&(#%$&
( RTPRMO
 65H5;;= 	IMD'T"))//t/LT"--g-H	I ''),,S147LL4F4FGqAIIbffc*GG 	:D77>>$''x'9$)99	:  	6D77>>$''8#5dH%55	6	 Hs   *'D>c                 .   t        t              }d|_        t        |      }t        j
                  j                  dd      |_        t	        j                  d       t        j
                  j                  dd      }t        |       t               5  |j                          |j                  j                  |       |j                          d d d        t        |j                        }|j!                  d      }t#        |      |v sJ y # 1 sw Y   ?xY w)Nre   sdist_test.egg-infoSOURCES.txtr   u   smörbröd.pyUTF-8)r   r   r   r
   r2   r6   ry   r{   rk   rV   r*   r   rw   r   write_manifestrG   r>   r7   )rp   r   mmrE   contents
u_contentss         r)   +test_manifest_is_written_with_utf8_encodingz9TestSdistTest.test_manifest_is_written_with_utf8_encoding  s     K(%D!ggll#8-H
&' 77<<o> 	h W 	 FFHKKx(	 
 ""++. __W-
 X*,,,	  	 s   <DDc                    t        t              }d|_        t        |      }t        j
                  j                  dd      |_        t	        j                  d       t        j
                  j                  dt        j                        }t        |       t               5  |j                          |j                  d      }|j                  j                   j#                  |       |j%                          d d d        t'        |j                        }|j                  d       t)        |      |v sJ |j                  j                   v sJ y # 1 sw Y   YxY w)Nre   r   r   
   sdist_testr;   r   )r   r   r   r
   r2   r6   ry   r{   rk   r   utf_8rV   r*   r   r>   rw   rx   r   r   rG   r7   rp   r   r   rE   
u_filenamer   s         r)   )test_write_manifest_allows_utf8_filenamesz7TestSdistTest.test_write_manifest_allows_utf8_filenames  s    K(%D!ggll#8-H
&'77<<y? 	h W 	 FFH!1JKK$$Z0	  ""++. 	  X(** R[[.....!	  	 s   AEEc                    t        t              }d|_        t        |      }t        j
                  j                  dd      |_        t	        j                  d       t        j
                  j                  dt        j                        }t               5  |j                          |j                  dd      }|j                  j                  |       |j!                          ddd       t#        |j                        }|j                  d       t%        |      |vsJ |j                  j&                  vsJ y# 1 sw Y   YxY w)	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.
        re   r   r   r   r;   surrogateescapeNr   )r   r   r   r
   r2   r6   ry   r{   rk   r   rL   r*   r   r>   rw   r   r   rG   r7   rx   r   s         r)   ,test_write_manifest_skips_non_utf8_filenamesz:TestSdistTest.test_write_manifest_skips_non_utf8_filenames  s     K(%D!ggll#8-H
&' 77<<y/@/@A W 	 FFH!2CDJKKz*	  ""++. 	  Xh.. !2!2222!	  	 s   AD::Ec                    t        t              }d|_        t        |      }|j	                          t               5  |j                          d d d        t        j                  j                  dt        j                        }t        j                  j                  dd      |_        t        |j                  d      }|j                  d|z          |j                          t!        |       g |j"                  _        t               5  |j'                          d d d        |j)                  d      }||j"                  j$                  v sJ y # 1 sw Y   xY w# 1 sw Y   BxY w)Nre   r   r   r   ab   
r;   )r   r   r   r   r   r*   r   r2   r6   ry   r   r   r{   rC   r   rM   rV   rw   rx   read_manifestr>   rp   r   rz   rE   r{   s        r)   (test_manifest_is_read_with_utf8_encodingz6TestSdistTest.test_manifest_is_read_with_utf8_encoding5  s    K(%Dk W 	GGI	 77<<y?ww||$9=Id+ux'( 	h  W 	 	  ??7+3<<-----)	 		  	    EEEE#c                    t        t              }d|_        t        |      }|j	                          t               5  |j                          d d d        t        j                  j                  dt        j                        }t        j                  j                  dd      |_        t        |j                  d      }|j                  d|z          |j                          t!        |       g |j"                  _        t               5  |j'                          d d d        |j)                  d      }||j"                  j$                  vsJ y # 1 sw Y   xY w# 1 sw Y   BxY w)Nre   r   r   r   r  r  latin-1)r   r   r   r   r   r*   r   r2   r6   ry   r   rL   r{   rC   r   rM   rV   rw   rx   r  r>   r  s        r)   +test_read_manifest_skips_non_utf8_filenamesz9TestSdistTest.test_read_manifest_skips_non_utf8_filenamesT  s    K(%Dk W 	GGI	 77<<y/@/@Aww||$9=Id+ux'( 	h  W 	 	  ??9-s||11111)	 		  	 r  c                    t        | j                  t                    }d|_        t	        |      }|j                          t        j                  j                  dt        j                        }t        |       t               5  |j                          d d d        t        j                  dk(  rt!        |      }t        j"                         }t        j                  dk(  r]|dk(  r+|j%                  d      }||j&                  j(                  v s.J |j%                  d      }||j&                  j(                  v sJ y y |j%                  d      }||j&                  j(                  v sJ y # 1 sw Y   xY w)Nre   r   darwinwin32cp1252mbcsr;   )r   make_stringsr   r   r   r   r2   r6   ry   r   r   rV   r*   r   r"   platformr@   getfilesystemencodingr>   rw   rx   rp   r   rz   rE   fs_encs        r)   %test_sdist_with_utf8_encoded_filenamez3TestSdistTest.test_sdist_with_utf8_encoded_filenames  s(    D--k:;%Dk77<<y?hW 	GGI	 <<8# *H**,<<7"!#??843<<#5#555#??623<<#5#5555 6
  w/Hs||11111%	 	s   E++E4c                    t        |t              r3|j                         D ci c]  \  }}|| j                  |       c}}S t        |t              rt	        t        | j                  |            S t        |      S c c}}w r!   )r/   dictr   r  listr   r0   )clsitemkeyvalues       r)   r  zTestSdistTest.make_strings  si    dD!CG::<PZS%C))%00PPdD!C,,d3444y Qs   A>c                    t        | j                  t                    }d|_        t	        |      }|j                          t        j                  j                  dt        j                        }t        |       t        j                  j                  |      sJ t               5  |j                          d d d        t        j                   dk(  rGt        j"                         }|dk7  rd}|j%                  |      }||j&                  j(                  v sJ y |j%                  d      }||j&                  j(                  vsJ y # 1 sw Y   xY w)Nre   r   r  r  r	  )r   r  r   r   r   r   r2   r6   ry   r   rL   rV   isfiler*   r   r"   r  r  r>   rw   rx   r  s        r)   'test_sdist_with_latin1_encoded_filenamez5TestSdistTest.test_sdist_with_latin1_encoded_filename  s    D--k:;%Dk 77<<y/@/@Ahww~~h''W 	GGI	 <<7" ..0F"v.Hs||11111  y1H3<<#5#5555!	 	s   %EEz
            [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                 ^   |j                  d      \  }}}| j                  |   }|dz  j                          |dz  j                  dd       |dz  j                  dd       |d	z  j                  dd       |d
z  j                  dd       ||z  j                  |d       t	        dg i      }d|_        |j                          t        |      }|j                          t               5  |j                          d d d        d|j                  j                  v sd|j                  j                  v sJ d	|j                  j                  v sJ d
|j                  j                  v sJ d|j                  j                  vsJ d|j                  j                  vsJ y # 1 sw Y   xY w)Nz - r]   zsrc/VERSION.txtz0.42r;   rf   z
README.rstzhello world!z	USAGE.rstDOWHATYOUWANTr   re   zsrc\VERSION.txtr.   \)	partition_EXAMPLE_DIRECTIVESrk   rl   r   r   parse_config_filesr   r   r*   r   rw   rx   )rp   ru   r   config_file_config_textr   rz   s           r)   .test_add_files_referenced_by_config_directivesz<TestSdistTest.test_add_files_referenced_by_config_directives  s   
 #,,U3Q..v6	e	""$	'	'33FW3M	l	"..~.P	k	!--nw-O	o	%11.71S	k	!--kG-LZ,-%!DkW 	GGI	 !3!33!S\\%7%77	
 cll0000#,,"4"444#,,,,,,3<<-----	 	s   /F##F,c                    t        |dz         t        t              }d|_        t	        |      }|j                          t               5  |j                          ddd       |j                  j                  }d|v sJ y# 1 sw Y   &xY w)zW
        Check if pyproject.toml is included in source distribution if present
        pyproject.tomlre   N)
rV   r   r   r   r   r   r*   r   rw   rx   r   s        r)   test_pyproject_toml_in_sdistz*TestSdistTest.test_pyproject_toml_in_sdist   sy     	j++,K(%DkW 	GGI	<<%%8+++	 	s   
B  B	c                 x   t        |dz         t        ddd      5 }t        d|       ddd       t        t              }d	|_        t        |      }|j                          t               5  |j                          ddd       |j                  j                  }d|vsJ y# 1 sw Y   zxY w# 1 sw Y   2xY w)
zH
        Check that pyproject.toml can excluded even if present
        r,  r   r   r;   rf   zexclude pyproject.toml)r   Nre   )rV   rC   printr   r   r   r   r   r*   r   rw   rx   )rp   ru   mtsr   rz   r{   s         r)   test_pyproject_toml_excludedz*TestSdistTest.test_pyproject_toml_excluded  s     	j++,-w7 	63*5	6K(%DkW 	GGI	<<%%x///	6 	6	 	s   B$.B0$B-0B9c                    t        |dz         t        i t        ddi      }t        |      }|j	                          t               5  |j                          d d d        |j                  j                  }d|vsJ t        i t        ddi      }|j                  d      }g |j                  d|_
         G d dt              }|j                  j                  |       t        |      }d	|_        |j	                          t               5  |j                          d d d        |j                  j                  }d|v sJ y # 1 sw Y   xY w# 1 sw Y   2xY w)
N.myfile~r   re   build)build_customNc                   $    e Zd Zd Zd Zd Zd Zy)FTestSdistTest.test_build_subcommand_source_files.<locals>.build_customc                      y r!   r   rp   s    r)   initialize_optionszYTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.initialize_options0      r8   c                      y r!   r   r9  s    r)   finalize_optionszWTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.finalize_options2  r;  r8   c                      y r!   r   r9  s    r)   r   zJTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.run4  r;  r8   c                     dgS )Nr3  r   r9  s    r)   get_source_fileszWTestSdistTest.test_build_subcommand_source_files.<locals>.build_custom.get_source_files6  s
    "|#r8   N)r   r   r   r:  r=  r   r@  r   r8   r)   r5  r7  /  s    -+$r8   r5  )r5  T)rV   r   r   r   r   r*   r   rw   rx   get_command_objsub_commandsr   r   updateuse_defaults)rp   ru   r   rz   r{   r4  r5  s          r)   "test_build_subcommand_source_filesz0TestSdistTest.test_build_subcommand_source_files  s<   j:%& F{FM:FGDkW 	GGI	<<%%)) F{FM:FG$$W-Ju11J3IJ	$7 	$ 	,7DkW 	GGI	<<%%X%%%9	 	2	 	s   	EEEEz6os.environ.get('SETUPTOOLS_USE_DISTUTILS') == 'stdlib'c           	          t        i t        dddt        j                  d      iid      }t	        |      }|j                          t               5  |j                          ddd       y# 1 sw Y   yxY w)zS
        Ensure if build_base is a pathlib.Path, the build still succeeds.
        re   r4  
build_base)r   optionsN)r   r   pathlibr   r   r   r*   r   )rp   ru   r   rz   s       r)   test_build_base_pathlibz%TestSdistTest.test_build_base_pathlibC  ss    
  

%,W0E!FG
 
 DkW 	GGI	 	 	s   A--A6N)-r   r   r   r[   fixtureru   r|   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-  r1  rE  skipifrJ  r   r8   r)   ra   ra      s   V^^D! "062 2$	$((0
%

,
N$ ![[X~':':'<=)* > !)*V$2L
&**58&6P - -8 / /@ !3 !3F . .< &2 &2< %2 & 2<   &6  &6>5M@F5#J [[X':'?'?'AB[[@. C.8,0 #&J [[PQ Rr8   ra   c                      t         j                  j                  d      \  } | j                         }t	        |d      sJ y)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ress     r)   test_default_revctrlr]  S  s>       ++	ER '')C3
###r8   c                       e Zd ZdZed        Zej                  j                  dd      d        Z	ed        Z
ej                  j                  dd      d        Zy	)
TestRegressionszp
    Can be removed/changed if the project decides to change how it handles symlinks
    or external files.
    c                 6    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re   z	hello.pyxr   externalprojectr   )tmp_pathdep_paths     r)   &files_for_symlink_in_extension_dependsz6TestRegressions.files_for_symlink_in_extension_dependsn  sI     "~ %* +3 6  3#	
 	
r8   rk  )zmyheaders/dir/file.hzmyheaders/dir/../dir/file.hc                     | j                  ||      }t        j                  j                  |t	        |             t        |dz  |dz         t        ||dz        }dD ]  }||v rJ  y )Nprefixrh  zproject/myheadersri  )zmyproj-42/hello.pyxzmyproj-42/myheaders/dir/file.h)rl  jaracor6   r4  r0   r_   	run_sdist)rp   monkeypatchrj  rk  rx   membersexpecteds          r)   !test_symlink_in_extension_dependsz1TestRegressions.test_symlink_in_extension_depends  sw    
 ;;HhO%H6X
2H?R4RS KI)=>
 	'H w&&		'r8   c                     |j                  d      \  }}}|r| |z  n|}dddiit        dt        |      d      dddd	S )
Nz$tmp_path$/ra  rb  r   rc  rd  re  rf  rg  )r$  r   r0   )rj  rk  headr(  tails        r)   ,files_for_external_path_in_extension_dependsz<TestRegressions.files_for_external_path_in_extension_depends  sq     **=9a&*8d? "~ %* +.h-): ;  3#	
 	
r8   )z$tmp_path$/external/dir/file.hz../external/dir/file.hc                     | j                  ||      }t        j                  j                  |t	        |             t        ||dz        }|D ]  }d|vrJ  y )Nrn  ri  rb  )ry  rp  r6   r4  r0   rq  )rp   rr  rj  rk  rx   rs  r   s          r)   'test_external_path_in_extension_dependsz7TestRegressions.test_external_path_in_extension_depends  s\    
 AA(HU%H6KI)=> 	(D4''	(r8   N)r   r   r   r   staticmethodrl  r[   rM  rN  ru  ry  r{  r   r8   r)   r_  r_  h  s    
 
 
4 [[K'' 
 
: [[P((r8   r_  c                 P   | j                  |       t               5  t        ddg       ddd       t        |dz  j	                  d            }t        j                  t        |            5 }t        |j                               cddd       S # 1 sw Y   gxY w# 1 sw Y   yxY w)z@Given a project directory, run the sdist and return its contentsre   r   Nr   z*.tar.gz)
chdirr*   r   nextglobtarfilerC   r0   setgetnames)rr  ri  archivetars       r)   rq  rq    s    g	 )*wi() Gf$**:67G	c'l	# #s3<<>"# #	) )# #s   B-BBB%c                     t        j                  |       5 }|j                         }d d d        D cg c]	  }d|v s| }}t        |      dk(  s
J d|        y # 1 sw Y   6xY wc c}w )Nz.toxr   z
not empty )r  rC   r  r   )setuptools_sdistr  rx   r   	tox_filess        r)   &test_sanity_check_setuptools_own_sdistr    sn    	&	' 3 #(:$6T>:I:y>Q8*YK 88  ;s   A	A(A(A%)Cr   
contextlibr%   r   r2   rI  r"   r  rJ   r<   inspectr   r   unittestr   jaraco.pathrp  r[   rS   r   r   setuptools._importlibr	   setuptools.command.egg_infor
   setuptools.command.sdistr   setuptools.distr   setuptools.extensionr   setuptools.testsr   textr   	distutilsdistutils.corer   r6   ry   r   rm   r   r   r   rn   contextmanagerr*   r7   r@   rG   rQ   rM  xfailrQ  rT  rP  __package__
startswithrL  rV   r_   ra   r]  r_  rq  r  r   r8   r)   <module>r     s     	  	  
         < * 6 * ( * *   $ !G9-RWW\\#w789:	 
  	WW\\,./WW\\,./	
 %%	(9(99  8 8)	
 $*;;#4#4M6 $5 $   ;;%%+( &   %kk00((66< 1  
O Od$*\( \(~#9r8   