\bgw LddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZddlZddlZddlZddlmZdd lmZdd l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dd l*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ej5ddgdZ6eded7dddededddd id!Z8d"Z9ej:;ejd#kd$%ej:<d&ie8d'e9ie8gd(Z=d)Z>d*Z?Gd+d,Z@Gd-d.ZAd/ZBGd0d1ZCd2ZDGd3d4ZEGd5d6ZFej:Gd7d8ZHd9ZIGd:d;ZJGd<d=ZKGd>d?ZLd@ZMej:GdAdBZNdCZOdDZPdEZQdOdKZRdPdNZSdS)Q) annotationsN)deepcopy) import_module)EXTENSION_SUFFIXES)Path)dedent)Any)Mock)uuid4) resources) _DebuggingTips _encode_pth_find_namespaces_find_package_roots_find_virtual_namespaces_finder_template _LinkTree_TopLevelFindereditable_wheel) Distribution) Extension)SetuptoolsDeprecationWarning)contexts namespaces) run_setupstrictlenient)paramsc$|jdkrddgSgS)Nr--config-settingseditable-mode=strict)param)requests w/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/setuptools/tests/test_editable_install.py editable_optsr&+s }  #%;<< Ia [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 zThis 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) zx = ''z Hello World) __init__.pyz __main__.pymod.pyzdata.txt)pyproject.toml MANIFEST.inz README.rstz LICENSE.txtsrcz __import__('setuptools').setup()darwinpypa/setuptools#4328reasonfilessetup.pyc |dz }|tj||ddddddt |g|}t ||gd }||d ksJ|d z d d |dz dd ||dksJdS)Nr(prefixpython-mpipinstall--no-build-isolation-e)r7r8r(z3.14159.post0 Hello Worldzsrc/mypkg/data.txtfoobarutf-8encodingzsrc/mypkg/mod.pyx = 42z3.14159.post0 foobar 42) mkdirjaracopathbuildstrprintrunstrip write_text)tmp_pathvenvr2r&projectcmds r%test_editable_with_pyprojectrO|s G MMOOO KeG,,,     G    C $((3-- # # #C 88C==   $? ? ? ? ? ##//7/KKK !!--h-III 88C==   $= = = = = = =r'c Vdtdddiddi}tj|||dz }dd d d d d t |g|}t ||gd}||dksJdS)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)za = 4b = 2)r+pkgr*r5r7r8r9r:r;r<)r7-cz$import pkg, mod; print(pkg.a, mod.b)z4 2rrCrDrErFrGrHrIrKrLr&r2rMrNs r%test_editable_with_flat_layoutrVs$ "7+#   E* KeH--- G     G    C $((3-- B B BC 88C==   E ) ) ) ) ) )r'c Pdtdddi}tj|||dz }dddd d d t |g|}t ||gd }||d ksJdS)Nr(a> [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] name = "mod" version = "3.14159" [tool.setuptools] py-modules = ["mod"] rQ)r+r*r5r7r8r9r:r;r<)r7rSzimport mod; print(mod.b)2rTrUs r% test_editable_with_single_modulerYs$      E& KeH--- G     G    C $((3-- 6 6 6C 88C==   C ' ' ' ' ' 'r'ceZdZdZejddejdddZdS)TestLegacyNamespacesctjtd}|dz }|d}|D]}t j||d}|5|5}||tdd } t| } | | d j } | || dddn #1swxYwYdddn #1swxYwYt|d } t!| t!|ksJdS) Nz .*namespace_packages parameter.*matchz.installation_dir)z myns.pkgAz myns.pkgB myns.n.pkgA myns.n.pkgB42)versionr3config) stop_after dist_infoz *-nspkg.pth)pytestwarnsrrBrbuild_namespace_packagecontextchdirrrfinalize_optionsget_finalized_commandname_install_namespaceslistgloblen) selfrK monkeypatch deprecationinstallation_direxamplesrmrRctxdistrN editable_namer2s r%test_nspkg_file_is_uniquez.TestLegacyNamespaces.test_nspkg_file_is_uniquesl (0R   $&99     I ID4XtTRRRC I Ik1133 Is # AAA$T**$$&&& # 9 9+ F F K ''(8-HHH  I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I%**=99::5zzS]]******s7D)A:C/# D/C3 3D6C3 7DD D impl) pkg_resourcesns)zmyns.nc *d}tj||d|}tj||d|}|dz |d|dz |d|dd} | d |d d d d t |g| |d d d d dt |g| |d dd|d|dg|gddS)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;r7r8r9r:r<rSzimport z.pkgA; import )r7rSzimport pkg_resources)rrhrJappendrHrF) rrrLrKr}r{r& build_systempkg_Apkg_Boptss r%!test_namespace_package_importablez6TestLegacyNamespaces.test_namespace_package_importablesD$ 28\\\PTUUU28\\\PTUUU ! !--lW-MMM ! !--lW-MMMQQQ *+++ (D%CJJFFGGG (D%D#e**LtLMMM (D"GB"G"Gb"G"G"GHIII 999:::::r'N)__name__ __module__ __qualname__rzrfmark parametrizerr'r%r[r[sz+++4 [  [T;//;;0/;;;r'r[c eZdZdZdZdZdS)TestPep420Namespacesc ltj|d}tj|d}|dd}|d|ddddt |g||ddddd t |g||gd dS) 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;r7r8r9r:r<)r7rSz&import myns.n.pkgA; import myns.n.pkgB)rbuild_pep420_namespace_packagerrHrF)rrrLrKr&rrrs r%rz6TestPep420Namespaces.test_namespace_package_importable.s 9(MRR9(MRRQQQ *+++ (D%CJJFFGGG (D%D#e**LtLMMM KKKLLLLLr'c 8dtdddidi}tj|||dz }t j|d}t j|d}|d d }|d |d d d dt|g||d d d ddt|g||d d d ddt|g||gdd S)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-r5r`z myns.n.pkgCNr;r7r8r9r:r<)r7rSz#from myns.n import pkgA, pkgB, pkgC) rrCrDrErrrrHrF) rrrLrKr&r2rrpkg_Crs r%&test_namespace_created_via_package_dirz;TestPep420Namespaces.test_namespace_created_via_package_dir=s= "(  # #&w/ &  %1116!9(MRR9(MRRQQQ *+++ (D%CJJFFGGG (D%D#e**LtLMMM (D%D#e**LtLMMM HHHIIIIIr'c dtdddddddtdd i}tj|| |dz }d g}|d d ddddt |g||gd}|dksJd}|d dt|g}d|vsJdS)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. rar [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] name = "pkgA" version = "3.14159" [tool.setuptools] packages.find.include = ["mypkg.*"] zb = 1r)r)zpkgA.py)r)zother.pynr,)r+r(r,r5r;r7r8r9-vr:r<)r7rSz'from mypkg.n import pkgA; print(pkgA.a)1z} try: import mypkg.other except ImportError: print("mypkg.other not defined") rSzmypkg.other not definedN)rEXAMPLErCrDrErHrFrI)rrrLrKr2rroutrNs r%0test_namespace_accidental_config_in_lenient_modezETestPep420Namespaces.test_namespace_accidental_config_in_lenient_mode_s" "(  # #$& '')#* '}5/ 6  %1116!'' (D%y$E RTRSSShhRRRSSyy{{c!!!!  hh$s 455(C//////r'N)rrrrrrrr'r%rr-sH M M M J J JD0000000000r'rc . |dz fdtjD}|D]}|dt|t t jt jtt|}tj dddd t|d t d g |}tj || tjd krdnd} |z dz }tj |g| dS)z> Editable install to a prefix should be discoverable. r6cg|]T}d|v|tj%t|tjz US)z site-packages) startswithsysr6r relative_to).0rDr6s r% z-test_editable_with_prefix..s\  d " "tsz'B'B " d'' 333 " " "r'T)parents) PYTHONPATHr8r9r:z --editablez--prefixr;)envWindowsScriptsbinsampleN)rrDrB _addsitedirsdictosenvironpathsepjoinmaprF executable subprocess check_callplatformsystem) rKsample_projectr&site_packages_allsprrNrexer6s @r%test_editable_with_prefixrs= FH   "### rzbjooc#?P6Q6Q&R&R S S SC    N F    C#3'''' ((I55))5C 3, !C3%S))))))r'cTeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd S)TestFinderTemplateThis 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. cLi}t||||ddS)Nr:)exec)rrfinderlocs r%install_finderz!TestFinderTemplate.install_finders1 VS#Ir'cddddididdid}tj|| t|d z t|d z d }t tt |i}t j5t j5d D]"}tj |d#| |td}td}td}|jdksJ|jdksJt|dz } t!|| dddn #1swxYwYddddS#1swxYwYdS)Npkg1rmod1.pyza = 42)r)subpkgmod2.pyza = 43src1src2r5z src1/pkg1z src2/mod2)rmod2)r pkg1.subpkgpkg1.subpkg.mod1rrrr*+zsrc1/pkg1/subpkg)rCrDrErFrr r save_pathssave_sys_modulesrmodulespoprraresolve assert_path) rrrKr2mappingtemplatemodmod1rrexpecteds r% test_packagesz TestFinderTemplate.test_packagess&#%((3 )    %111;.//;.//  $CLL'2>>  " " * *H$=$?$? * *J + + T****    ) ) ) !344D ((D"=11F6R<<<<6R<<<<H'99BBDDEEH  ) ) ) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *s7F&B6E( F(E, ,F/E, 0FFFcddddi}tj||dt|dz i}dgi}t tt ||}t j5t j5dD]"}tj |d#| |td}tj|d z }t|dz } t#|| |jd ksJ|d dksJ dddn #1swxYwYddddS#1swxYwYdS) NrRa = 13abc)r)text.txtr5 ns.othernamer}r}rr r>r?)rCrDrErFrr rrrrrrrrimportlib_resourcesr2rrr read_text) rrrKr2rrrrrRtextrs r%test_namespacez!TestFinderTemplate.test_namespaceseDDE %111!3x%'7#8#89BZ #CLL':FF  " " = =H$=$?$? = =- + + T****    ) ) )//C&,S11J>DHu,557788H X & & &5B;;;;>>7>33u<<<<< = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =s7>E5B>E E5E! !E5$E! %E55E9<E9cLddddiiidddiid}tj||t|d z t|d z d }dt|d z t|d z gi}t tt ||}t j5t j5dD]"}tj |d#| |td}td}t|d z } t|| |jdksJ|jdksJ dddn #1swxYwYddddS#1swxYwYdS)Nr}rr)rrb = 37rr5z src1/ns/pkg1zsrc2/ns)ns.pkgAr}rr)r}rns.mod2rrr%)rCrDrErFrr rrrrrrrrrrrb) rrrKr2r namespaces_rrrrrs r%test_combine_namespacesz*TestFinderTemplate.test_combine_namespacess8F]H$=>?Ix01    %1118n455h*++  c(V"344c(V:K6L6LMN #CLL';GG  " " H$=$?$? 3 + + T****    ) ) ) ++D ++DH~5>>@@AAH h ' ' '6R<<<<6R<<<<< s79F B'F5 FF FF FF Fcdddiidddiid}tj}||5tj|dd d d d d gd}t |}t |tt}td| D}dddn #1swxYwYtj 5tj 5|dD]"}tj|d#||t%d} t%d} t|dz } tt)| j| ksJt|dz } tt)| j| ksJ| jdksJ| jdksJ dddn #1swxYwYddddS#1swxYwYdS)z 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%zsrc/my_packagezsrc2/my_package2)different_namedifferent_name.subpkgrr) script_name package_dirpackagesc3JK|]\}}|d|VdS)z.pyNendswith)rkvs r% zDTestFinderTemplate.test_combine_namespaces_nested../s8WWdaQZZPUEVEVWWWWWWWr'Nrzdifferent_name.my_modulez different_name.subpkg.my_module2zsrc/my_package/my_module.pyzsrc2/my_package2/my_module2.pyrr)rCrDDirectoryStackrirErrrFr nextget_implementationrrrrrrrrrr__file__rr) rrrKr2stackattrsrxrcoderrrrs r%test_combine_namespaces_nestedz1TestFinderTemplate.test_combine_namespaces_nesteds8!>8"<="_h$?@    **,, ]]8 $ $ X X K  e $ $ $*&6-?  ./FG E &&D$T3uww<<88FWWf&?&?&A&AWWWWWD X X X X X X X X X X X X X X X " "  H$=$?$?  Z( + + T****    % % % !;<.Ns+KK4&&&KKKKKKr')onetwothreez parent.childzparent.child.onerzparent.child.twor zparent.child.threer)rCrDrErFrr rrrrrrrrxrfraises ImportErrorr) rrrKr2rrrmodsrrrrs r%test_dynamic_path_computationz0TestFinderTemplate.test_dynamic_path_computationBsZ"Gh-@#AB!Gh-@#AB!Gj'-B#CD    %111#h1B&B"C"C!DE #CLL';GGKK3JKKK  " "  H$=$?$?   ..H4HH + + T****    ) ) ) 233C5A::::{++ 2 20111 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 HOOC: 566 7 7 7 233C5A::::{++ 4 42333 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 HOOC: 566 7 7 7!"677E7a<<<<<+                                 sI.A6H.$E4 H.E H.E A'H./G ? H. G H.G AH." I.H2 2I5H2 6II  I cldddii}tj||dt|dz i}t tt |i}t j5t j5tj dd| |tjtd5t!ddddn #1swxYwYdddn #1swxYwYddddS#1swxYwYdS)NrRr)zfrom . import pkgr5r]rCrDrErFrr rrrrrrrrfrrrrrrKr2rrs r%test_no_recursionz$TestFinderTemplate.test_no_recursionfs 2   %111 3x%'(( $CLL'2>>  " " % %H$=$?$? % % KOOE4 ( ( (    ) ) ){%888 % %e$$$ % % % % % % % % % % % % % % %  % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %s[9D) ADC:. D:C> >DC> D D)D D)D D))D-0D-cddddidi}tj||dt|dz i}t tt |i}t j5t j5tj ddtj dd| |tjtd5t!ddddn #1swxYwYdddn #1swxYwYddddS#1swxYwYdS) Nfoorr))r)barr5zfoo.barr=r]rrs r%test_similar_namez$TestFinderTemplate.test_similar_name{s !!2   %111 3x%'(( $CLL'2>>  " " ( (H$=$?$? ( ( KOOE4 ( ( ( KOOIt , , ,    ) ) ){(;;; ( (h''' ( ( ( ( ( ( ( ( ( ( ( ( ( ( (  ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s[<E A1D4D D4D! !D4$D! %D4( E 4D8 8E ;D8 <E  EEcdddddddi}tj||dt|dz i}t tt |i}t j5t j5tj dd| |tjtd 5t!d dddn #1swxYwYtjtd 5t!d dddn #1swxYwYtjtd 5t!ddddn #1swxYwYtjtd 5t!ddddn #1swxYwYtjtd 5t!ddddn #1swxYwYt!d}|jdksJt!d}|jdksJ dddn #1swxYwYddddS#1swxYwYdS)Nrrr r )r) lowercase.py)r)r#r r5z'FOO'r]FOOz'foo\.LOWERCASE'z foo.LOWERCASEz'foo\.bar\.Lowercase'zfoo.bar.Lowercasez 'foo\.BAR'zfoo.BAR.lowercasezFOO.bar.lowercasez foo.lowercaserzfoo.bar.lowercaser)rCrDrErFrr rrrrrrrrfrrrr)rrrKr2rrrs r%test_case_sensitivityz(TestFinderTemplate.test_case_sensitivitys! ! '#%$+    %111 3x%'(( $CLL'2>>  " "  H$=$?$?   KOOE4 ( ( (    ) ) ){'::: % %e$$$ % % % % % % % % % % % % % % %{2EFFF / /o... / / / / / / / / / / / / / / /{2KLLL 3 31222 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3{-@@@ 3 31222 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3{'::: 3 31222 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 00C5A:::: 344C5A:::::/                                 s>I/AI#C?3 I?D ID I%E5 IE IE I'F7 IF I F I)G9 IG I G I+H; IH IH ;I I/I I/I I//I36I3cddddddi}tj||dt|dz i}d gi}t tt ||}t j5t j5d D]"}tj |d#| |td}t|dz }t|||jd ksJtd } | jd ksJtd} | jdksJt'jt*d5tddddn #1swxYwYt'jt*d5tddddn #1swxYwYt'jt*d5tddddn #1swxYwYdddn #1swxYwYddddS#1swxYwYdS)NrRrrzc = 42)r)zbar.py)r)rr5rr}rrzns.othername.foorzns.othername.foo.barrz'NS'r]zNS.othername.fooz'ns\.othername\.FOO\'zns.othername.FOOz'ns\.othername\.foo\.BAR\'zns.othername.foo.BAR)rCrDrErFrr rrrrrrrrrrrrcrfrr) rrrKr2rrrrrRrrr s r%test_namespace_case_sensitivityz2TestFinderTemplate.test_namespace_case_sensitivitys '#+&   %111!3x%'7#8#89BZ #CLL':FF  " " 6 6H$=$?$? 6 6- + + T****    ) ) )//CHu,557788H X & & &5B;;;; 233C5B;;;; 677C5B;;;;{&999 2 20111 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2{2LMMM 2 20111 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2{2RSSS 6 64555 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6- 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6sICH*3F H*F H*F H*5G H*G H*G H*7H H*H H*H H* I*H. .I1H. 2II Icdddddddidii}tj|| dt|d z i}t tt |i}t j5t j5d D]"}tj |d #| |td }|jdksJtd}|jdksJt!jt$5tdd d d n #1swxYwYd d d n #1swxYwYd d d d S#1swxYwYd S)z The finder should not import ``fullname`` if the intermediate segments don't exist (see pypa/setuptools#4019). r-r(rrzb = 13 config.pyza = 37)r)r*z helloworld.py componentsr5z src/mypkg)r(z mypkg.configmypkg.helloworldzmypkg.componentsmypkg.components.configmypkg.components.helloworldNr-rr,rr.)rCrDrErFrr rrrrrrrrrrrfrr)rrrKr2rrrrc helloworlds r%test_intermediate_packagesz-TestFinderTemplate.test_intermediate_packagessJ #%!)%-#X#      %111C; 6778#CLL'2>>  " " = =H$=$?$? = = + + T****    ) ) )"#<==F8r>>>>&'9::J<2%%%%{++ = =;<<< = = = = = = = = = = = = = = =' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =s[E+B E D<0 E<E EE E E+E E+E E++E/2E/N)rrr__doc__rrrrrrrr!r%r(r0rr'r%rrs  ***@===.   6) ) ) V" " " H%%%*(((0'''R'6'6'6R*=*=*=*=*=r'rc Nddidddddiddd dd iiidd idd idd id}tj||dddd}gd}t|||}|t |dz t |dz t |dz t |dz t |dz t |dz dksJt t t||}|ddhksJt t|}|hdksJdS)rr)zab = 1r)rr)zd = 1zde = 1)r)eghzfgh = 1zabc = 1z abcxyz = 1z mnopq = 1)rdfotheranother yet_anotherr5r8r9r:)a.b.c a.b.c.x.y.z m.n.o.p.q) ra.br; a.b.c.x.yr<r6zd.er7f.gzf.g.hr=rr6r7)rr;r<r6r7r=r@>m.nm.n.oa.b.c.xm.n.o.pmr>r?N) rCrDrErrFsetrrr)rKr2rrrootsr}s r%test_pkg_rootsrHs "8,W E E$M8+D E EC-34 5+!<0%{3   E KeH--- "K   H +x @ @E  C X'((8i/00 C C M122      T"8U33 4 4 5 5B #u     %e , , - -B PPP P P P P P Pr'c <eZdZUdZeeedddddddddd Zd ed <eeeeddd ed id eeedzeddded dded ddeeeddd ed ded ddid dZe j e j dkde j dedZdS)TestOverallBehaviourz [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "mypkg" version = "3.14159" r,rzvar = 42zvar = 13 resource 39)r)rzresource_file.txt)r)r subpackage)r+r, otherfile.pyr(zdict[str, Any] FLAT_LAYOUTr()r+r,rMr-z [tool.setuptools] packages = ["mypkg", "mypkg.subpackage"] [tool.setuptools.package-dir] "mypkg.subpackage" = "other" r)r)rrL)r+r,rMr(r8)rrL) flat-layout src-layout custom-layout namespacer.r/r0layoutcjtd|||j|g|R\}}d}|ddt|g}d|vsJd} |ddt| g}d|vsJd} |ddt| g}d |vsJt |d } t |d } t |d } | d d| dd| dd|ddt| g}d|vsJd|vsJ|ddt| g}d |vsJd|vsJdS)Nr(zj try: import otherfile except ImportError as ex: print(ex) r7rSzNo module named 'otherfile'zy import mypkg, mypkg.mod1, mypkg.subpackage.mod2 print(mypkg.mod1.var, mypkg.subpackage.mod2.var) z42 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")) rK **/mod1.py **/mod2.py**/resource_file.txtzvar = 17r>r?z var = 781z resource 374z17 781)install_projectEXAMPLESrHrrrprJ)rrrKrLrSr&rM_cmd_import_errorr cmd_get_varscmd_get_resourcerr resource_files r%test_editable_installz*TestOverallBehaviour.test_editable_installs% T8T]6%: =J      hh$/?(@(@ABB,3333 hh$|(<(<=>>#~~~~  hh$/?(@(@ABB####GLL..//GLL..//W\\*@AABB   W555  g666  ' BBBhh$|(<(<=>>c!!!!3hh$/?(@(@ABBC''''$$$$$$r'N)rrr PYPROJECTrrrN__annotations__rYrfrxfailrrrkeysr_rr'r%rJrJCs I!&++}-!!%%2  # #K     #$fY//"=1[12   %fY//f #=1!&w/ :!),7#  (%fY//"=1*73I>"-g"6|"D   7&&HP [s|x/8NOO [Xx}}770%0%87PO0%0%0%r'rJceZdZeejdZedxxedz cc<deddd<dZd Z d S) TestLinkTreerPr+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*"] rr-r(resource.not_in_manifestctj|j|t |5d}t ddi}|t}|dz }|dz }||| d}d|_ t||_ | |}|} t!||||} | ||| t#|d } |d z } t'| | t#|d dJt#|d dJt#|d dJt#|ddJ ddddS#1swxYwYdS)Nr5z mypkg-3.14159rrz.auxz.buildbuild_pyTrUzsrc/mypkg/mod1.pyz **/subpackagerVrWz**/resource.not_in_manifest)rCrDrEFILES_Pathrparse_config_filesr rBget_command_obj editable_moderF build_libensure_finalized get_outputsget_output_mappingrrrpassert_link_to) rrrKrmrxwheelauxrErhoutputsoutput_mapping make_treerrs r%test_generated_treez TestLinkTree.test_generated_treesH $*X666 8__ O O"D <==D  # # % % %FFEV#Cx'E IIKKK KKMMM++J77H%)H "!$UH   % % ' ' '**,,G%88::N!$c599I IeWn 5 5 5..//D"55H 4 * * *11488@@@..55===!788$??GGG!>??FFNNNN; O O O O O O O O O O O O O O O O O OsF>HH Hc2ddg}td|||jg|R|gd}d|vsJd}|ddt|g}d |vsJd }|ddt|g}d |vsJd |vsJdS) Nr!r"r(r7rSz(import mypkg.mod1; print(mypkg.mod1.var)razv try: from mypkg import subpackage except ImportError as ex: print(ex) r7rScannot 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) zNo such file or directoryrf)rXrirHr)rrrKrLrrr[r]s r%test_strict_installz TestLinkTree.test_strict_installs#%;<xCdCCCChhSSSTTs{{{{  hh$/?(@(@ABB0C7777 hh$/?(@(@ABB*c1111)S000000r'N) rrrrrJrYrirrxr|rr'r%reres H)2<@ A AE vv    9>E%L45 O O OD11111r'rez9ignore:.*compat.*:setuptools.SetuptoolsDeprecationWarningc~ddg}tjd}td|||g|R|gd}d|vsJt t |}dD]-}t |dd |g}||vsJ.d }|dd t |g}d |vsJdS) Nr!zeditable-mode=compatrQr(rzra)z"import otherfile; print(otherfile)zimport other; print(other)zimport mypkg; print(mypkg)r7rSzc try: from mypkg import subpackage; except ImportError as ex: print(ex) r{)rJrYrXrHcomparable_pathrFr)rKrLrr2r expected_pathrNs r%test_compat_installrs !7 8D )/ :EGT8U:T:::: ((OOO P PC 3;;;;#CMM22M$$ dhh$'<==>>##### C ((HdF3KK0 1 1C , 3 3 3 3 3 3r'cPtdtdtddddddid }|gd tjd 5t d |||g|Rdddn #1swxYwY|gd}d|vsJdS)z3Ensure editable installs work with pbr, issue #3500z [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" z __import__('setuptools').setup( pbr=True, setup_requires=["pbr"], ) z~ [metadata] name = mypkg [files] packages = mypkg rzprint('Hello world!'))r)zhello.pyztest.txtzAnother file in here.)r+r3z setup.cfgr(r8)r7r8r9r:pbrz0.42) PBR_VERSIONr(N)r7rSzimport mypkg.helloz Hello world!)rrHr environmentrX)rKrLr&r2rs r%test_pbr_integrationr/sJ!          /  56=  E@ HH 6 6 6777  & 1 1 1HHxGGGGGHHHHHHHHHHHHHHH ((999 : :C S s!A>>BBcPeZdZdZiejddediZdZdS)TestCustomBuildPya$ 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. rOr3af 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}) ctd|||j\}}d|vsJd|vsJ|gd}d|vsJdS)z>Ensure that errors in custom build_py are reported as warningsr(rzValueError: TEST_RAISErzraN)rXrirH)rrrKrLrZrs r%test_safeguarded_from_errorsz.TestCustomBuildPy.test_safeguarded_from_errorsysh!$$*EE3-4444'3....hhSSSTTs{{{{{{r'N) rrrr1rJrYrrirrr'r%rrZsd   ' 6 FF      E$r'rceZdZdZdZdS)TestCustomBuildWheelc`|d}Gdd|}||jd<dS)N bdist_wheelceZdZfdZxZS)ETestCustomBuildWheel.install_custom_build_wheel..MyBdistWheelc||jdrd}tS)Nzmacosx-zmacOS platform) plat_namersuperget_tag)rrrZ __class__s r%rzMTestCustomBuildWheel.install_custom_build_wheel..MyBdistWheel.get_tags6>,,Y77)(Aww(((r')rrrr __classcell__)rs@r% MyBdistWheelrs8 ) ) ) ) ) ) ) ) )r'r)get_command_classcmdclass)rrrxbdist_wheel_clsrs r%install_custom_build_wheelz/TestCustomBuildWheel.install_custom_build_wheelsS00?? ) ) ) ) )? ) ) )(4 m$$$r'ctjddit}d|_|||t|}|| ttt d}d|vsJdS)N module.pyrAr3 dist/*.whleditable)rCrDrErr set_defaultsrrrorHrFrrrp)rr tmpdir_cwdrxrN wheel_files r%test_access_plat_namez*TestCustomBuildWheel.test_access_plat_names  ;1222~~%  ''---T""   dffkk,778899 Z''''''r'N)rrrrrrr'r%rrs2 4 4 4 ( ( ( ( (r'rcpeZdZdZejejdkddZ dS)TestCustomBuildExtcBddlm}Gdd|}||jd<dS)Nr) build_extceZdZdS)ITestCustomBuildExt.install_custom_build_ext_distutils..MyBuildExtN)rrrrr'r% MyBuildExtrs Dr'rr)distutils.command.build_extrr)rrrx build_ext_clsrs r%"install_custom_build_ext_distutilsz5TestCustomBuildExt.install_custom_build_ext_distutilssRJJJJJJ        &0 k"""r'linuxz(compilers may fail without correct setupr0ctjddidtddggi}t |}d|_|||t|}| | tttd}d|vsJdtd D}t|d ksJ|d jt#fd t$DsJdS) Nzmodule.cr ext_modulesmoduler3rrc(g|]}|jdk |S)z.c)suffix)rps r%rzITestCustomBuildExt.test_distutils_leave_inplace_files..s$HHHqqx47G7G7G7G7Gr'zmodule.*rrc3BK|]}|VdSNr)rextrms r%rzHTestCustomBuildExt.test_distutils_leave_inplace_files..s/DD#4==%%DDDDDDr')rCrDrErrrrrrrorHrFrrrprqrmanyr)rrrrrxrNrr2rms @r%"test_distutils_leave_inplace_filesz5TestCustomBuildExt.test_distutils_leave_inplace_filessK  :r*+++ Ih ==> E""%  //555T""   dffkk,778899 Z''''HHDFFKK 33HHH5zzQQx}DDDD1CDDDDDDDDDDr'N) rrrrrfrskipifrrrrr'r%rrsj000 [ (REEEEEr'rcXtjddit}d|_|t |}|tdtfi}t|}| |d|d}tj |5tjt|5|d d d n #1swxYwYd d d d S#1swxYwYd S) z7Make sure to display useful debugging tips to the user.rrAr3 SimulatedErr) side_effectrlz-following steps are recommended to help debugr]N)rCrDrErrrrrotype Exceptionr setattrrfrrgr rH)rrsrxrNrsimulated_failure expected_msgs r%test_debugging_tipsrs K{H-... >>D!D   C b99L88846GHHHBL | $ $fl>&V&V&V  s6 D&D; DD DD DD#&D#errorcRtd}t|tsJdS)z>Ensure _encode_pth function does not produce encoding warningsutkmilan_ç_utf8N)r isinstancebytes)contents r%test_encode_pthrs.+,,G gu % %%% %%%r'c ||z }|tj||g|d}|ddddddt |g|t j }||fS) Nr5r;r7r8r9rr:r<)stderr)rBrCrDrErHrFrSTDOUT)rmrLrKr2rrMrs r%rXrXsoG MMOOO KeG,,, *T *) *D (( 4is7||KdK    C C<r'cddtd|Dz}|ddz |ddS) a5To 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 sitec3FK|]}dtj|dVdS)zsite.addsitedir()N)rfspath)rnew_dirs r%rz_addsitedirs..s8SSw:29W#5#5:::SSSSSSr'rzsitecustomize.pyr>r?N)rtuplerJ)new_dirsrs r%rrse ii SS(SSS S S TGa[%%11'G1LLLLLr'c|jrXtt|jd}|r6tt ||ksJdSdSdSr)__path__riterrFrr)rRrrDs r%rrsr |9D&&--  9tDzz))++,,888899 9 988r'filerr8returnNonec|rHt|t|ksJdS|}|}|tj|tjksJ|tj|tjksJdSr) is_symlinkrFrstatST_INOST_DEV)rr8 file_stat other_stats r%rrrrs A4<<>>""c%--//&:&:::::::IIKK ZZ\\ %DK)@@@@@%DK)@@@@@@@r' str_with_pathrFc|tjdddS)N/z//)lowerreplacersep)rs r%r~r~s6    ( ( 5 5 = =dC H HHr')rrr8rrr)rrFrrF)T __future__rrrrrrcopyr importlibrimportlib.machineryrpathlibrtextwraprtypingr unittest.mockr uuidr jaraco.envsrC jaraco.pathrfrDrjsetuptools._importlibr r!setuptools.command.editable_wheelr rrrrrrrrsetuptools.distrsetuptools.extensionrsetuptools.warningsrrrrdistutils.corerfixturer&rIrSETUP_SCRIPT_STUBrrbrrOrVrYr[rrrrHrJrefilterwarningsrrrrrrrrXrrrrr~rr'r%rs""""""   ######222222 BBBBBB                      )(((((******<<<<<<""""""""$$$$$$),---.-f <6  egg(6!6  "6  %/   SD D N73<8+4JKK 272J 122>>LK>2%*%*%*P#(#(#(L?;?;?;?;?;?;?;?;Db0b0b0b0b0b0b0b0J%*%*%*PU=U=U=U=U=U=U=U=p .Q.Q.Qbu%u%u%u%u%u%u%u%pP1P1P1P1P1P1P1P1fWXX44YX4@(!(!(!V''''''''T((((((((:EEEEEEEE@$G$$&&%$&    M M M 999AAAAIIIIIIr'