
    5h	              
           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mZ d dlm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Z e ej        dd                    Zdej        v Z ej!        "                    ej#        dk    oe d          Z$ G d d          Z% G d de%          Z& G d de%          Z' ed           ed          d ed           ed          d ed           ed          dd ed          i ed           ed           d! ed          d ed           d"gZ( G d# d$          Z) G d% d&e)          Z*ej!        +                    d'          d(             Z,d) Z-dS )*    N)futures)Path)AnyCallable)ZipFile)path)Requirement)SetuptoolsDeprecationWarning   )DALSz __import__('setuptools').setup()TIMEOUT_BACKEND_TEST180__pypy__win32z_The combination of PyPy + Windows + pytest-xdist + ProcessPoolExecutor is flaky and problematic)reasonc                       e Zd ZddZdS )BuildBackendBase.Nsetuptools.build_metac                 4    || _         |pi | _        || _        d S )N)cwdenvbackend_name)selfr   r   r   s       @lib/python3.11/site-packages/setuptools/tests/test_build_meta.py__init__zBuildBackendBase.__init__&   s"    9"(    )r   Nr   )__name__
__module____qualname__r    r   r   r   r   %   s(        ) ) ) ) ) )r   r   c                   H     e Zd ZdZ fdZdededef         fdZd Z	 xZ
S )BuildBackendzPEP 517 Build Backendc                 n     t                      j        |i | t          j        d          | _        d S )Nr   )max_workers)superr   r   ProcessPoolExecutorpool)r   argskwargs	__class__s      r   r   zBuildBackend.__init__/   s8    $)&)))/A>>>			r   namereturn.c                       fd}|S )<Handles arbitrary function invocations on the build backend.c                     t           j                            j                  }t	          |j        j                  }d }	 j                            t           j	                  
                    t                    } j        j        |g| R i |
                    t                    S # t          j        $ rQ j                            d                               |           t!          j        dt           d           Y d S t          j        j        t(          t*          f$ r t,          rt!          j        d            w xY w)NF)waitz(Backend did not respond before timeout (z s)z3PyPy frequently fails tests with ProcessPoolExector)osr   abspathr   BuildBackendCallerr   r   r(   submitgetpidresultTIMEOUTr   TimeoutErrorshutdown_killpytestxfailprocessBrokenProcessPoolMemoryErrorOSErrorIS_PYPY)r)   kwrootcallerpidr,   r   s        r   methodz(BuildBackend.__getattr__.<locals>.method6   s;   7??48,,D'dh8IJJFC
i&&ry1188AA'ty'BtBBBrBBII'RRR' V V V	"""...

3TTTTUUUUUUO5{GL    XL!VWWWs   A*B/ /AE=Er!   )r   r,   rG   s   `` r   __getattr__zBuildBackend.__getattr__3   s)    	 	 	 	 	 	  r   c                     |d S t          j        t          t                    5  t	          j        |t          j        dk    rt          j        nt          j	                   d d d            d S # 1 swxY w Y   d S )Nnt)

contextlibsuppressProcessLookupErrorrA   r2   killr,   signalSIGTERMSIGKILL)r   rF   s     r   r;   zBuildBackend._killH   s    ;F !3W== 	P 	PGC27d??OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   <A--A14A1)r   r   r    __doc__r   strr   r   rH   r;   __classcell__r+   s   @r   r#   r#   ,   s        ? ? ? ? ? c(:    *P P P P P P Pr   r#   c                   $     e Zd Z fdZd Z xZS )r4   c                      t                      j        |i | | j                            d          \  | _        }| _        d S )N:)r&   r   r   	partitionbackend_obj)r   r)   r*   _r+   s       r   r   zBuildBackendCaller.__init__P   sH    $)&)))373D3N3Ns3S3S0	At///r   c                    t          j        | j                   t           j                            | j                   t          j        | j                  }| j	        rt          || j	                  }n|} t          ||          |i |S )r/   )r2   chdirr   environupdater   	importlibimport_moduler   rZ   getattr)r   r,   r)   rC   modbackends         r   __call__zBuildBackendCaller.__call__U   s    


$(###%d&788 	c4#344GGG%ww%%t2r222r   )r   r   r    r   re   rT   rU   s   @r   r4   r4   O   sL        T T T T T
3 3 3 3 3 3 3r   r4   z
            __import__('setuptools').setup(
                name='foo',
                version='0.0.0',
                py_modules=['hello'],
                setup_requires=['six'],
            )
            C
            def run():
                print('hello')
            setup.pyhello.pyz
            assert __name__ == '__main__'
            __import__('setuptools').setup(
                name='foo',
                version='0.0.0',
                py_modules=['hello'],
                setup_requires=['six'],
            )
            aF  
            variable = True
            def function():
                return variable
            assert variable
            __import__('setuptools').setup(
                name='foo',
                version='0.0.0',
                py_modules=['hello'],
                setup_requires=['six'],
            )
            rh   a  
            # Some packages construct files on the fly, include them in the package,
            # and immediately remove them after `setup()` (e.g. pybind11==2.9.1).
            # Therefore, we cannot use `distutils.core.run_setup(..., stop_after=...)`
            # to obtain a distribution object first, and then run the distutils
            # commands later, because these files will be removed in the meantime.

            with open('world.py', 'w', encoding="utf-8") as f:
                f.write('x = 42')

            try:
                __import__('setuptools').setup(
                    name='foo',
                    version='0.0.0',
                    py_modules=['world'],
                    setup_requires=['six'],
                )
            finally:
                # Some packages will clean temporary files
                __import__('os').unlink('world.py')
            z
        [metadata]
        name = foo
        version = 0.0.0

        [options]
        py_modules=hello
        setup_requires=six
        z7
        def run():
            print('hello')
        )	setup.cfgri   )rj   rh   ri   c                   j   e Zd ZdZd Z ej        e          d             Zd Z	d Z
d Zej                            dd	          d
             Zej                            ddeg          d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z ed          d ed          dZd Z ed          ddd iid!Zd" Zd# Z d$ Z!ej                            d%d&d'ig          d(             Z"ej                            d)d*d+gfd,d+gfd-d+gfd.d+gfd/d+d0gfd1d+gfd2d+gfd3d4gfd5d+d0gfd6d+d0gfd7d+d0gfg          ej                            d8d9d:g          d;                         Z#d< Z$d= Z%d> ed?          iZ&d@ Z'd> edA          iZ(dB Z)ej                            dCdD          dE             Z*dS )FTestBuildMetaBackendr   c                 ,    t          | j                  S )Nr   )r#   r   )r   s    r   get_build_backendz&TestBuildMetaBackend.get_build_backend   s    ):;;;;r   )paramsc              #      K   t          j        |j        t          |                     |                                5  |                                 V  d d d            d S # 1 swxY w Y   d S )N)prefix)r   buildparamrS   as_cwdro   )r   tmpdirrequests      r   build_backendz"TestBuildMetaBackend.build_backend   s      
7=V5555]]__ 	+ 	+((*****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   A##A'*A'c                 x    |                                 }dg}t          |          t          |          k    sJ d S Nsix)get_requires_for_build_wheelsortedr   rx   actualexpecteds       r   !test_get_requires_for_build_wheelz6TestBuildMetaBackend.test_get_requires_for_build_wheel   ?    ;;==7f~~!1!1111111r   c                 x    |                                 }dg}t          |          t          |          k    sJ d S rz   )get_requires_for_build_sdistr}   r~   s       r   !test_get_requires_for_build_sdistz6TestBuildMetaBackend.test_get_requires_for_build_sdist   r   r   c                 D   t           j                            d          }t          j        |           |                    |          }t           j                            ||          }t           j                            |          sJ t           j                            d          rJ t          |          5 }t          |	                                          }d d d            n# 1 swxY w Y   d |D             }d |D             }t          |          dk    sJ d S )Nz	pip-wheelworld.pyc              3   D   K   | ]}|                     d           |V  dS )z.pyNendswith.0fs     r   	<genexpr>z8TestBuildMetaBackend.test_build_wheel.<locals>.<genexpr>  s3      IIqzz%7H7HI!IIIIIIr   c                 <    g | ]}|                     d           |S )rh   r   r   s     r   
<listcomp>z9TestBuildMetaBackend.test_build_wheel.<locals>.<listcomp>	  s)    KKKAJJz4J4JK1KKKr   r   )r2   r   r3   makedirsbuild_wheeljoinisfiler   setnamelistlen)	r   rx   dist_dir
wheel_name
wheel_filezipfilewheel_contentspython_scriptsmoduless	            r   test_build_wheelz%TestBuildMetaBackend.test_build_wheel   sB   7??;//
H"..x88
W\\(J77
w~~j))))) 7>>*-----Z   	5G !1!1!3!344N	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5
 JI^IIIKKnKKK7||q      s   :"C((C,/C,
build_type)wheelsdistc                 f   ddt          d          t          d          d}t          j        |           t          j                            d|z             }|                                 }t          |d|z             } ||          }t          dd	d
          5 }|                    d           d d d            n# 1 swxY w Y    ||          }	t          j        	                    t          j        
                    ||                    sJ ||	k    sJ t          t          j        
                    ||	          d                                            ||          }
|
|	k    sJ t          j                            t          j        
                    ||
                    dk    sJ d S )Nz$from setuptools import setup
setup()z0.0.1zo
                [metadata]
                name = foo
                version = file: VERSION
                
                [build-system]
                requires = ["setuptools", "wheel"]
                build-backend = "setuptools.build_meta"
                )rh   VERSIONrj   pyproject.tomlzpreexisting-build_r   wtutf-8encodingz0.0.2wbr   )r   r   rs   r2   r3   ro   rb   openwriter   r   closegetsize)r   r   
tmpdir_cwdfilesr   rx   build_methodfirst_resultversion_filesecond_resultthird_results              r   %test_build_with_existing_file_presentz:TestBuildMetaBackend.test_build_with_existing_file_present  s   
 @  # 
 
& 	
57??>J#>??..00}h.CDD
 $|H-- )TG444 	(w'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( %X..w~~bgll8\BBCCCCC},,,, 	RW\\(M22D99??AAA#|H--},,,,wrw||HlCCDDqHHHHHHs   B>>CCsetup_scriptNc                    t          d          t          d          dddddddd	d
id}|r||d<   |                                 }|                                5  t          j        |           ddg}t          j                    5  |D ]}t          j        d|t                     |	                    d          }|
                    d          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        t          j                            |d|                    5 }	t          |	                                          }
d d d            n# 1 swxY w Y   t#          t          j                            |d|                    5 }t          |                                          }t'          |                    d          d          }t'          |                    d          d          }t'          |                    d          d          }d d d            n# 1 swxY w Y   |
dhz
  h dk    sJ |h dk    sJ |dk    sJ ddddddt'          t+          d                    z   dt'          t+          d                    z   fD ]}||v sJ ||f            |                                                    d          sJ |                                d k    sJ d S )!Naj  
                [build-system]
                requires = ["setuptools", "wheel"]
                build-backend = "setuptools.build_meta"

                [project]
                name = "foo"
                license = {text = "MIT"}
                description = "This is a Python package"
                dynamic = ["version", "readme"]
                classifiers = [
                    "Development Status :: 5 - Production/Stable",
                    "Intended Audience :: Developers"
                ]
                urls = {Homepage = "http://github.com"}
                dependencies = [
                    "appdirs",
                ]

                [project.optional-dependencies]
                all = [
                    "tomli>=1",
                    "pyscaffold>=4,<5",
                    'importlib; python_version == "2.6"',
                ]

                [project.scripts]
                foo = "foo.cli:main"

                [tool.setuptools]
                zip-safe = false
                package-dir = {"" = "src"}
                packages = {find = {where = ["src"]}}
                license-files = ["LICENSE*"]

                [tool.setuptools.dynamic]
                version = {attr = "foo.__version__"}
                readme = {file = "README.rst"}

                [tool.distutils.sdist]
                formats = "gztar"
                zd
                global-include *.py *.txt
                global-exclude *.py[cod]
                zThis is a ``README``z!---- placeholder MIT license ----fooz__version__ = '0.1'z__version__: strz def main(): print('hello world') )__init__.pyz__init__.pyizcli.pyzdata.txtzpy.typed)r   MANIFEST.inz
README.rstzLICENSE.txtsrcrh   zQ'tool.setuptools.license-files' is deprecated in favor of 'project.license-files'z/`project.license` as a TOML table is deprecatedignoretempfoo-0.1.dist-info/METADATAr   &foo-0.1.dist-info/licenses/LICENSE.txt"foo-0.1.dist-info/entry_points.txtzfoo-0.1/setup.py>   foo-0.1foo-0.1/srcfoo-0.1/src/foofoo-0.1/PKG-INFOfoo-0.1/setup.cfgfoo-0.1/README.rstfoo-0.1/LICENSE.txtfoo-0.1/MANIFEST.infoo-0.1/pyproject.tomlfoo-0.1/src/foo/cli.pyfoo-0.1/src/foo.egg-infofoo-0.1/src/foo/data.txtfoo-0.1/src/foo/py.typedfoo-0.1/src/foo/__init__.pyfoo-0.1/src/foo/__init__.pyi!foo-0.1/src/foo.egg-info/PKG-INFO$foo-0.1/src/foo.egg-info/SOURCES.txt%foo-0.1/src/foo.egg-info/not-zip-safe%foo-0.1/src/foo.egg-info/requires.txt&foo-0.1/src/foo.egg-info/top_level.txt)foo-0.1/src/foo.egg-info/entry_points.txt-foo-0.1/src/foo.egg-info/dependency_links.txt>   
foo/cli.pyfoo/data.txtfoo/py.typedfoo/__init__.pyfoo/__init__.pyifoo-0.1.dist-info/WHEELfoo-0.1.dist-info/RECORDfoo-0.1.dist-info/top_level.txtr   r   r   z!Summary: This is a Python packagezLicense: MITzLicense-File: LICENSE.txtz+Classifier: Intended Audience :: DeveloperszRequires-Dist: appdirszRequires-Dist: ztomli>=1 ; extra == "all"z2importlib; python_version=="2.6" and extra =="all"z$[console_scripts]
foo = foo.cli:main)r   ro   ru   r   rs   warningscatch_warningsfilterwarningsr
   build_sdistr   tarfiler   r2   r   r   getnamesr   r   rS   readr	   stripr   )r   rv   r   r   rx   msgsmsg
sdist_pathr   tarsdist_contentsr   r   metadatalicenseepointslines                    r    test_build_with_pyproject_configz5TestBuildMetaBackend.test_build_with_pyproject_config?  sm    #)+ +X    1>#8$6@ B " k>
 >
~  	- ,E*..00]]__ 
	? 
	?JucAD (** ? ? Y YC+Hc;WXXXX*66v>>
*66v>>
	? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? 
	? \"',,vvzBBCC 	1s 00N	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 RW\\&&*==>> 	W' !1!1!3!344N7<<(DEEwOOHEFF G ',,'KLLgVVG	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W !3 44 9
 9
 9
 
 
 
 
0  "
 "
 "
 
 
 
 
 ===== 0'9$K0K$L$L M MM+RSSTTU	
 
	6 
	6D 8###dH%5####~~(()?@@@@@}}"IIIIIIIs\   ,C4ACC4C!	!C4$C!	%C44C8;C82"E  E$'E$BH00H47H4c                 d   t          d          t          d          t          d          d}|                                 }|                                5  t          j        |           |                    d          }|                    d          }d d d            n# 1 swxY w Y   |dz                                  sJ |dz                                  sJ |dz                                  rJ |d	z                                  rJ |d
z                                  rJ |dz                                  rJ |dz                                  rJ |dz                                  rJ t          j	        t          j                            |d|                    5 }t          |                    d                                          d          }|                                }d|vsJ 	 d d d            n# 1 swxY w Y   t!          t          j                            |d|                    5 }	t          |	                    d          d          }
|	                                }d|vsJ 	 d d d            n# 1 swxY w Y   ||
fD ]}dD ]}||v sJ 	dD ]}||vsJ 	d S )NaR  
                [build-system]
                requires = ["setuptools", "wheel"]
                build-backend = "setuptools.build_meta"

                [project]
                name = "foo"
                description = "This is a Python package"
                version = "42"
                dependencies = ["six"]
                zO
                def run():
                    print('hello')
                z
                __import__('setuptools').setup(
                    name='bar',
                    version='13',
                )
                )r   ri   rh   r   ztemp/foo-42.tar.gzztemp/foo-42-py3-none-any.whlztemp/bar-13.tar.gzztemp/bar-42.tar.gzztemp/foo-13.tar.gzztemp/bar-13-py3-none-any.whlztemp/bar-42-py3-none-any.whlztemp/foo-13-py3-none-any.whlzfoo-42/PKG-INFOr   zbar-13/PKG-INFOzfoo-42.dist-info/METADATAzbar-13.dist-info/METADATA)z	Name: foozVersion: 42)z	Name: barzVersion: 13)r   ro   ru   r   rs   r   r   existsr   r   r2   r   rS   extractfiler   r   r   r   )r   rv   r   rx   r   r   r   pkg_infomembersr   r   filer   s                r   (test_static_metadata_in_pyproject_configz=TestBuildMetaBackend.test_static_metadata_in_pyproject_config  s    #
     )
 
: ..00]]__ 	; 	;Ju&226::J&226::J	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;
 --557777777??AAAAA1199;;;;;1199;;;;;1199;;;;;;;CCEEEEE;;CCEEEEE;;CCEEEEE\"',,vvzBBCC 	4s3??+<==BBDDgNNHllnnG$G33333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4
 RW\\&&*==>> 	>'7<<(CDDgNNH&&((G.g=====	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>
 h& 	( 	(D4 $ $t|||||4 ( (4'''''(	( 	(s7   ?B!!B%(B%'AHHH=>JJJc                    t           j                            d          }t          j        |           |                    |          }t           j                            t           j                            ||                    sJ d S )Nz	pip-sdist)r2   r   r3   r   r   r   r   r   rx   r   
sdist_names       r   test_build_sdistz%TestBuildMetaBackend.test_build_sdist  sh    7??;//
H"..x88
w~~bgll8Z@@AAAAAAAr   c                    t           j                            d          }t          j        |           |                    |          }t           j                            t           j                            ||d                    sJ d S )Npip-dist-infoMETADATA)r2   r   r3   r    prepare_metadata_for_build_wheelr   r   )r   rx   r   	dist_infos       r   %test_prepare_metadata_for_build_wheelz:TestBuildMetaBackend.test_prepare_metadata_for_build_wheel  sj    7???33
H!BB8LL	w~~bgll8Y
KKLLLLLLLr   c                     dD ]}t          j        |d           |                    d          }t           j                            t           j                            |d                    sJ dS )zy
        Some users might pass metadata_directory pre-populated with `.tox` or `.venv`.
        See issue #3523.
        )z?.tox/python/lib/python3.10/site-packages/attrs-22.1.0.dist-infozD.tox/python/lib/python3.10/site-packages/autocommand-2.2.1.dist-infoz>.nox/python/lib/python3.10/site-packages/build-0.8.0.dist-infoz4.venv/python3.10/site-packages/click-8.1.3.dist-infoz5venv/python3.10/site-packages/distlib-0.3.5.dist-infoz4env/python3.10/site-packages/docutils-0.19.dist-infoT)exist_okr   r  N)r2   r   r  r   r   r   )r   rx   pre_existingr  s       r   test_prepare_metadata_inplacez2TestBuildMetaBackend.test_prepare_metadata_inplace  sp    

 	5 	5L Kt44444!BB3GG	w~~bgll9jAABBBBBBBr   c                     t           j                            d          }|                    |          }t           j                            t           j                            ||                    sJ d S )Ndist)r2   r   r3   r   r   r   r   s       r   test_build_sdist_explicit_distz3TestBuildMetaBackend.test_build_sdist_explicit_dist0  sZ     7??6**"..x88
w~~bgll8Z@@AAAAAAAr   c                 "   t           j                            d          }t          j        |           |                    |          }t           j                            t           j                            ||                    sJ t           j                            d          }t           j                            |          st           j                            d          }t          |dd          5 }|	                                }d d d            n# 1 swxY w Y   t          |dd          5 }|
                    |                    dd	                     d d d            n# 1 swxY w Y   t          j        |           t          j        |           |                    d          }t           j                            t           j                            t           j                            d          |                    sJ d S )
N	out_sdistrh   rj   rtr   r   r   zversion='0.0.0'zversion='0.0.1')r2   r   r3   r   r   r   r   r   r   r   r   replaceshutilrmtree)r   rx   sdist_into_directoryr   	setup_locfile_handlercontents          r   test_build_sdist_version_changez4TestBuildMetaBackend.test_build_sdist_version_change7  s,   !w{;;
()))"../CDD
w~~bgll+?LLMMMMM
 GOOJ//	w~~i(( 	544I)TG444 	*"''))G	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*)TG444 	Vw/@BSTTUUU	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	*+++
()))"..{;;
w~~bgll27??;+G+GTTUUUUUUUs$   7DDD5*E++E/2E/c                    t          d          dt          d          d}t          j        |           |                                 }|                    d          }t          j        t          j                            d|                    5 }t          d |
                                D                       sJ 	 d d d            d S # 1 swxY w Y   d S )N
                __import__('setuptools').setup(
                    name='foo',
                    version='0.0.0',
                    py_modules=['hello']
                )r   r   )rh   ri   r   r   c              3      K   | ]}d |v V  	dS )r   Nr!   r   r,   s     r   r   zNTestBuildMetaBackend.test_build_sdist_pyproject_toml_exists.<locals>.<genexpr>g  s(      KKD'4/KKKKKKr   r   r   rs   ro   r   r   r   r2   r   anyr   r   r   r   rx   
targz_pathr   s         r   &test_build_sdist_pyproject_toml_existsz;TestBuildMetaBackend.test_build_sdist_pyproject_toml_existsP  s/     " 
 
$ 	
5..00"..v66
\"',,vz::;; 	LsKKCLLNNKKKKKKKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L   .CCCc                    t          j        t          d                    |                                 }|                    d          }t          j        t          j                             d|                    5 }t          d |
                                D                       sJ 	 d d d            d S # 1 swxY w Y   d S )Nr   r   c              3      K   | ]}d |v V  	dS rh   Nr!   r  s     r   r   zHTestBuildMetaBackend.test_build_sdist_setup_py_exists.<locals>.<genexpr>q  s'      EEdzT)EEEEEEr   )r   rs   defnsro   r   r   r   r2   r   r  r   )r   r   rx   r  r   s        r    test_build_sdist_setup_py_existsz5TestBuildMetaBackend.test_build_sdist_setup_py_existsi  s     	
58..00"..v66
\"',,vz::;; 	FsEEcllnnEEEEEEEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   ;.B77B;>B;c                    t          d          dt          d          d}t          j        |           |                                 }|                    d          }t          j        t          j                            d|                    5 }t          d |
                                D                       rJ 	 d d d            d S # 1 swxY w Y   d S )Nz
        __import__('setuptools').setup(
            name='foo',
            version='0.0.0',
            py_modules=['hello']
        )r   z"
        exclude setup.py
        )rh   ri   r   r   c              3      K   | ]}d |v V  	dS r$  r!   r  s     r   r   zSTestBuildMetaBackend.test_build_sdist_setup_py_manifest_excluded.<locals>.<genexpr>  s'      II$:-IIIIIIr   r  r  s         r   +test_build_sdist_setup_py_manifest_excludedz@TestBuildMetaBackend.test_build_sdist_setup_py_manifest_excludeds  s1       
 
" 	
5..00"..v66
\"',,vz::;; 	JsII#,,..IIIIIIIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Jr!  c                     t          d          dt          d          d}t          j        |           |                                 }|                    d           d S )Nr  r   zE
                [sdist]
                formats=zip
                rh   ri   rj   r   )r   r   rs   ro   r   )r   r   r   rx   s       r   3test_build_sdist_builds_targz_even_if_zip_indicatedzHTestBuildMetaBackend.test_build_sdist_builds_targz_even_if_zip_indicated  st       
 
$ 	
5..00!!&)))))r   z
            __import__('setuptools').setup(
                name='foo',
                version=__import__('hello').__version__,
                py_modules=['hello']
            )z__version__ = "0.0.0"z9
            [sdist]
            formats=zip
            r+  c                     t          j        | j                   |                                 }t	          j        t          d          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nz^No module named 'hello'$matchr   )r   rs   _relative_path_import_filesro   r<   raisesImportErrorr   r   r   rx   s      r   %test_build_sdist_relative_path_importz:TestBuildMetaBackend.test_build_sdist_relative_path_import  s    
43444..00];.IJJJ 	. 	.%%f---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   	A,,A03A0zX
            [project]
            name = "proj"
            version = "42"
            projr   r   )r   r   c                     t          t          |                              d                    }|sJ |D ]5}|                                st	          j        |          j        dk    sJ 6dS )z?All files in the directory should be either links or hard linksz**/*r   N)listr   glob
is_symlinkr2   statst_nlink)r   
parent_dirr   r   s       r   _assert_link_treez&TestBuildMetaBackend._assert_link_tree  sw    T*%%**62233u 	C 	CD??$$B(>(B(B(BB	C 	Cr   c                    t          j        | j                   |                                 }t	          d                                          rJ |                    d           t	          d                                          rJ dS )z
        Sanity check to ensure tests with --mode=strict are different from the ones
        without --mode.

        --mode=strict should create a local directory with a package tree.
        The directory should not get created otherwise.
        rs   r   N)r   rs   _simple_pyproject_examplero   r   r   build_editabler3  s      r   %test_editable_without_config_settingsz:TestBuildMetaBackend.test_editable_without_config_settings  s~     	
41222..00=='')))))$$V,,,=='')))))))r   c                    dddgi}t          j        | j                   |                                 }t	          d                                          rJ t	          d                                           |                    d|           |                    d|           t	          d                                          sJ d S )Nz--build-option	build_extz	--inplacers   zbuild/proj-42-py3-none-any.whl)	r   rs   r?  ro   r   r   mkdirr  r   r   r   config_settingsrx   s       r   test_build_wheel_inplacez-TestBuildMetaBackend.test_build_wheel_inplace  s    +k;-GH
41222..00=='')))))W66wPPP!!'?;;;455<<>>>>>>>r   rF  zeditable-modestrictc                    t          j        i | j        di i           t          d                                          rJ |                                 }|                    d|           |                    d|d           |                     t          t          d          
                    d                               d S )N_metars   r   z__editable__.*)r   rs   r?  r   r   ro   #prepare_metadata_for_build_editabler@  r=  nextr8  rE  s       r   "test_editable_with_config_settingsz7TestBuildMetaBackend.test_editable_with_config_settings  s    
Bd4BgrBBCCC=='')))))..0099'?SSS$$V_gFFFtDMM$6$67G$H$HIIJJJJJr   )setup_literalrequirementsz'foo'r   z['foo']z'foo\n'z	'foo\n\n'z['foo', 'bar']barz'# Has a comment line\nfoo'z'foo # Has an inline comment'z'foo \\\n >=3.0'zfoo>=3.0z
'foo\nbar'z'foo\nbar\n'z['foo\n', 'bar\n']	use_wheelTFc                 :   t          d                              |          t          d          d}t          j        |           |                                 }|r|j        }n|j        }t          |          } |            }	|t          |	          k    sJ d S )Na  
                from setuptools import setup

                setup(
                    name="qux",
                    version="0.0.0",
                    py_modules=["hello"],
                    setup_requires={setup_literal},
                )
            )rN  rf   rg   )r   formatr   rs   ro   r|   r   r}   )
r   rN  rO  rQ  r   r   rx   get_requiresr   r   s
             r   test_setup_requiresz(TestBuildMetaBackend.test_setup_requires  s    & 	  f=f11 
 
* 	
5..00 	F(ELL(EL ,''6&>>))))))r   c                     t          d          t          d          ddd}t          j        |           |                                 }|                                }|dgk    sJ d S )Nzd
                [project]
                name = "proj"
                version = "42"
            z
                __import__('setuptools').setup(
                    setup_requires=["foo"],
                    py_modules = ["hello", "world"]
                )
            z'hello'z'world')r   rh   ri   r   r   )r   r   rs   ro   r|   )r   r   r   rx   setup_requiress        r   'test_setup_requires_with_auto_discoveryz<TestBuildMetaBackend.test_setup_requires_with_auto_discovery&  s    
 #    "!#
 
& 	
5..00&CCEE%((((((r   c                 $   t          d          t          d          d}t          j        |           |                                 }t          j                            d          }t	          j        |           |                    |           d S )NaN  
                        from setuptools import setup

                        setup(
                            name="qux",
                            version="0.0.0",
                            py_modules=["hello"],
                            setup_requires=["does-not-exist >99"],
                        )
                    z[
                    def run():
                        print('hello')
                    rg   r  )r   r   rs   ro   r2   r3   r   r  )r   r   r   rx   r   s        r    test_dont_install_setup_requiresz5TestBuildMetaBackend.test_dont_install_setup_requiresB  s    	   
 
* 	
5..007???33
H 	66x@@@@@r   rh   aD  
            import os
            import sys

            __import__('setuptools').setup(
                name='foo',
                version='0.0.0',
            )

            sys_argv = os.path.abspath(sys.argv[0])
            file_path = os.path.abspath('setup.py')
            assert sys_argv == file_path
            c                     t          j        | j                   |                                 }t	          j        t                    5  |                    d           d d d            d S # 1 swxY w Y   d S Nr   )r   rs   _sys_argv_0_passthroughro   r<   r1  AssertionErrorr   r3  s      r   test_sys_argv_passthroughz.TestBuildMetaBackend.test_sys_argv_passthroughu  s    
4/000..00]>** 	. 	.%%f---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   A**A.1A.a  
            import os
            assert os.path.isabs(__file__)
            __import__('setuptools').setup(
                name='foo',
                version='0.0.0',
                py_modules=['hello'],
                setup_requires=['six'],
            )
            c                     t          j        | j                   |                                 }|                    d           d S r\  )r   rs   _setup_py_file_abspathro   r   r3  s      r   test_setup_py_file_abspathz/TestBuildMetaBackend.test_setup_py_file_abspath  s@    
4.///..00!!&)))))r   
build_hook)r   r   c                     ddi}t          j        |           t          j        d          }t	          j        t          |          5   t          ||          d           d d d            d S # 1 swxY w Y   d S )Nrh   r   zNo distribution was found.r.  r   )r   rs   reescaper<   r1  
ValueErrorrb   )r   rx   rc  r   r   s        r   test_build_with_empty_setuppyz2TestBuildMetaBackend.test_build_with_empty_setuppy  s    R 
5i455]:S111 	7 	7.GM:..v666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   A//A36A3)+r   r   r    r   ro   r<   fixturer%  rx   r   r   r   markparametrizer   SETUP_SCRIPT_STUBr   r   r   r  r	  r  r  r   r&  r)  r,  r   r0  r4  r?  r=  rA  rG  rM  rU  rX  rZ  r]  r_  ra  rb  rh  r!   r   r   rl   rl      s       *L< < < V^5!!!+ + "!+
2 2 2
2 2 2
! ! !( [\+=>>0I 0I ?>0Id [^d4E-FGGOJ OJ HGOJb=( =( =(~B B BM M MC C C"B B BV V V2L L L2F F FJ J J4* * *2 D
 
 ,T
 
# #$. . . $
 
 +,	! 	!C C C* * *? ? ? [./81L0MNNK K ONK [)ug %!E7#u~.+eW5-w7 :,/UEN+uen-"UEN3	
   [[4-88#* #* 98! "#*J) ) )8A A AD 	DD
 
$. . . 	DD	
 
* * *
 [\+IJJ7 7 KJ7 7 7r   rl   c                       e Zd ZdZd Zd ZdS )TestBuildMetaLegacyBackendz setuptools.build_meta:__legacy__c                     t          j        | j                   |                                 }|                    d           d S r\  )r   rs   r0  ro   r   r3  s      r   r4  z@TestBuildMetaLegacyBackend.test_build_sdist_relative_path_import  s@    
43444..00!!&)))))r   c                     t          j        | j                   |                                 }|                    d           d S r\  )r   rs   r]  ro   r   r3  s      r   r_  z4TestBuildMetaLegacyBackend.test_sys_argv_passthrough  s@    
4/000..00!!&)))))r   N)r   r   r    r   r4  r_  r!   r   r   rn  rn    s7        5L* * ** * * * *r   rn  z/ignore::setuptools.SetuptoolsDeprecationWarningc                     |                      |           d}|dz                      t          |          d           t          d          }|                                g k    sJ dS )zHSetuptools should be resilient to setup.py with ``sys.exit(0)`` (#3973).zr
        import sys, setuptools
        setuptools.setup(name='foo', version='0.0.0')
        sys.exit(0)
        rh   r   r   r   rn   N)r]   
write_textr   r#   r|   monkeypatchtmp_pathsetuppyrd   s       r   test_sys_exit_0_in_setuppyrw    sy     hG
 
&&tG}}w&GGG(?@@@G//11R777777r   c                    |                      |           d}|dz                      |d           t          j        t          d          5  t          d          }|                                 d d d            d S # 1 swxY w Y   d S )	Nz"import sys; sys.exit('some error')rh   r   r   z
some errorr.  r   rn   )r]   rr  r<   r1  
SystemExitr#   r|   rs  s       r   test_system_exit_in_setuppyrz    s    h2G
&&w&AAA	z	6	6	6 / /,CDDD,,.../ / / / / / / / / / / / / / / / / /s   %A??BB).rK   r`   r2   re  r  rO   sysr   r   
concurrentr   pathlibr   typingr   r   r   r   r<   jaracor   packaging.requirementsr	   setuptools.warningsr
   textwrapr   rl  intgetenvr8   builtin_module_namesrB   rj  skipifplatform
pytestmarkr   r#   r4   r%  rl   rn  r   rw  rz  r!   r   r   <module>r     s           				 				   



                                            . . . . . . < < < < < <      6  #ibi.66
7
7
0
0 [LG'    
) ) ) ) ) ) ) ) P  P  P  P  P#  P  P  PF3 3 3 3 3) 3 3 3, D	
 	
 D
 
 & D

 

 D
 
 ( D
 
 D
 
 . 	DD
 
4 T

 

 D
 
 ( T

 

 7D
 
 Q|	~t
7 t
7 t
7 t
7 t
7 t
7 t
7 t
7n* * * * *!5 * * *$ MNN
8 
8 ON
8/ / / / /r   