
    7f4              
          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	Z	d dl
mZ d dlmZ d dl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"d$ Z#ej        $                    d%          d&             Z%d' Z&dS )(    N)futures)ZipFile)Path)path   )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       ^/home/feoh/.local/pipx/shared/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                   .     e Zd ZdZ fdZ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   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pidnamer   s        r   methodz(BuildBackend.__getattr__.<locals>.method1   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   rA   rB   s   `` r   __getattr__zBuildBackend.__getattr__.   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ProcessLookupErrorr;   r,   killrA   signalSIGTERMSIGKILL)r   r@   s     r   r5   zBuildBackend._killC   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   rC   r5   __classcell__r'   s   @r   r   r   '   sc        ? ? ? ? ?  *P P P P P P Pr   r   c                   $     e Zd Z fdZd Z xZS )r.   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__K   sH    $)&)))373D3N3Ns3S3S0	At///r   c                    t          j        | j                   t           j                            | j                   t          j        | j                  }| j	        rt          || j	                  }n|} t          ||          |i |S )r)   )r,   chdirr   environupdater   	importlibimport_moduler   rT   getattr)r   rA   r%   r=   modbackends         r   __call__zBuildBackendCaller.__call__P   s    


$(###%d&788 	c4#344GGG%ww%%t2r222r   )r   r   r   r   r_   rN   rO   s   @r   r.   r.   J   sL        T T T T T
3 3 3 3 3 3 3r   r.   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'],
            )
            rb   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.cfgrc   )rd   rb   rc   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paramstras_cwdri   )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   rs   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 ru   )get_requires_for_build_sdistrx   ry   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 )rb   r   r   s     r   
<listcomp>z9TestBuildMetaBackend.test_build_wheel.<locals>.<listcomp>  s)    KKKAJJz4J4JK1KKKr   r   )r,   r   r-   makedirsbuild_wheeljoinisfiler   setnamelistlen)	r   rs   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"
                )rb   VERSIONrd   pyproject.tomlzpreexisting-build_r   wtutf-8encodingz0.0.2wbr   )r   r   rm   r,   r-   ri   r\   openwriter   r   closegetsize)r   r   
tmpdir_cwdfilesr   rs   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          }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 ]}||v sJ 	|                                                    d          sJ |                                dk    sJ d S )Na  
                [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"

                [tool.distutils.bdist_wheel]
                universal = true
                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srcrb   tempfoo-0.1.dist-info/METADATAr   foo-0.1.dist-info/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+Classifier: Intended Audience :: DeveloperszRequires-Dist: appdirsz)Requires-Dist: tomli >=1 ; extra == 'all'zERequires-Dist: importlib ; python_version == "2.6" and extra == 'all'z$[console_scripts]
foo = foo.cli:main)r   ri   rp   r   rm   build_sdistr   tarfiler   r,   r   r   getnamesr   r   ro   readreplacestripr   )r   rq   r   r   rs   
sdist_pathr   tarsdist_contentsr   r   metadatalicenseepointslines                  r    test_build_with_pyproject_configz5TestBuildMetaBackend.test_build_with_pyproject_config:  s    #,. .^    1>#8$6@ B " qA
 A
D  	- ,E*..00]]__ 	; 	;Ju&226::J&226::J	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;
 \"',,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',,'FGGQQG',,'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  "
 "
 "
 
 
 
 
 =====##C,,44S"==
 	$ 	$D 8#####~~(()?@@@@@}}"IIIIIIIs7   ?B%%B),B)#"DDD
BG!!G%(G%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   rc   rb   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   ri   rp   r   rm   r   r   existsr   r   r,   r   ro   extractfiler   r   r   r   )r   rq   r   rs   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)r,   r   r-   r   r   r   r   r   rs   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)r,   r   r-   r    prepare_metadata_for_build_wheelr   r   )r   rs   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)r,   r   r   r   r   r   )r   rs   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)r,   r   r-   r   r   r   r   s       r   test_build_sdist_explicit_distz3TestBuildMetaBackend.test_build_sdist_explicit_dist&  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_sdistrb   rd   rtr   r   r   zversion='0.0.0'zversion='0.0.1')r,   r   r-   r   r   r   r   r   r   r   r   r   shutilrmtree)r   rs   sdist_into_directoryr   	setup_locfile_handlercontents          r   test_build_sdist_version_changez4TestBuildMetaBackend.test_build_sdist_version_change-  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   )rb   rc   r   r   c              3      K   | ]}d |v V  	dS )r   Nr   r   rA   s     r   r   zNTestBuildMetaBackend.test_build_sdist_pyproject_toml_exists.<locals>.<genexpr>]  s(      KKD'4/KKKKKKr   r   r   rm   ri   r   r   r   r,   r   anyr   r   r   r   rs   
targz_pathr   s         r   &test_build_sdist_pyproject_toml_existsz;TestBuildMetaBackend.test_build_sdist_pyproject_toml_existsF  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 rb   Nr   r  s     r   r   zHTestBuildMetaBackend.test_build_sdist_setup_py_exists.<locals>.<genexpr>g  s'      EEdzT)EEEEEEr   )r   rm   defnsri   r   r   r   r,   r   r  r   )r   r   rs   r  r   s        r    test_build_sdist_setup_py_existsz5TestBuildMetaBackend.test_build_sdist_setup_py_exists_  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
        )rb   rc   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_excludedi  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
                rb   rc   rd   r   )r   r   rm   ri   r   )r   r   r   rs   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   rm   _relative_path_import_filesri   r6   raisesImportErrorr   r   r   rs   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_symlinkr,   statst_nlink)r   
parent_dirr   r   s       r   _assert_link_treez&TestBuildMetaBackend._assert_link_tree  sw    T*%%**62233 	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.
        rm   r   N)r   rm   _simple_pyproject_exampleri   r   r   build_editabler*  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	--inplacerm   zbuild/proj-42-py3-none-any.whl)	r   rm   r6  ri   r   r   mkdirr   r   r   r   config_settingsrs   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   r=  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_metarm   r   z__editable__.*)r   rm   r6  r   r   ri   #prepare_metadata_for_build_editabler7  r4  nextr/  r<  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   z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},
                )
            )setup_literalr`   ra   )r   formatr   rm   ri   rw   r   rx   )
r   rH  requirementsrF  r   r   rs   get_requiresr{   rz   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   rb   rc   r   r   )r   r   rm   ri   rw   )r   r   r   rs   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')
                    ra   r   )r   r   rm   ri   r,   r-   r   r   )r   r   r   rs   r   s        r    test_dont_install_setup_requiresz5TestBuildMetaBackend.test_dont_install_setup_requires8  s    	   
 
* 	
5..007???33
H 	66x@@@@@r   rb   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   rm   _sys_argv_0_passthroughri   r6   r(  AssertionErrorr   r*  s      r   test_sys_argv_passthroughz.TestBuildMetaBackend.test_sys_argv_passthroughk  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 rS  )r   rm   _setup_py_file_abspathri   r   r*  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 )Nrb   r   zNo distribution was found.r%  r   )r   rm   reescaper6   r(  
ValueErrorr\   )r   rs   rZ  r   msgs        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   ri   r6   fixturer  rs   r|   r   r   markparametrizer   SETUP_SCRIPT_STUBr   r   r   r   r  r  r  r  r  r   r#  r   r'  r+  r6  r4  r8  r>  rD  rL  rO  rQ  rT  rV  rX  rY  r`  r   r   r   rf   rf      s       *L< < < V^5!!!+ + "!+
2 2 2
2 2 2
! ! !( [\+=>>0I 0I ?>0Id [^d4E-FGGJJ JJ HGJJX=( =( =(~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   rf   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 rS  )r   rm   r'  ri   r   r*  s      r   r+  z@TestBuildMetaLegacyBackend.test_build_sdist_relative_path_import  s@    
43444..00!!&)))))r   c                     t          j        | j                   |                                 }|                    d           d S rS  )r   rm   rT  ri   r   r*  s      r   rV  z4TestBuildMetaLegacyBackend.test_sys_argv_passthrough  s@    
4/000..00!!&)))))r   N)r   r   r   r   r+  rV  r   r   r   rf  rf    s7        5L* * ** * * * *r   rf  c                 P   d}t          j        t          |          dd           g d}|                     ||                                          }d|vsJ d|v sJ i t
          j        dd	i}g d}|                     |||
                                          }d|v sJ d S )Nz
    [build-system]
    requires = ["setuptools"]
    build-backend = "setuptools.build_meta"
    [project]
    name = "myproj"
    version = "42"
    r   )r   zmymod.py)pipinstallz--no-build-isolationz-er   )r   z#running setup.py develop for myprojzcreated wheel for myprojSETUPTOOLS_ENABLE_FEATURESzlegacy-editable)r   r   )r   rm   r   runlowerr,   rX   )venvrq   r   	pyprojectcmdoutputr   s          r   test_legacy_editable_installrs    s    I 	J$y//rBBCCC @
?
?CXXcvX&&,,..F0>>>>%//// JRZ
I57H
I
IC
?
?
?CXXcv3X//5577F0F::::::r   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)
        rb   r   r   r   rh   N)rW   
write_textr   r   rw   monkeypatchtmp_pathsetuppyr^   s       r   test_sys_exit_0_in_setuppyrz    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')rb   r   r   z
some errorr%  r   rh   )rW   ru  r6   r(  
SystemExitr   rw   rv  s       r   test_system_exit_in_setuppyr}    s    h2G
&&w&AAA	z	6	6	6 / /,CDDD,,.../ / / / / / / / / / / / / / / / / /s   %A??BB)'r,   sysr  rJ   r   rZ   rF   
concurrentr   r\  r   r   pathlibr   r6   jaracor   textwrapr   rd  intgetenvr2   builtin_module_namesr<   rb  skipifplatform
pytestmarkr   r   r.   r  rf   rf  rs  filterwarningsrz  r}  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|	~o
7 o
7 o
7 o
7 o
7 o
7 o
7 o
7d* * * * *!5 * * *$; ; ;0 MNN
8 
8 ON
8/ / / / /r   