
    n&ph{              
         S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKrS SKrS SKrS SKJr  S SKJr  S SK J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  S SK)J*r*  S SK+J,r,  S SK-J.r.  SSK/J0r0J1r1  S SK2J3r3  \Rh                  " SS/S9S 5       r5\" S5      \" S5      Rm                  5       SSS\" S5      \" S5      SSS .0S!.r7S"r8\Rr                  Ru                  \R                  S#:H  S$S%9\Rr                  Rw                  S&0 \7ES'\80E\7/5      S( 5       5       r<S) r=S* r> " S+ S,5      r? " S- S.5      r@S/ rA " S0 S15      rBS2 rC " S3 S45      rD " S5 S65      rE\Rr                  R                  S75      S8 5       rG\Rr                  R                  S9 5       rI " S: S;5      rJ " S< S=5      rK " S> S?5      rLS@ rM\Rr                  R                  SA5      SB 5       rNSC rOSD rPSE rQSHSF jrRSISG jrSg)J    )annotationsN)deepcopy)import_module)EXTENSION_SUFFIXES)Path)dedent)Any)Mock)uuid4)	resources)_encode_pth_find_namespaces_find_package_roots_find_virtual_namespaces_finder_template	_LinkTree_TopLevelFindereditable_wheel)Distribution)	Extension)SetuptoolsDeprecationWarning   )contexts
namespaces)	run_setupstrictlenient)paramsc                .    U R                   S:X  a  SS/$ / $ )Nr   --config-settingseditable-mode=strict)param)requests    Y/var/www/html/venv/lib/python3.13/site-packages/setuptools/tests/test_editable_install.pyeditable_optsr%   *   s    }} #%;<<I    a          [build-system]
        requires = ["setuptools"]
        build-backend = "setuptools.build_meta"

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

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

        [tool.setuptools.dynamic]
        readme = {file = "README.rst"}

        [tool.distutils.egg_info]
        tag-build = ".post0"
        zr        global-include *.py *.txt
        global-exclude *.py[cod]
        prune dist
        prune build
        zThis is a ``README``z!---- placeholder MIT license ----mypkga                  import sys
                from importlib.metadata import PackageNotFoundError, version

                try:
                    __version__ = version(__name__)
                except PackageNotFoundError:
                    __version__ = "unknown"
                a                  from importlib.resources import read_text
                from . import __version__, __name__ as parent
                from .mod import x

                data = read_text(parent, "data.txt")
                print(__version__, data, x)
                zx = ''zHello World)__init__.pyz__main__.pymod.pyzdata.txt)pyproject.tomlMANIFEST.inz
README.rstzLICENSE.txtsrcz __import__('setuptools').setup()darwinpypa/setuptools#4328reasonfilessetup.pyc           	        U S-  nUR                  5         [        R                  R                  X$S9  SSSSSS[	        U5      /UQn[        UR                  U5      5        / S	QnUR                  U5      R                  5       S
:X  d   eUS-  R                  SSS9  US-  R                  SSS9  UR                  U5      R                  5       S:X  d   eg )Nr'   prefixpython-mpipinstall--no-build-isolation-e)r6   r7   r'   z3.14159.post0 Hello Worldzsrc/mypkg/data.txtfoobarutf-8encodingzsrc/mypkg/mod.pyx = 42z3.14159.post0 foobar 42)	mkdirjaracopathbuildstrprintrunstrip
write_text)tmp_pathvenvr1   r%   projectcmds         r$   test_editable_with_pyprojectrN   {   s      GMMO
KKe, 	G	 
	C 
$((3-
#C88C= $????##//7/K!!--h-I88C= $====r&   c           	        S[        S5      SS0SS.0n[        R                  R                  X0S9  U S-  nSS	S
SSS[	        U5      /UQn[        UR                  U5      5        / SQnUR                  U5      R                  5       S:X  d   eg )Nr'   ac                  [build-system]
                requires = ["setuptools", "wheel"]
                build-backend = "setuptools.build_meta"

                [project]
                name = "mypkg"
                version = "3.14159"

                [tool.setuptools]
                packages = ["pkg"]
                py-modules = ["mod"]
                r(   za = 4b = 2)r*   pkgr)   r4   r6   r7   r8   r9   r:   r;   )r6   -cz$import pkg, mod; print(pkg.a, mod.b)z4 2r   rB   rC   rD   rE   rF   rG   rH   rJ   rK   r%   r1   rL   rM   s         r$   test_editable_with_flat_layoutrU      s    $ "7+#
E* KKe- G 	G	 
	C 
$((3-
BC88C= E)))r&   c           	        S[        S5      SS.0n[        R                  R                  X0S9  U S-  nSSSS	S
S[	        U5      /UQn[        UR                  U5      5        / SQnUR                  U5      R                  5       S:X  d   eg )Nr'   a>                  [build-system]
                requires = ["setuptools", "wheel"]
                build-backend = "setuptools.build_meta"

                [project]
                name = "mod"
                version = "3.14159"

                [tool.setuptools]
                py-modules = ["mod"]
                rP   )r*   r)   r4   r6   r7   r8   r9   r:   r;   )r6   rR   zimport mod; print(mod.b)2rS   rT   s         r$    test_editable_with_single_modulerX      s    $ 
E& KKe- G 	G	 
	C 
$((3-
6C88C= C'''r&   c                      \ rS rSrS r\R                  R                  SS5      \R                  R                  SS5      S 5       5       rSr	g	)
TestLegacyNamespaces   c                Z   [         R                  " [        SS9nUS-  nUR                  5         SnU H  n[        R
                  " XSS9nU   UR                  5        nUR                  U5        [        SSS	9n	[        U	5      n
U
R                  5         U
R                  S
5      R                  nU
R                  XK5        S S S 5        S S S 5        M     [        UR                  S5      5      n[!        U5      [!        U5      :X  d   eg ! , (       d  f       NO= f! , (       d  f       M  = f)Nz .*namespace_packages parameter.*matchz.installation_dir)z	myns.pkgAz	myns.pkgBmyns.n.pkgAmyns.n.pkgB42)versionr2   config)
stop_after	dist_infoz*-nspkg.pth)pytestwarnsr   rA   r   build_namespace_packagecontextchdirr   r   finalize_optionsget_finalized_commandname_install_namespaceslistgloblen)selfrJ   monkeypatchdeprecationinstallation_direxamplesrm   rQ   ctxdistrM   editable_namer1   s                r$   test_nspkg_file_is_unique.TestLegacyNamespaces.test_nspkg_file_is_unique   s    ll(0R
 $&99 
 D44XTRCk113s		# A$T*$$& # 9 9+ F K K''(8H 4  %**=9:5zS]*** 43s%   DA#D
D

DD
D*	impl)pkg_resourcesns)zmyns.nc           
        Sn[         R                  " X# S3US9n[         R                  " X# S3US9nUS-  R                  USS9  US-  R                  USS9  USS n	U	R                  S	5        UR	                  S
SSS[        U5      /U	Q5        UR	                  S
SSSS[        U5      /U	Q5        UR	                  S
SSU SU S3/5        UR	                  / SQ5        g)a  
Installing two packages sharing the same namespace, one installed
naturally using pip or `--single-version-externally-managed`
and the other installed in editable mode should leave the namespace
intact and both packages reachable by import.
(Ported from test_develop).
zq        [build-system]
        requires = ["setuptools"]
        build-backend = "setuptools.build_meta"
        z.pkgA)r|   z.pkgBr*   r=   r>   Nr:   r6   r7   r8   r9   r;   rR   zimport z.pkgA; import )r6   rR   zimport pkg_resources)r   rh   rI   appendrG   rE   )
rr   rK   rJ   r~   r|   r%   build_systempkg_Apkg_Boptss
             r$   !test_namespace_package_importable6TestLegacyNamespaces.test_namespace_package_importable  s    $
 228t5\PTU228t5\PTU	!	!--lW-M	!	!--lW-MQ*+(D%CJFFG(D%D#e*LtLM(DGB4~bT"GHI9:r&    N)
__name__
__module____qualname____firstlineno__rz   rf   markparametrizer   __static_attributes__r   r&   r$   rZ   rZ      sM    +4 [[	
 [[T;/; 0;r&   rZ   c                  &    \ rS rSrS rS rS rSrg)TestPep420Namespacesi,  c           
     8   [         R                  " US5      n[         R                  " US5      nUSS nUR                  S5        UR                  SSSS[	        U5      /UQ5        UR                  SSSSS	[	        U5      /UQ5        UR                  / S
Q5        g)z
Installing two packages sharing the same namespace, one installed
normally using pip and the other installed in editable mode
should allow importing both packages.
r_   r`   Nr:   r6   r7   r8   r9   r;   )r6   rR   z&import myns.n.pkgA; import myns.n.pkgB)r   build_pep420_namespace_packager   rG   rE   )rr   rK   rJ   r%   r   r   r   s          r$   r   6TestPep420Namespaces.test_namespace_package_importable-  s     99(MR99(MRQ*+(D%CJFFG(D%D#e*LtLMKLr&   c           
        S[        S5      SS0S.0n[        R                  R                  XBS9  US-  n[        R
                  " US5      n[        R
                  " US5      nUS	S	 nUR                  S
5        UR                  SSSS[        U5      /UQ5        UR                  SSSSS[        U5      /UQ5        UR                  SSSSS[        U5      /UQ5        UR                  / SQ5        g	)z@Currently users can create a namespace by tweaking `package_dir`pkgAat                      [build-system]
                    requires = ["setuptools", "wheel"]
                    build-backend = "setuptools.build_meta"

                    [project]
                    name = "pkgA"
                    version = "3.14159"

                    [tool.setuptools]
                    package-dir = {"myns.n.pkgA" = "src"}
                    r(   a = 1)r*   r,   r4   r`   zmyns.n.pkgCNr:   r6   r7   r8   r9   r;   )r6   rR   z#from myns.n import pkgA, pkgB, pkgC)	r   rB   rC   rD   r   r   r   rG   rE   )	rr   rK   rJ   r%   r1   r   r   pkg_Cr   s	            r$   &test_namespace_created_via_package_dir;TestPep420Namespaces.test_namespace_created_via_package_dir<  s     "(# &w/
& 	%16!99(MR99(MR Q*+(D%CJFFG(D%D#e*LtLM(D%D#e*LtLMHIr&   c                r   S[        S5      SSSSS.S.[        S   S	.0n[        R                  R	                  X2S
9  US-  nS/nUR                  SSSSSS[        U5      /UQ5        UR                  / SQ5      nUR                  5       S:X  d   eSnUR                  SS[        U5      /5      nSU;   d   eg)a  Sometimes users might specify an ``include`` pattern that ignores parent
packages. In a normal installation this would ignore all modules inside the
parent packages, and make them namespaces (reported in issue #3504),
so the editable mode should preserve this behaviour.
r   ar                      [build-system]
                    requires = ["setuptools", "wheel"]
                    build-backend = "setuptools.build_meta"

                    [project]
                    name = "pkgA"
                    version = "3.14159"

                    [tool.setuptools]
                    packages.find.include = ["mypkg.*"]
                     zb = 1r   )r(   zpkgA.py)r(   zother.pynr+   )r*   r'   r+   r4   r:   r6   r7   r8   -vr9   r;   )r6   rR   z'from mypkg.n import pkgA; print(pkgA.a)1z}        try:
            import mypkg.other
        except ImportError:
            print("mypkg.other not defined")
        rR   zmypkg.other not definedN)r   EXAMPLErB   rC   rD   rG   rE   rH   )rr   rK   rJ   r1   r   r   outrM   s           r$   0test_namespace_accidental_config_in_lenient_modeETestPep420Namespaces.test_namespace_accidental_config_in_lenient_mode^  s     "(# $& '')#*  '}5/
6 	%16! ''(D%y$E
RTRShhRSyy{c!!! hh$s45(C///r&   r   N)r   r   r   r   r   r   r   r   r   r&   r$   r   r   ,  s    M JD00r&   r   c           
        U S-  n[         R                   Vs/ s H\  nSU;   d  M  UR                  [         R                  5      (       d  M1  U[	        U5      R                  [         R                  5      -  PM^     nnU H  nUR                  SS9  M     [        U5        [        [        R                  [        R                  R                  [        [        U5      5      S9n[         R                  SSSS	[        U5      S
[        U5      S/	UQn[         R"                  " XS9  [$        R&                  " 5       S:X  a  SOSn	X9-  S-  n
[         R"                  " U
/US9  gs  snf )z6
Editable install to a prefix should be discoverable.
r5   zsite-packagesT)parents)
PYTHONPATHr7   r8   r9   
--editablez--prefixr:   )envWindowsScriptsbinsampleN)sysrC   
startswithr5   r   relative_torA   _addsitedirsdictosenvironpathsepjoinmaprE   
executable
subprocess
check_callplatformsystem)rJ   sample_projectr%   r5   rC   site_packages_allspr   rM   r   exes              r$   test_editable_with_prefixr     s8     F
 HHDd" 	4'+szz'B 	4d''

33    
   "#
rzzbjjooc#?P6Q&R
SCNF 
C #'  (I5)5C
,
!C3%S)=s   
E"E/Ec                  Z    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)TestFinderTemplatei  This test focus in getting a particular implementation detail right.
If at some point in time the implementation is changed for something different,
this test can be modified or even excluded.
c                4    0 n[        XU5        US   " 5         g )Nr9   )exec)rr   finderlocs      r$   install_finder!TestFinderTemplate.install_finder  s    V#Ir&   c                   SSSS0S.0SS0S.n[         R                  R                  X!S	9  [        US
-  5      [        US-  5      S.n[	        [        [        5       5      U0 5      n[        R                  " 5          [        R                  " 5          S H#  n[        R                  R                  US 5        M%     U R                  U5        [        S5      n[        S5      n[        S5      nUR                  S:X  d   eUR                  S:X  d   e[        US-  R                  5       5      n	[!        X5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Npkg1r   mod1.pyza = 42)r(   subpkgmod2.pyza = 43src1src2r4   z	src1/pkg1z	src2/mod2)r   mod2)r   pkg1.subpkgpkg1.subpkg.mod1r   r   r   r   *   +   zsrc1/pkg1/subpkg)rB   rC   rD   rE   r   r   r   
save_pathssave_sys_modulesr   modulespopr   r   aresolveassert_path)
rr   rJ   r1   mappingtemplatemodmod1r   r   expecteds
             r$   test_packages TestFinderTemplate.test_packages  s;    #%((3 )
 	%1 ;./;./
 $CL'2>  "H$=$=$?JT* K ) !34D (D"=1F66R<<66R<<H'99BBDEH) %@""$?$?""s%   <EB'E
9E

E	E
E)c                   SSSS.0n[         R                  R                  X!S9  S[        US-  5      0nS/ 0n[	        [        [        5       5      X45      n[        R                  " 5          [        R                  " 5          S H#  n[        R                  R                  US 5        M%     U R                  U5        [        S5      n[        R                  " U5      S	-  n[        US-  R!                  5       5      n	[#        Xy5        UR$                  S
:X  d   eUR'                  SS9S:X  d   e S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NrQ   a = 13abc)r(   text.txtr4   ns.othernamer~   r~   r   r      r=   r>   )rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   importlib_resourcesr1   r   r   r   	read_text)
rr   rJ   r1   r   r   r   r   rQ   textr   s
             r$   test_namespace!TestFinderTemplate.test_namespace  s   eDE%1!3x%'7#89BZ
#CL'F  "H$=$=$?-T* . )/C&,,S1J>DHu,5578H&55B;; >>7>3u<<< %@""$?$?""s%   +EB-E /E 
E	
E
Ec                    SSSS000SSS00S.n[         R                  R                  X!S9  [        US	-  5      [        US
-  5      S.nS[        US-  5      [        US-  5      /0n[	        [        [        5       5      X45      n[        R                  " 5          [        R                  " 5          S H#  n[        R                  R                  US 5        M%     U R                  U5        [        S5      n[        S5      n[        US	-  R                  5       5      n	[        Xy5        UR                   S:X  d   eUR"                  S:X  d   e S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr~   r   r(   r   r   b = 37r   r4   zsrc1/ns/pkg1zsrc2/ns)ns.pkgAr~   r   r   )r~   r   ns.mod2r   r   r   %   )rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   b)
rr   rJ   r1   r   namespaces_r   r   r   r   r   s
             r$   test_combine_namespaces*TestFinderTemplate.test_combine_namespaces  sJ   F]H$=>?Ix01
 	%1 8n45h*+
 c(V"34c(V:K6LMN#CL'G  "H$=$=$?3T* 4 ) +D +DH~5>>@AH'66R<<66R<< %@""$?$?""s%   E/0BEE/
E,	(E//
E=c                z   SSS00SSS00S.n[         R                  R                  5       nUR                  U5         [         R                  R	                  U5        SS	S
S.SS/S.n[        U5      n[        U[        [        5       5      5      n[        S UR                  5        5       5      nSSS5        [        R                  " 5          [        R                  " 5          WS    H#  n[        R                  R!                  US5        M%     U R#                  W5        [%        S5      n	[%        S5      n
[        US-  R'                  5       5      n[        [)        U	R*                  5      R'                  5       5      U:X  d   e[        US-  R'                  5       5      n[        [)        U
R*                  5      R'                  5       5      U:X  d   eU	R,                  S:X  d   eU
R.                  S:X  d   e SSS5        SSS5        g! , (       d  f       GN`= f! , (       d  f       N)= f! , (       d  f       g= f)zw
Users may attempt to combine namespace packages in a nested way via
``package_dir`` as shown in pypa/setuptools#4248.

my_packagezmy_module.pyr   my_package2zmy_module2.pyr   )r,   r   	%PEP 517%zsrc/my_packagezsrc2/my_package2)different_namedifferent_name.subpkgr   r   )script_namepackage_dirpackagesc              3  Z   #    U  H!  u  pUR                  S 5      (       d  M  Uv   M#     g7f)z.pyNendswith).0kvs      r$   	<genexpr>DTestFinderTemplate.test_combine_namespaces_nested.<locals>.<genexpr>.  s"     W&AdaQZZPUEV&As   +	+Nr  zdifferent_name.my_modulez different_name.subpkg.my_module2zsrc/my_package/my_module.pyzsrc2/my_package2/my_module2.pyr   r   )rB   rC   DirectoryStackri   rD   r   r   rE   r   nextget_implementationr   r   r   r   r   r   r   r   r   r   __file__r   r   )rr   rJ   r1   stackattrsrx   r   coder   r   r   r   s               r$   test_combine_namespaces_nested1TestFinderTemplate.test_combine_namespaces_nested  s    !>8"<="_h$?@

 **,]]8$KKe$*&6-?  ./FGE  &D$T3uw<8FWf&?&?&AWWD %   "H$=$=$?Z(T* ) % !;<D !CDDH'DDMMOPHtDMM*2245AAAH'GGPPRSHtDMM*2245AAA66R<<66R<< %@"" %$ %@$?""s1   A3H	H,#DH8H,	
H
H)	%H,,
H:c                t   SSSS000SSSS000SSSS000S	.n[         R                  R                  X!S
9  0 nS[        US-  5      /0n[	        [        [        5       5      X45      nS S 5       n[        R                  " 5          [        R                  " 5          SSS/UQ7 H#  n[        R                  R                  US 5        M%     U R                  U5        [        S5      nUR                  S:X  d   e[        R                   " ["        5         [        S5        S S S 5        [        R                  R%                  [        US-  5      5        [        S5      n	U	R                  S:X  d   e[        R                   " ["        5         [        S5        S S S 5        [        R                  R%                  [        US-  5      5        [        S5      n
U
R                  S:X  d   e S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       Ny= f! , (       d  f       N9= f! , (       d  f       g = f)Nparentchildzone.pyx = 1ztwo.pyx = 2zthree.pyzx = 3)project1project2project3r4   zproject1/parentc              3  ,   #    U  H
  nS U 3v   M     g7f)zparent.child.Nr   )r  rm   s     r$   r  CTestFinderTemplate.test_dynamic_path_computation.<locals>.<genexpr>M  s     K3J4-v&3J   )onetwothreezparent.childzparent.child.oner   zparent.child.twor     zparent.child.threer     )rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   xrf   raisesImportErrorr   )rr   rJ   r1   r   r   r   modsr   r  r  r   s              r$   test_dynamic_path_computation0TestFinderTemplate.test_dynamic_path_computationA  s    "Gh-@#AB!Gh-@#AB!Gj'-B#CD

 	%1#h1B&B"C!DE#CL'GK3JK  "H$=$=$? ..H4HT* I ) 23C55A::{+01 , HHOOC: 567 23C55A::{+23 , HHOOC: 567!"67E77a<<+ %@"" ,+ ,+! %@$?""sW   H)A8HG6A*HHAH%H)6
H H
HH
H&	"H))
H7c                @   SSS00n[         R                  R                  X!S9  S[        US-  5      0n[	        [        [        5       5      U0 5      n[        R                  " 5          [        R                  " 5          [        R                  R                  SS 5        U R                  U5        [        R                  " [        SS9   [!        S5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)NrQ   r(   zfrom . import pkgr4   r]   rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   rf   r$  r%  r   rr   rJ   r1   r   r   s        r$   test_no_recursion$TestFinderTemplate.test_no_recursione  s     2

 	%1 3x%'(
 $CL'2>  "H$=$=$?KKOOE4(){%8e$ 9	 %@"" 98	 %@$?""s=   'D=AC>C-C>D-
C;7C>>
D	D
Dc                   SSSS0S.0n[         R                  R                  X!S9  S[        US-  5      0n[	        [        [        5       5      U0 5      n[        R                  " 5          [        R                  " 5          [        R                  R                  SS 5        [        R                  R                  SS 5        U R                  U5        [        R                  " [        SS9   [!        S5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)	Nfoor   r(   )r(   barr4   zfoo.barr<   r]   r*  r+  s        r$   test_similar_name$TestFinderTemplate.test_similar_namez  s    !!2
 	%1 3x%'(
 $CL'2>  "H$=$=$?KKOOE4(KKOOIt,){(;h' < %@""
 <; %@$?""s=   *D2 A+D!+D7D!?D2
DD!!
D/	+D22
E c                   SSSSSS.S.0n[         R                  R                  X!S9  S[        US-  5      0n[	        [        [        5       5      U0 5      n[        R                  " 5          [        R                  " 5          [        R                  R                  SS 5        U R                  U5        [        R                  " [        SS	9   [!        S
5        S S S 5        [        R                  " [        SS	9   [!        S5        S S S 5        [        R                  " [        SS	9   [!        S5        S S S 5        [        R                  " [        SS	9   [!        S5        S S S 5        [        R                  " [        SS	9   [!        S5        S S S 5        [!        S5      nUR"                  S:X  d   e[!        S5      nUR"                  S:X  d   e S S S 5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nm= f! , (       d  f       g = f)Nr/  r   r  r  )r(   lowercase.py)r(   r4  r0  r4   z'FOO'r]   FOOz'foo\.LOWERCASE'zfoo.LOWERCASEz'foo\.bar\.Lowercase'zfoo.bar.Lowercasez
'foo\.BAR'zfoo.BAR.lowercasezFOO.bar.lowercasezfoo.lowercaser   zfoo.bar.lowercaser!  )rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   rf   r$  r%  r   r#  )rr   rJ   r1   r   r   r   s         r$   test_case_sensitivity(TestFinderTemplate.test_case_sensitivity  s   ! '#%$+	
 	%13x%'(
 $CL'2>  "H$=$=$?KKOOE4(){':e$ ; {2EFo. G {2KL12 M {-@12 A {':12 ;  0C55A:: 34C55A::/ %@"" ;: GF ML A@ ;:! %@$?""s   ,IAH7G!!H7:G3!H7'H3!H7H !H7H&AH7I!
G0+H73
H=H7
HH7
H#H7&
H40H77
I	I
Ic                T   SSSSS.S.0n[         R                  R                  X!S9  S[        US-  5      0nS	/ 0n[	        [        [        5       5      X45      n[        R                  " 5          [        R                  " 5          S
 H#  n[        R                  R                  US 5        M%     U R                  U5        [        S5      n[        US-  R                  5       5      n[        Xx5        UR                   S:X  d   e[        S5      n	U	R"                  S:X  d   e[        S5      n
U
R$                  S:X  d   e[&        R(                  " [*        SS9   [        S5        S S S 5        [&        R(                  " [*        SS9   [        S5        S S S 5        [&        R(                  " [*        SS9   [        S5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       Ny= f! , (       d  f       N]= f! , (       d  f       NA= f! , (       d  f       NJ= f! , (       d  f       g = f)NrQ   r   r   zc = 42)r(   zbar.py)r(   r/  r4   r   r~   r   r   zns.othername.foor   zns.othername.foo.barr   z'NS'r]   zNS.othername.fooz'ns\.othername\.FOO\'zns.othername.FOOz'ns\.othername\.foo\.BAR\'zns.othername.foo.BAR)rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   crf   r$  r%  )rr   rJ   r1   r   r   r   r   rQ   r   r/  r0  s              r$   test_namespace_case_sensitivity2TestFinderTemplate.test_namespace_case_sensitivity  s   '#+&
 	%1!3x%'7#89BZ
#CL'F  "H$=$=$?-T* . )/CHu,5578H&55B;; 23C55B;; 67C55B;;{&901 : {2LM01 N {2RS45 T- %@""  :9 NM TS- %@$?""sm   .HCHG"!HG&!H0G7<HH
G#H&
G40H7
HH
H	H
H'c                   SSSSSSS0S.00n[         R                  R                  X!S	9  S[        US
-  5      0n[	        [        [        5       5      U0 5      n[        R                  " 5          [        R                  " 5          S H#  n[        R                  R                  US5        M%     U R                  U5        [        S5      nUR                  S:X  d   e[        S5      nUR                  S:X  d   e[         R"                  " [$        5         [        S5        SSS5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g= f)zp
The finder should not import ``fullname`` if the intermediate segments
don't exist (see pypa/setuptools#4019).
r,   r'   r   r   zb = 13	config.pyza = 37)r(   r=  zhelloworld.py
componentsr4   z	src/mypkg)r'   zmypkg.configmypkg.helloworldzmypkg.componentsmypkg.components.configmypkg.components.helloworldNr@  r   r?  r   rA  )rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   r   r   rf   r$  r%  )rr   rJ   r1   r   r   r   rc   
helloworlds           r$   test_intermediate_packages-TestFinderTemplate.test_intermediate_packages  s,    #%!)%-#X#		
 	%1C; 678#CL'2>  "H$=$=$? T* )"#<=F88r>!>&'9:J<<2%%%{+;< ,' %@""& ,+' %@$?""s=   .EBE	D8E	'E8
EE		
E	E
E(r   N)r   r   r   r   __doc__r   r   r   r   r  r'  r,  r1  r6  r:  rC  r   r   r&   r$   r   r     sC    

*@=. 6) V" H%*(0'R'6R*=r&   r   c           
        SS0SS.SSS0S.SS	SS
000SS0SS0SS0S.n[         R                  R                  XS9  SSSS.n/ SQn[        X2U 5      nU[	        U S-  5      [	        U S-  5      [	        U S-  5      [	        U S-  5      [	        U S-  5      [	        U S-  5      S.:X  d   e[        [        [        X45      5      5      nUSS1:X  d   e[        [        U5      5      nU1 Sk:X  d   eg)r   r(   zab = 1r   )r   r(   zd = 1zde = 1)r(   eghzfgh = 1zabc = 1z
abcxyz = 1z	mnopq = 1)r   dfotheranotheryet_anotherr4   rL  rM  rN  )a.b.ca.b.c.x.y.z	m.n.o.p.q)r   a.brO  	a.b.c.x.yrP  rJ  zd.erK  f.gzf.g.hrQ  r   rJ  rK  )r   rO  rP  rJ  rK  rQ  rT  >   mrR  m.nm.n.oa.b.c.xm.n.o.prS  N)	rB   rC   rD   r   rE   setr   r   r   )rJ   r1   r   r  rootsr~   s         r$   test_pkg_rootsr\    s5    "8,WE$M8+DEC-345+!<0%{3E KKe- "K
H  x@EC X'(8i/0C C M12    
T"834	5B#u	%e,	-BPPPPr&   c            
         \ rS rSr% Sr\" \5      \S   SSSSSSS.S	.S
.rS\S'   \\" \5      \S   SS\S   0S.\" \5      \" S5      -   \S   SS\S   S   S.\S   S   S.\" \5      \S   SS\S   S   \S   S   S.0S.S.r	\
R                  R                  \R                  S:H  SS9\
R                  R                  S\	R!                  5       5      S 5       5       rSrg)TestOverallBehaviouriB  z        [build-system]
        requires = ["setuptools"]
        build-backend = "setuptools.build_meta"

        [project]
        name = "mypkg"
        version = "3.14159"
        r+   r   zvar = 42zvar = 13resource 39)r(   r   zresource_file.txt)r(   r   
subpackage)r*   r+   otherfile.pyr'   zdict[str, Any]FLAT_LAYOUTr'   )r*   r+   ra  r,   z                [tool.setuptools]
                packages = ["mypkg", "mypkg.subpackage"]

                [tool.setuptools.package-dir]
                "mypkg.subpackage" = "other"
                r   )r(   r   r`  )r*   r+   ra  r'   rL  )r   r`  )flat-layout
src-layoutcustom-layout	namespacer-   r.   r/   layoutc                   [        SX!U R                  U   /UQ76 u  pVSnUR                  SS[        U5      /5      nSU;   d   eSn	UR                  SS[        U	5      /5      nSU;   d   eSn
UR                  SS[        U
5      /5      nS	U;   d   e[	        UR                  S
5      5      n[	        UR                  S5      5      n[	        UR                  S5      5      nUR                  SSS9  UR                  SSS9  UR                  SSS9  UR                  SS[        U	5      /5      nSU;  d   eSU;   d   eUR                  SS[        U
5      /5      nS	U;  d   eSU;   d   eg )Nr'   zj        try:
            import otherfile
        except ImportError as ex:
            print(ex)
        r6   rR   zNo module named 'otherfile'zy        import mypkg, mypkg.mod1, mypkg.subpackage.mod2
        print(mypkg.mod1.var, mypkg.subpackage.mod2.var)
        z42 13z        import mypkg.subpackage
        from setuptools._importlib import resources as importlib_resources
        text = importlib_resources.files(mypkg.subpackage) / "resource_file.txt"
        print(text.read_text(encoding="utf-8"))
        r_  
**/mod1.py
**/mod2.py**/resource_file.txtzvar = 17r=   r>   z	var = 781zresource 374z17 781)install_projectEXAMPLESrG   r   r  rp   rI   )rr   rJ   rK   rg  r%   rL   _cmd_import_errorr   cmd_get_varscmd_get_resourcer   r   resource_files                 r$   test_editable_install*TestOverallBehaviour.test_editable_install  s    %TT]]6%:
=J


 hh$/?(@AB,333 hh$|(<=>#~~ hh$/?(@AB### GLL./GLL./W\\*@AB
W5g6  ' Bhh$|(<=>c!!!3hh$/?(@ABC'''$$$r&   r   N)r   r   r   r   	PYPROJECTr   r   rb  __annotations__rm  rf   r   xfailr   r   r   keysrs  r   r   r&   r$   r^  r^  B  s\   I !+}-!!%%2
	#K   #$Y/"=1[12	
 %Y/	 #=1!&w/	: !),7#
( %Y/"=1*73I>"-g"6|"D	

7&HP [[s||x/8NO[[Xx}}70% 8 P0%r&   r^  c                      \ rS rSr\" \R                  S   5      r\S==   \" S5      -  ss'   S\S   S   S'   S	 r	S
 r
Srg)TestLinkTreei  rd  r*   a[          [tool.setuptools]
        # Temporary workaround: both `include-package-data` and `package-data` configs
        # can be removed after #3260 is fixed.
        include-package-data = false
        package-data = {"*" = ["*.txt"]}

        [tool.setuptools.packages.find]
        where = ["src"]
        exclude = ["*.subpackage*"]
        r   r,   r'   resource.not_in_manifestc                d   [         R                  R                  U R                  US9  [	        U5         Sn[        SS05      nUR                  5         [        5       nUS-  nUS-  nUR                  5         UR                  5         UR                  S5      nSUl
        [        U5      Ul        UR                  5         UR                  5       nUR                  5       n	[!        X2XV5      n
U
" XHU	5        [#        UR%                  S	5      5      nUS
-  n['        X5        [#        UR%                  S5      S 5      b   e[#        UR%                  S5      S 5      b   e[#        UR%                  S5      S 5      b   e[#        UR%                  S5      S 5      b   e S S S 5        g ! , (       d  f       g = f)Nr4   zmypkg-3.14159r   r   z.auxz.buildbuild_pyTri  zsrc/mypkg/mod1.pyz**/subpackagerj  rk  z**/resource.not_in_manifest)rB   rC   rD   FILES_Pathr   parse_config_filesr
   rA   get_command_objeditable_moderE   	build_libensure_finalizedget_outputsget_output_mappingr   r  rp   assert_link_to)rr   rJ   rm   rx   wheelauxrD   r}  outputsoutput_mapping	make_treer   r   s                r$   test_generated_tree TestLinkTree.test_generated_tree  su   $**X68_"D <=D##%FEV#Cx'EIIKKKM++J7H%)H"!$UH%%'**,G%88:N!$c9Ien5./D"55H4*148@@@.5===!78$?GGG!>?FNNN; __s   E#F!!
F/c                   SS/n[        SX!U R                  /UQ76   UR                  / SQ5      nSU;   d   eSnUR                  SS[        U5      /5      nS	U;   d   eS
nUR                  SS[        U5      /5      nSU;   d   eSU;   d   eg )Nr    r!   r'   r6   rR   z(import mypkg.mod1; print(mypkg.mod1.var)ra   zv        try:
            from mypkg import subpackage
        except ImportError as ex:
            print(ex)
        r6   rR   cannot import name 'subpackage'a8          import mypkg
        from setuptools._importlib import resources as importlib_resources
        try:
            text = importlib_resources.files(mypkg) / "resource.not_in_manifest"
            print(text.read_text(encoding="utf-8"))
        except FileNotFoundError as ex:
            print(ex)
        zNo such file or directoryr{  )rl  r~  rG   r   )rr   rJ   rK   r   r   ro  rq  s          r$   test_strict_install TestLinkTree.test_strict_install  s    #%;<CdChhSTs{{ hh$/?(@AB0C777 hh$/?(@AB*c111)S000r&   r   N)r   r   r   r   r   r^  rm  r~  r   r  r  r   r   r&   r$   rz  rz    sW    )22<@AE	
v
	   9>E%L45 OD1r&   rz  z9ignore:.*compat.*:setuptools.SetuptoolsDeprecationWarningc                T   SS/n[         R                  S   n[        SXU/UQ76   UR                  / SQ5      nSU;   d   e[	        [        U 5      5      nS H'  n[	        UR                  SS	U/5      5      nXT;   a  M'   e   S
nUR                  SS	[        U5      /5      nSU;   d   eg )Nr    zeditable-mode=compatre  r'   r  ra   )z"import otherfile; print(otherfile)zimport other; print(other)zimport mypkg; print(mypkg)r6   rR   zc    try:
        from mypkg import subpackage;
    except ImportError as ex:
        print(ex)
    r  )r^  rm  rl  rG   comparable_pathrE   r   )rJ   rK   r   r1   r   expected_pathrM   s          r$   test_compat_installr    s      !78D ))/:EGTU:T:
((O
PC3;;#CM2M
 dhh$'<=>###C ((HdF3K0
1C,333r&   c                    SSSSSSU /UQnUR                  U[        R                  S9  UR                  / SQ5      nS	U;   d   eg
)z3Ensure editable installs work with pbr, issue #3500r6   r7   r8   r   r9   r   stderr)r6   rR   zimport mypkg.hellozHello world!N)rG   r   STDOUT)pbr_packagerK   r%   rM   r   s        r$   test_pbr_integrationr  .  s_     		 
	C 	HHS**H+
((9
:CS   r&   c                  T    \ rS rSrSr0 \R                  S   ES\" S5      0ErS r	Sr
g)	TestCustomBuildPyi@  a  
Issue #3501 indicates that some plugins/customizations might rely on:

1. ``build_py`` not running
2. ``build_py`` always copying files to ``build_lib``

During the transition period setuptools should prevent potential errors from
happening due to those assumptions.
rc  r2   af              import pathlib
            from setuptools import setup
            from setuptools.command.build_py import build_py as orig

            class my_build_py(orig):
                def run(self):
                    super().run()
                    raise ValueError("TEST_RAISE")

            setup(cmdclass={"build_py": my_build_py})
            c                    [        SX!U R                  5      u  p4SU;   d   eSU;   d   eUR                  / SQ5      nSU;   d   eg)z>Ensure that errors in custom build_py are reported as warningsr'   r   zValueError: TEST_RAISEr  ra   N)rl  r~  rG   )rr   rJ   rK   rn  r   s        r$   test_safeguarded_from_errors.TestCustomBuildPy.test_safeguarded_from_errors_  sO     !$$**E-444'3...hhSTs{{r&   r   N)r   r   r   r   rE  r^  rm  r   r~  r  r   r   r&   r$   r  r  @  s:    

'
'
6F
E$r&   r  c                       \ rS rSrS rS rSrg)TestCustomBuildWheelij  c                X    UR                  S5      n " S SU5      nX1R                  S'   g )Nbdist_wheelc                  (   ^  \ rS rSrU 4S jrSrU =r$ )ETestCustomBuildWheel.install_custom_build_wheel.<locals>.MyBdistWheelin  c                d   > U R                   R                  S5      (       a  Sn[        TU ]  5       $ )Nzmacosx-zmacOS platform)	plat_namer   superget_tag)rr   rn  	__class__s     r$   r  MTestCustomBuildWheel.install_custom_build_wheel.<locals>.MyBdistWheel.get_tago  s,     >>,,Y77(Aw((r&   r   )r   r   r   r   r  r   __classcell__)r  s   @r$   MyBdistWheelr  n  s    ) )r&   r  )get_command_classcmdclass)rr   rx   bdist_wheel_clsr  s       r$   install_custom_build_wheel/TestCustomBuildWheel.install_custom_build_wheelk  s,    00?	)? 	) (4m$r&   c                f   [         R                  R                  SS05        [        5       nSUl        UR                  5         U R                  U5        [        U5      nUR                  5         UR                  5         [        [        [        5       R                  S5      5      5      nSU;   d   eg )N	module.pyr@   r2   
dist/*.whleditable)rB   rC   rD   r   r   set_defaultsr  r   r  rG   rE   r  r   rp   )rr   
tmpdir_cwdrx   rM   
wheel_files        r$   test_access_plat_name*TestCustomBuildWheel.test_access_plat_namex  s     	;12~%''-T"	dfkk,789
Z'''r&   r   N)r   r   r   r   r  r  r   r   r&   r$   r  r  j  s    4(r&   r  c                  t    \ rS rSrS r\R                  R                  \R                  S:g  SS9S 5       r
Srg)	TestCustomBuildExti  c                B    SSK Jn   " S SU5      nX1R                  S'   g )Nr   )	build_extc                      \ rS rSrSrg)ITestCustomBuildExt.install_custom_build_ext_distutils.<locals>.MyBuildExti  r   N)r   r   r   r   r   r   r&   r$   
MyBuildExtr    s    r&   r  r  )distutils.command.build_extr  r  )rr   rx   build_ext_clsr  s       r$   "install_custom_build_ext_distutils5TestCustomBuildExt.install_custom_build_ext_distutils  s    J	 	 &0k"r&   linuxz(compilers may fail without correct setupr/   c                  ^ [         R                  R                  SS05        S[        SS/5      /0n[	        U5      nSUl        UR                  5         U R                  U5        [        U5      nUR                  5         UR                  5         [        [        [        5       R                  S5      5      5      nSU;   d   e[        5       R                  S5       Vs/ s H  ofR                  S	:w  d  M  UPM     nn[!        U5      S
:X  d   eUS   R"                  m[%        U4S j[&         5       5      (       d   eg s  snf )Nzmodule.cr   ext_modulesmoduler2   r  r  zmodule.*z.cr   r   c              3  F   >#    U  H  nTR                  U5      v   M     g 7fNr  )r  extrm   s     r$   r  HTestCustomBuildExt.test_distutils_leave_inplace_files.<locals>.<genexpr>  s     D1C#4==%%1Cs   !)rB   rC   rD   r   r   r   r  r  r   r  rG   rE   r  r   rp   suffixrq   rm   anyr   )	rr   r  r  rx   rM   r  pr1   rm   s	           @r$   "test_distutils_leave_inplace_files5TestCustomBuildExt.test_distutils_leave_inplace_files  s    	:r*+Ih=>
 E"%//5T"	dfkk,789
Z''' FKK
3H3qxx47G3H5zQQx}}D1CDDDDD Is   D?6D?r   N)r   r   r   r   r  rf   r   skipifr   r   r  r   r   r&   r$   r  r    s@    0 [[(R  EEr&   r  c                   [         R                  R                  SS05        [        5       nSUl        UR                  5         [        U5      nUR                  5         [        S[        40 5      n[        U" 5       S9nUR                  USU5        [        R                  " U5       nUR                  5         SSS5        [        S WR                   R"                   5       5      (       d   eg! , (       d  f       N<= f)	z7Make sure to display useful debugging tips to the user.r  r@   r2   SimulatedErr)side_effectrl   Nc              3  ,   #    U  H
  nS U;   v   M     g7f)zdebugging-tipsNr   )r  notes     r$   r  &test_debugging_tips.<locals>.<genexpr>  s     H4GD4'4Gr  )rB   rC   rD   r   r   r  r   r  type	Exceptionr
   setattrrf   r$  rG   r  value	__notes__)r  rs   rx   rM   r  simulated_failurerw   s          r$   test_debugging_tipsr    s    
KK{H-.>D!D

Cb9L846GH	|	$	 
%HCII4G4GHHHHH 
%	$s   'C..
C<errorc                 H    [        S5      n [        U [        5      (       d   eg)z>Ensure _encode_pth function does not produce encoding warningsu   tkmilan_ç_utf8N)r   
isinstancebytes)contents    r$   test_encode_pthr    s"     +,Ggu%%%%r&   c                    X -  nUR                  5         [        R                  R                  X5S9  / UQSPnUR	                  SSSSSS[        U5      /UQ[        R                  S	9nXV4$ )
Nr4   r:   r6   r7   r8   r   r9   r;   r  )rA   rB   rC   rD   rG   rE   r   r  )rm   rK   rJ   r1   r   rL   r   s          r$   rl  rl    sx    oGMMO
KKe,*T*)*D
((	4is7|KdK    C <r&   c                x    SR                  S[        S U  5       5      -   5      nU S   S-  R                  USS9  g)	a%  To use this function, it is necessary to insert new_dir in front of sys.path.
The Python process will try to import a ``sitecustomize`` module on startup.
If we manipulate sys.path/PYTHONPATH, we can force it to run our code,
which invokes ``addsitedir`` and ensure ``.pth`` files are loaded.

)zimport sitec              3  X   #    U  H   nS [         R                  " U5      < S3v   M"     g7f)zsite.addsitedir()N)r   fspath)r  new_dirs     r$   r  _addsitedirs.<locals>.<genexpr>  s$     S(w"299W#5"8:(s   (*r   zsitecustomize.pyr=   r>   N)r   tuplerI   )new_dirsr  s     r$   r   r     sH     ii
S(S
S	TG a[%%11'G1Lr&   c                    U R                   (       aP  [        [        U R                   5      S 5      nU(       a)  [        [	        U5      R                  5       5      U:X  d   eg g g r  )__path__r  iterrE   r   r   )rQ   r   rC   s      r$   r   r     sK    
||D&-tDz))+,888  r&   c                   U R                  5       (       a7  [        U R                  5       5      [        UR                  5       5      :X  d   eg U R                  5       nUR                  5       nU[        R                     U[        R                     :X  d   eU[        R
                     U[        R
                     :X  d   eg r  )
is_symlinkrE   r   statST_INOST_DEV)filerL  	file_stat
other_stats       r$   r  r    s    4<<>"c%--/&::::IIK	ZZ\
%DKK)@@@@%DKK)@@@@r&   c                ~    U R                  5       R                  [        R                  S5      R                  SS5      $ )N/z//)lowerreplacer   sep)str_with_paths    r$   r  r    s/     ((5==dCHHr&   )r  r   rL  r   returnNone)r  rE   r  rE   )T
__future__r   r   r   r  r   r   copyr   	importlibr   importlib.machineryr   pathlibr   textwrapr   typingr	   unittest.mockr
   uuidr   jaraco.envsrB   jaraco.pathrf   rC   r  setuptools._importlibr   r   !setuptools.command.editable_wheelr   r   r   r   r   r   r   r   setuptools.distr   setuptools.extensionr   setuptools.warningsr   r   r   r   distutils.corer   fixturer%   rH   r   SETUP_SCRIPT_STUBr   rw  r   rN   rU   rX   rZ   r   r   r   r\  r^  rz  filterwarningsr  uses_networkr  r  r  r  r  r  rl  r   r   r  r  r   r&   r$   <module>r     sX   " 	    
  # 2          B	 	 	 ) * < " $ ),- . 	< 	 eg(6!
 "	 %/
SDN 7  3<<8+4JK272J 12> L>2%*P#(L?; ?;Db0 b0J%*PU= U=p
.Qbu% u%pP1 P1f WX4 Y4@ ! !"' 'T( (:E E@I$ G$& %&	
M 9AIr&   