
    ?wg&              
          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
Z e ej4                  dd            Zdej8                  v Zej<                  j?                  ej@                  dk(  xr 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<                  jS                  d'      d(        Z*d) Z+y)*    N)futures)Path)AnyCallable)ZipFile)path)Requirement   )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y)BuildBackendBaseNc                 6    || _         |xs i | _        || _        y )N)cwdenvbackend_name)selfr   r   r   s       W/var/www/horilla/myenv/lib/python3.12/site-packages/setuptools/tests/test_build_meta.py__init__zBuildBackendBase.__init__#   s    9"(    ).Nsetuptools.build_meta)__name__
__module____qualname__r    r   r   r   r   "   s    )r   r   c                   B     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                 Z    t        |   |i | t        j                  d      | _        y )Nr
   )max_workers)superr   r   ProcessPoolExecutorpool)r   argskwargs	__class__s      r   r   zBuildBackend.__init__,   s'    $)&)//A>	r   namereturn.c                       fd}|S )<Handles arbitrary function invocations on the build backend.c                     t         j                  j                  j                        }t	        |j
                  j                        }d }	 j                  j                  t         j                        j                  t              } j                  j                  |g| i |j                  t              S # t        j                  $ rM j                  j                  d       j                  |       t!        j"                  dt         d       Y y 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>.method3   s   77??488,D'dhh8I8IJFC
ii&&ryy188A'tyy''BtBrBII'RR'' V		""".

3GyPSTUOO55{GL LL!VWs   A/B? ?AE"AE"r    )r   r+   rF   s   `` r   __getattr__zBuildBackend.__getattr__0   s    	  r   c                     |y t        j                  t        t              5  t	        j
                  |t        j                  dk(  rt        j                  nt        j                         d d d        y # 1 sw Y   y xY w)Nnt)

contextlibsuppressProcessLookupErrorr@   r1   killr+   signalSIGTERMSIGKILL)r   rE   s     r   r:   zBuildBackend._killE   sV    ;  !3W= 	PGGC277d?O	P 	P 	Ps   AA33A<)r   r   r   __doc__r   strr   r   rG   r:   __classcell__r*   s   @r   r"   r"   )   s-    ? c(: *Pr   r"   c                   $     e Zd Z fdZd Z xZS )r3   c                 v    t        |   |i | | j                  j                  d      \  | _        }| _        y )N:)r%   r   r   	partitionbackend_obj)r   r(   r)   _r*   s       r   r   zBuildBackendCaller.__init__M   s8    $)&)373D3D3N3Ns3S0	At/r   c                 >   t        j                  | j                         t         j                  j	                  | j
                         t        j                  | j                        }| j                  rt        || j                        }n|} t        ||      |i |S )r.   )r1   chdirr   environupdater   	importlibimport_moduler   rY   getattr)r   r+   r(   rB   modbackends         r   __call__zBuildBackendCaller.__call__R   sw    



$((#%%d&7&78c4#3#34GG%ww%t2r22r   )r   r   r   r   rd   rS   rT   s   @r   r3   r3   L   s    T
3r   r3   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'],
            )
            rg   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.cfgrh   )ri   rg   rh   c                   0   e Zd ZdZd Z ej                  e      d        Zd Z	d Z
d Zej                  j                  dd	      d
        Zej                  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                  j                  d%d&d'ig      d(        Z"ej                  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                  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                  j                  dCdD      dE        Z*y)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        |             |j	                         5  | j                          d d d        y # 1 sw Y   y xY ww)N)prefix)r   buildparamrR   as_cwdrn   )r   tmpdirrequests      r   build_backendz"TestBuildMetaBackend.build_backend   sH     

7==V5]]_ 	+((**	+ 	+ 	+s   ;A%A	A%A"A%c                 \    |j                         }dg}t        |      t        |      k(  sJ y Nsix)get_requires_for_build_wheelsortedr   rw   actualexpecteds       r   !test_get_requires_for_build_wheelz6TestBuildMetaBackend.test_get_requires_for_build_wheel   .    ;;=7f~!1111r   c                 \    |j                         }dg}t        |      t        |      k(  sJ y ry   )get_requires_for_build_sdistr|   r}   s       r   !test_get_requires_for_build_sdistz6TestBuildMetaBackend.test_get_requires_for_build_sdist   r   r   c                 B   t         j                  j                  d      }t        j                  |       |j	                  |      }t         j                  j                  ||      }t         j                  j                  |      sJ t         j                  j                  d      rJ t        |      5 }t        |j                               }d d d        d D        }|D cg c]  }|j                  d      r| }	}t        |	      dk(  sJ y # 1 sw Y   DxY wc c}w )Nz	pip-wheelworld.pyc              3   D   K   | ]  }|j                  d       s|  yw)z.pyN)endswith).0fs     r   	<genexpr>z8TestBuildMetaBackend.test_build_wheel.<locals>.<genexpr>  s     Iqzz%7H!Is     rg   r
   )r1   r   r2   makedirsbuild_wheeljoinisfiler   setnamelistr   len)
r   rw   dist_dir
wheel_name
wheel_filezipfilewheel_contentspython_scriptsr   moduless
             r   test_build_wheelz%TestBuildMetaBackend.test_build_wheel   s    77??;/
H"..x8
WW\\(J7
ww~~j))) 77>>*---Z  	5G !1!1!34N	5
 J^I,KAJJz4J1KK7|q   	5 	5 Ls   3D"D9DD
build_type)wheelsdistc                    ddt        d      t        d      d}t        j                  |       t        j                  j	                  d|z         }| j                         }t        |d|z         } ||      }t        dd	d
      5 }|j                  d       d d d         ||      }	t        j                  j                  t        j                  j                  ||            sJ ||	k7  sJ t        t        j                  j                  ||	      d      j                           ||      }
|
|	k(  sJ t        j                  j                  t        j                  j                  ||
            dkD  sJ y # 1 sw Y   xY w)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"
                )rg   VERSIONri   pyproject.tomlzpreexisting-build_r   wtutf-8encodingz0.0.2wbr   )r   r   rr   r1   r2   rn   ra   openwriter   r   closegetsize)r   r   
tmpdir_cwdfilesr   rw   build_methodfirst_resultversion_filesecond_resultthird_results              r   %test_build_with_existing_file_presentz:TestBuildMetaBackend.test_build_with_existing_file_present	  sV   
 @ #
& 	

577??>J#>?..0}h.CD
 $H- )TG4 	(w'	( %X.ww~~bggll8\BCCC},,, 	RWW\\(M2D9??A#H-},,,wwrww||HlCDqHHH	( 	(s   E88Fsetup_scriptNc                 v   t        d      t        d      dddddddd	d
id}|r||d<   | j                         }|j                         5  t        j                  |       |j                  d      }|j                  d      }d d d        t        j                  t        j                  j                  |d            5 }t        |j                               }d d d        t        t        j                  j                  |d            5 }	t        |	j                               }
t        |	j!                  d      d      }t        |	j!                  d      d      }t        |	j!                  d      d      }d d d        dhz
  h dk(  sJ 
h dk(  sJ dk(  sJ dddddt        t#        d            z   dt        t#        d            z   fD ]  }|v rJ ||f        j%                         j'                  d      sJ j%                         dk(  sJ y # 1 sw Y   xY w# 1 sw Y   LxY w# 1 sw Y   xY w)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srcrg   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: ztomli>=1 ; extra == "all"z2importlib; python_version=="2.6" and extra =="all"z$[console_scripts]
foo = foo.cli:main)r   rn   rt   r   rr   build_sdistr   tarfiler   r1   r   r   getnamesr   r   rR   readr	   stripr   )r   ru   r   r   rw   
sdist_pathr   tarsdist_contentsr   r   metadatalicenseepointslines                  r    test_build_with_pyproject_configz5TestBuildMetaBackend.test_build_with_pyproject_config<  si    #)+X   1>#8$6@ B "k>
~  ,E*..0]]_ 	;JJu&226:J&226:J	;
 \\"'',,vvzBC 	1s 0N	1 RWW\\&&*=> 	W' !1!1!34N7<<(DEwOH',,'FGQG',,'KLgVG		W !3 44 9
 
 	
 
0  "
 
 	
 
 ==== 09$K0K$L MM+RSTU
 		6D 8#5dH%55#		6 ~~(()?@@@}}"IIIIC	; 	;
	1 	1	W 	Ws%   
8H>H"
A+H/H"H,/H8c                    t        d      t        d      t        d      d}| j                         }|j                         5  t        j                  |       |j                  d      }|j                  d      }d d d        |dz  j                         sJ |dz  j                         sJ |dz  j                         rJ |d	z  j                         rJ |d
z  j                         rJ |dz  j                         rJ |dz  j                         rJ |dz  j                         rJ t        j                  t        j                  j                  |d            5 }t        |j                  d      j                         d      }|j                         }d|vsJ 	 d d d        t!        t        j                  j                  |d            5 }	t        |	j                  d      d      }
|	j#                         }d|vsJ 	 d d d        
fD ]  }dD ]  }||v rJ  dD ]  }||vrJ   y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   FxY w)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   rh   rg   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   rn   rt   r   rr   r   r   existsr   r   r1   r   rR   extractfiler   r   r   r   )r   ru   r   rw   r   r   r   pkg_infomembersr   r   filer   s                r   (test_static_metadata_in_pyproject_configz=TestBuildMetaBackend.test_static_metadata_in_pyproject_config  sp    #
  )
: ..0]]_ 	;JJu&226:J&226:J	;
 --5577777??AAA1199;;;1199;;;1199;;;;;CCEEE;;CCEEE;;CCEEE\\"'',,vvzBC 	4s3??+<=BBDgNHllnG$G333	4
 RWW\\&&*=> 	>'7<<(CDgNH&&(G.g===	>
 h& 	(D4 $t|#|$4 (4'''(	(1	; 	;	4 	4
	> 	>s%   8H0A H=2I	0H:=I	Ic                    t         j                  j                  d      }t        j                  |       |j	                  |      }t         j                  j                  t         j                  j                  ||            sJ y )Nz	pip-sdist)r1   r   r2   r   r   r   r   r   rw   r   
sdist_names       r   test_build_sdistz%TestBuildMetaBackend.test_build_sdist  sU    77??;/
H"..x8
ww~~bggll8Z@AAAr   c                    t         j                  j                  d      }t        j                  |       |j	                  |      }t         j                  j                  t         j                  j                  ||d            sJ y )Npip-dist-infoMETADATA)r1   r   r2   r    prepare_metadata_for_build_wheelr   r   )r   rw   r   	dist_infos       r   %test_prepare_metadata_for_build_wheelz:TestBuildMetaBackend.test_prepare_metadata_for_build_wheel
  sW    77???3
H!BB8L	ww~~bggll8Y
KLLLr   c                     dD ]  }t        j                  |d        |j                  d      }t         j                  j	                  t         j                  j                  |d            sJ y)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)r1   r   r   r   r   r   )r   rw   pre_existingr   s       r   test_prepare_metadata_inplacez2TestBuildMetaBackend.test_prepare_metadata_inplace  sZ    

 	5L KKt4	5 "BB3G	ww~~bggll9jABBBr   c                     t         j                  j                  d      }|j                  |      }t         j                  j	                  t         j                  j                  ||            sJ y )Ndist)r1   r   r2   r   r   r   r   s       r   test_build_sdist_explicit_distz3TestBuildMetaBackend.test_build_sdist_explicit_dist#  sK     77??6*"..x8
ww~~bggll8Z@AAAr   c                    t         j                  j                  d      }t        j                  |       |j	                  |      }t         j                  j                  t         j                  j                  ||            sJ t         j                  j                  d      }t         j                  j                  |      st         j                  j                  d      }t        |dd      5 }|j                         }d d d        t        |dd      5 }|j                  j                  dd	             d d d        t        j                  |       t        j                  |       |j	                  d      }t         j                  j                  t         j                  j                  t         j                  j                  d      |            sJ y # 1 sw Y   xY w# 1 sw Y   xY w)
N	out_sdistrg   ri   rtr   r   r   zversion='0.0.0'zversion='0.0.1')r1   r   r2   r   r   r   r   r   r   r   r   replaceshutilrmtree)r   rw   sdist_into_directoryr   	setup_locfile_handlercontents          r   test_build_sdist_version_changez4TestBuildMetaBackend.test_build_sdist_version_change*  s`   !ww{;
()"../CD
ww~~bggll+?LMMM
 GGOOJ/	ww~~i(4I)TG4 	*"'')G	*)TG4 	Vw/@BSTU	V 	*+
()"..{;
ww~~bggll277??;+GTUUU	* 	*	V 	Vs   0G"G%G"%G.c                 v   t        d      dt        d      d}t        j                  |       | j                         }|j	                  d      }t        j                  t        j                  j                  d|            5 }t        d |j                         D              sJ 	 d d d        y # 1 sw Y   y xY w)N
                __import__('setuptools').setup(
                    name='foo',
                    version='0.0.0',
                    py_modules=['hello']
                )r   r   )rg   rh   r   r   c              3   $   K   | ]  }d |v  
 yw)r   Nr    r   r+   s     r   r   zNTestBuildMetaBackend.test_build_sdist_pyproject_toml_exists.<locals>.<genexpr>Z  s     KD'4/K   r   r   rr   rn   r   r   r   r1   r   anyr   r   r   r   rw   
targz_pathr   s         r   &test_build_sdist_pyproject_toml_existsz;TestBuildMetaBackend.test_build_sdist_pyproject_toml_existsC  s     "
$ 	

5..0"..v6
\\"'',,vz:; 	LsKCLLNKKKK	L 	L 	L   #B//B8c                 T   t        j                  t        d          | j                         }|j	                  d      }t        j                  t        j                   j                  d|            5 }t        d |j                         D              sJ 	 d d d        y # 1 sw Y   y xY w)Nr   r   c              3   $   K   | ]  }d |v  
 ywrg   Nr    r  s     r   r   zHTestBuildMetaBackend.test_build_sdist_setup_py_exists.<locals>.<genexpr>d  s     EdzT)Er  )r   rr   defnsrn   r   r   r   r1   r   r  r   )r   r   rw   r  r   s        r    test_build_sdist_setup_py_existsz5TestBuildMetaBackend.test_build_sdist_setup_py_exists\  s     	

58..0"..v6
\\"'',,vz:; 	FsEcllnEEEE	F 	F 	Fs   1#BB'c                 v   t        d      dt        d      d}t        j                  |       | j                         }|j	                  d      }t        j                  t        j                  j                  d|            5 }t        d |j                         D              rJ 	 d d d        y # 1 sw Y   y xY w)Nz
        __import__('setuptools').setup(
            name='foo',
            version='0.0.0',
            py_modules=['hello']
        )r   z"
        exclude setup.py
        )rg   rh   r   r   c              3   $   K   | ]  }d |v  
 ywr  r    r  s     r   r   zSTestBuildMetaBackend.test_build_sdist_setup_py_manifest_excluded.<locals>.<genexpr>~  s     I$:-Ir  r  r  s         r   +test_build_sdist_setup_py_manifest_excludedz@TestBuildMetaBackend.test_build_sdist_setup_py_manifest_excludedf  s      
" 	

5..0"..v6
\\"'',,vz:; 	JsI#,,.IIIII	J 	J 	Jr  c                     t        d      dt        d      d}t        j                  |       | j                         }|j	                  d       y )Nr  r   zE
                [sdist]
                formats=zip
                rg   rh   ri   r   )r   r   rr   rn   r   )r   r   r   rw   s       r   3test_build_sdist_builds_targz_even_if_zip_indicatedzHTestBuildMetaBackend.test_build_sdist_builds_targz_even_if_zip_indicated  sR     
$ 	

5..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                         | j                         }t	        j
                  t        d      5  |j                  d       d d d        y # 1 sw Y   y xY w)Nz^No module named 'hello'$matchr   )r   rr   _relative_path_import_filesrn   r;   raisesImportErrorr   r   r   rw   s      r   %test_build_sdist_relative_path_importz:TestBuildMetaBackend.test_build_sdist_relative_path_import  sT    

4334..0]];.IJ 	.%%f-	. 	. 	.s   A&&A/zX
            [project]
            name = "proj"
            version = "42"
            projr   r   )r   r   c                     t        t        |      j                  d            }|sJ |D ]7  }|j                         rt	        j
                  |      j                  dkD  r7J  y)z?All files in the directory should be either links or hard linksz**/*r   N)listr   glob
is_symlinkr1   statst_nlink)r   
parent_dirr   r   s       r   _assert_link_treez&TestBuildMetaBackend._assert_link_tree  sY    T*%**623u 	CD??$(>(>(BBB	Cr   c                     t        j                  | j                         | j                         }t	        d      j                         rJ |j                  d       t	        d      j                         rJ y)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.
        rr   r   N)r   rr   _simple_pyproject_examplern   r   r   build_editabler)  s      r   %test_editable_without_config_settingsz:TestBuildMetaBackend.test_editable_without_config_settings  sa     	

4112..0='')))$$V,=''))))r   c                 T   dddgi}t        j                  | j                         | j                         }t	        d      j                         rJ t	        d      j                          |j                  d|       |j                  d|       t	        d      j                         sJ y )Nz--build-option	build_extz	--inplacerr   zbuild/proj-42-py3-none-any.whl)	r   rr   r5  rn   r   r   mkdirr   r   r   r   config_settingsrw   s       r   test_build_wheel_inplacez-TestBuildMetaBackend.test_build_wheel_inplace  s    +k;-GH

4112..0='')))W66wP!!'?;45<<>>>r   r<  zeditable-modestrictc                 R   t        j                  i | j                  di i       t        d      j	                         rJ | j                         }|j                  d|       |j                  d|d       | j                  t        t        d      j                  d                   y )N_metarr   r   z__editable__.*)r   rr   r5  r   r   rn   #prepare_metadata_for_build_editabler6  r3  nextr.  r;  s       r   "test_editable_with_config_settingsz7TestBuildMetaBackend.test_editable_with_config_settings  s    

Bd44BgrBC='')))..099'?S$$V_gFtDM$6$67G$HI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      j                  |      t        d      d}t        j                  |       | j	                         }|r|j
                  }n|j                  }t        |      } |       }	|t        |	      k(  sJ y )Na  
                from setuptools import setup

                setup(
                    name="qux",
                    version="0.0.0",
                    py_modules=["hello"],
                    setup_requires={setup_literal},
                )
            )rD  re   rf   )r   formatr   rr   rn   r{   r   r|   )
r   rD  rE  rG  r   r   rw   get_requiresr   r~   s
             r   test_setup_requiresz(TestBuildMetaBackend.test_setup_requires  s    & 	 f=f1
* 	

5..0(EEL(EEL ,'6&>)))r   c                     t        d      t        d      ddd}t        j                  |       | j                         }|j	                         }|dgk(  sJ y )Nzd
                [project]
                name = "proj"
                version = "42"
            z
                __import__('setuptools').setup(
                    setup_requires=["foo"],
                    py_modules = ["hello", "world"]
                )
            z'hello'z'world')r   rg   rh   r   r   )r   r   rr   rn   r{   )r   r   r   rw   setup_requiress        r   'test_setup_requires_with_auto_discoveryz<TestBuildMetaBackend.test_setup_requires_with_auto_discovery  si    
 #  "!#
& 	

5..0&CCE%(((r   c                    t        d      t        d      d}t        j                  |       | j                         }t        j                  j                  d      }t	        j                  |       |j                  |       y )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')
                    rf   r   )r   r   rr   rn   r1   r2   r   r   )r   r   r   rw   r   s        r    test_dont_install_setup_requiresz5TestBuildMetaBackend.test_dont_install_setup_requires5  so    	 
* 	

5..077???3
H 	66x@r   rg   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                         | j                         }t	        j
                  t              5  |j                  d       d d d        y # 1 sw Y   y xY wNr   )r   rr   _sys_argv_0_passthroughrn   r;   r'  AssertionErrorr   r)  s      r   test_sys_argv_passthroughz.TestBuildMetaBackend.test_sys_argv_passthroughh  sQ    

4//0..0]]>* 	.%%f-	. 	. 	.s   	A$$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                         | j                         }|j	                  d       y rR  )r   rr   _setup_py_file_abspathrn   r   r)  s      r   test_setup_py_file_abspathz/TestBuildMetaBackend.test_setup_py_file_abspath}  s0    

4../..0!!&)r   
build_hook)r   r   c                     ddi}t        j                  |       t        j                  d      }t	        j
                  t        |      5   t        ||      d       d d d        y # 1 sw Y   y xY w)Nrg   r   zNo distribution was found.r$  r   )r   rr   reescaper;   r'  
ValueErrorra   )r   rw   rY  r   msgs        r   test_build_with_empty_setuppyz2TestBuildMetaBackend.test_build_with_empty_setuppy  s[    R 

5ii45]]:S1 	7.GM:.v6	7 	7 	7s   
A&&A/)+r   r   r   r   rn   r;   fixturer  rw   r   r   r   markparametrizer   SETUP_SCRIPT_STUBr   r   r   r   r   r  r  r  r  r  r"  r   r&  r*  r5  r3  r7  r=  rC  rK  rN  rP  rS  rU  rW  rX  r_  r    r   r   rk   rk      s   *L< V^^5!+ "+
2
2
!( [[\+=>0I ?0Id [[^d4E-FGEJ HEJN=(~BMC"BV2L2FJ4*2 
 ,
#$. 
 +,	!C*? [[./81L0MNK OK [[)ug %!E7#u~.+eW5-w7 :,/UEN+uen-"UEN3	
  [[[4-8#* 9!"#*J)8AD 	D
$. 	D	
*
 [[\+IJ7 K7r   rk   c                       e Zd ZdZd Zd Zy)TestBuildMetaLegacyBackendz setuptools.build_meta:__legacy__c                     t        j                  | j                         | j                         }|j	                  d       y rR  )r   rr   r&  rn   r   r)  s      r   r*  z@TestBuildMetaLegacyBackend.test_build_sdist_relative_path_import  s0    

4334..0!!&)r   c                     t        j                  | j                         | j                         }|j	                  d       y rR  )r   rr   rS  rn   r   r)  s      r   rU  z4TestBuildMetaLegacyBackend.test_sys_argv_passthrough  s0    

4//0..0!!&)r   N)r   r   r   r   r*  rU  r    r   r   re  re    s    5L**r   re  c                 0   d}t        j                  t        |      dd       g d}| j                  ||      j	                         }d|vsJ d|v sJ i t
        j                  dd	i}g d}| j                  |||
      j	                         }d|v sJ y )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   rr   r   runlowerr1   r]   )venvru   r   	pyprojectcmdoutputr   s          r   test_legacy_editable_installrr    s    I 	JJ$y/rBC @CXXcvX&,,.F0>>>%/// JRZZ
I57H
IC
?CXXcv3X/557F0F:::r   z/ignore::setuptools.SetuptoolsDeprecationWarningc                     | j                  |       d}|dz  j                  t        |      d       t        d      }|j	                         g k(  sJ y)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)
        rg   r   r   r   rm   N)r\   
write_textr   r"   r{   monkeypatchtmp_pathsetuppyrc   s       r   test_sys_exit_0_in_setuppyry    sY     hG
 
&&tG}w&G(?@G//1R777r   c                     | j                  |       d}|dz  j                  |d       t        j                  t        d      5  t        d      }|j                          d d d        y # 1 sw Y   y xY w)	Nz"import sys; sys.exit('some error')rg   r   r   z
some errorr$  r   rm   )r\   rt  r;   r'  
SystemExitr"   r{   ru  s       r   test_system_exit_in_setuppyr|    sg    h2G
&&w&A	z	6 /,CD,,./ / /s   A++A4),rJ   r_   r1   r[  r  rN   sysr   
concurrentr   pathlibr   typingr   r   r   r   r;   jaracor   packaging.requirementsr	   textwrapr   rc  intgetenvr7   builtin_module_namesrA   ra  skipifplatform
pytestmarkr   r"   r3   r  rk   re  rr  filterwarningsry  r|  r    r   r   <module>r     s     	 	   
         . 6  ibii.6
7
00
0 [[LLG'   
) ) P#  PF3) 3, 	
 
& 

 
( 
 
. 	D
4 

 
( 

 7
Q|	~j
7 j
7Z*!5 *$;0 MN
8 O
8/r   