Jdy dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZmZmZmZmZmZmZmZmZmZdd lm Z m!Z!m"Z"m#Z#dd l$m%Z&dd l'm(Z(dd l)m*Z*erddl+m,Z,ej-dkrddlm.Z.nerddl/m.Z.nddl0m1Z.ee2efZ3ede3Z4ej5e6Z7Gdde Z8dZ9dZ:Gdde Z;Gdde.Z<GddZ=Gdde=Z>Gd d!Z?d"ed#e@fd$ZAd%ee2d&ee2e2fd'ed#e@fd(ZBd)ZCd*e*d#ee2fd+ZDd*e*d#ee2fd,ZEd%ee2d&ee2e2fd-e3d#ee2e2ffd.ZFd/e3d#e2fd0ZGd1ee2e2fd#ee2fd2ZHd%ee2d1ee2e2fd#eee2ee2ffd3ZId1ee2e2fd#ee2e2ffd4ZJd5e2d6e2d7e2d8e2d#e@f d9ZKd:e3d#e2fd;ZLde2d#e2fd?ZNGd@dAe#jOZPdBZQd>e2dCee2e2fdDee2ee2fd#e2fdEZRGdFdGeSZTGdHdIe"jUZVdS)Ja Create a wheel that, when installed, will make the source package 'editable' (add it to the interpreter's path, including metadata) per PEP 660. Replaces 'setup.py develop'. .. note:: One of the mechanisms briefly mentioned in PEP 660 to implement editable installs is to create a separated directory inside ``build`` and use a .pth file to point to that directory. In the context of this file such directory is referred as *auxiliary build directory* or ``auxiliary_dir``. N)suppress)Enum)cleandoc)chain)Path)TemporaryDirectory) TYPE_CHECKINGDictIterableIteratorListMappingOptionalTupleTypeVarUnion)CommandSetuptoolsDeprecationWarningerrors namespaces)build_pyfind_package_path) Distribution WheelFile))Protocol)ABC_P)boundcJeZdZdZdZdZdZedee ddfdZ dS) _EditableModea Possible editable installation modes: `lenient` (new files automatically added to the package - DEFAULT); `strict` (requires a new installation when files are added/removed); or `compat` (attempts to emulate `python setup.py develop` - DEPRECATED). strictlenientcompatmodereturnc|s tjS|}|tjvrt jd|d|dkrd}t j|tt|S)NzInvalid editable mode: z. Try: 'strict'.COMPATax The 'compat' editable mode is transitional and will be removed in future versions of `setuptools`. Please adapt your code accordingly to use either the 'strict' or the 'lenient' modes. For more information, please check: https://setuptools.pypa.io/en/latest/userguide/development_mode.html ) r$LENIENTupper __members__r OptionErrorwarningswarnr)clsr(_modemsgs T/opt/alt/python311/lib/python3.11/site-packages/setuptools/command/editable_wheel.pyconvertz_EditableMode.convertGs} ) ( (   1 1 1$%Wt%W%W%WXX X H  C M#; < < <U##N) __name__ __module__ __qualname____doc__STRICTr,r+ classmethodrstrr6r7r5r$r$;s_FG F$8C=$_$$$[$$$r7r$zU New or renamed files may not be automatically picked up without a new installation. zt Options like `package-data`, `include/exclude-package-data` or `packages.find.exclude/include` may have no effect. cVeZdZdZdZddddeejpdfgZdZd Z d Z d Z d Z d e efdZdedededefdZdZd eeeeeefffdZdedededed eeeeeefff dZdZdefdZdZdefdZdededed dfd ZdS)!editable_wheelzkBuild 'editable' wheel for development. (This command is reserved for internal use of setuptools). z!create a PEP 660 'editable' wheel)z dist-dir=dz-directory to put final built distributions in)zdist-info-dir=Iz(path to a pre-build .dist-info directoryzmode=Nc>d|_d|_d|_d|_dSN)dist_dir dist_info_dir project_dirr(selfs r5initialize_optionsz!editable_wheel.initialize_optionsvs$ ! r7c|j}|jp tj|_|jpi|_t |jp$tj |jd|_dS)Ndist) distributionsrc_rootoscurdirrI package_dirrrGpathjoin)rKrNs r5finalize_optionszeditable_wheel.finalize_options|sX =5BI+1rT]Tbgll4;KV.T.TUU r7c |jd||d|d}||j||dS#t$r<}tj d}tj t||d}~wwxYw)NT)exist_ok bdist_wheela Support for editable installs via PEP 660 was recently introduced in `setuptools`. If you are seeing this error, please report to: https://github.com/pypa/setuptools/issues Meanwhile you can try the legacy behavior by setting an environment variable and trying to install again: SETUPTOOLS_ENABLE_FEATURES="legacy-editable" )rGmkdir_ensure_dist_inforeinitialize_commandget_finalized_commandwrite_wheelfilerH_create_wheel_file Exception traceback print_excr InternalErrorr)rKrYexr4s r5runzeditable_wheel.runs > M    . . .  " " $ $ $  % %m 4 4 444]CCK  ' '(: ; ; ;  # #K 0 0 0 0 0 > > >   ! ! ! C&x}}552 = >sBB C7C  Cc|jW|d}|j|_|||j|_dSdS)N dist_info)rHr\rG output_dirensure_finalizedre)rKrgs r5r[z editable_wheel._ensure_dist_infos`   %11+>>I#'=I  & & ( ( ( MMOOO!*!8D    & %r7c|j}|jsdSt|j|jdd}t||||}|dS)NrD.) rOnamespace_packagesrrIrSgetresolve_NamespaceInstallerinstall_namespaces)rKinstallation_dir pth_prefixrNrP installers r5_install_namespacesz"editable_wheel._install_namespacessw &  F($*:*>*>r3*G*GHHPPRR'.> HUU $$&&&&&r7r)c|jrt|jjn t}tt|d}t |dS)Nz *.egg-info)rHrparentmapr>globnext)rK parent_dir candidatess r5_find_egg_info_dirz!editable_wheel._find_egg_info_dirsT8<8JVT$,--44PTPVPV jool;;<< J%%%r7nameunpacked_wheel build_libtmp_dirc|j}t|}t|}tt||dd}tt||dd}tt||dd} |dd} t|| _d| _|dd} |d d} |x| _x| _| _|x| _ x| _ | _ | x| _ | _ || _|| _|d } d| _t|| _|d }d |_||_|| | d S)aConfigure commands to behave in the following ways: - Build commands can write to ``build_lib`` if they really want to... (but this folder is expected to be ignored and modules are expected to live in the project directory...) - Binary extensions should be built in-place (editable_mode = True) - Data/header/script files are not part of the "editable" specification so they are written directly to the unpacked_wheel directory. z.datadataheadersscriptsegg_infoT)reinit_subcommandsbuildinstallinstall_scriptsrFN)rOr>rr\egg_baseignore_egg_info_in_manifest build_platlib build_purelibrinstall_purelibinstall_platlib install_libr build_scriptsinstall_headers install_dataget_command_objno_ep build_tempcompiler|existing_egg_info_dir_set_editable_moderi)rKr}r~rrrNwheelrrrrrrrrs r5_configure_buildzeditable_wheel._configure_builds N## NN 44??@@d>d>>>9EEFFd>d>>>9EEFF,,ZD,QQLL/3,))'d)KK++I$+OOFOOOe1EORWWW'"9G>>g~r7 dist_namec|||||||\}}|d|d|d||fS)Nrrr)r_run_build_subcommandsr _run_install)rKrr~rrrrs r5_run_build_commandsz"editable_wheel._run_build_commandss iGLLL ##%%%4466w )$$$ )$$$ &!!!g~r7c|d}|D]`}||}|dkr.t|tkr||K||adS)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`` However both these assumptions may be false in editable_wheel. This method implements a temporary workaround to support the ecosystem while the implementations catch up. rrN)r]rtype build_py_cls _safely_run run_command)rKrr}rs r5rz%editable_wheel._run_build_subcommands s33G<<**,, ' 'D,,T22Cz!!d3ii<&?&?  &&&&  &&&&  ' 'r7rc ||S#t$r<tjd|d|d}t j|t dYdSwxYw)Nz If you are seeing this warning it is very likely that a setuptools plugin or customization overrides the `z` command, without taking into consideration how editable installs run build steps starting from v64.0.0. Plugin authors and developers relying on custom build steps are encouraged to update their `aO` implementation considering the information in https://setuptools.pypa.io/en/latest/userguide/extension.html about editable installs. For the time being `setuptools` will silence this error and ignore the faulty command, but this behaviour will change in future versions. ) stacklevel)rr`ra format_excr0r1r)rKrr4s r5rzeditable_wheel._safely_run"s K##H-- - K K K +--  4<  '   C M#; J J J J J J J KsAAAc ddlm}|d}|j}d|}d}|d|d|d}t |j|}|r| t|} td} td } | 5} | 5} | 5}t | t |j j}tj |j ||| |j||| | |\}}|||| }|5||d 5}|||||| dddn #1swxYwYdddn #1swxYwYdddn #1swxYwYdddn #1swxYwYdddn #1swxYwY|S) Nrrrg-z 0.editablez.whl)suffixz .build-libz .build-tempw)wheel.wheelfilerr]r}rUget_tagrrGexistsunlinkrrHshutilcopytreertr_select_strategy write_files)rKrYrrgrtag build_tag archive_name wheel_pathr~r build_tmpunpackedlibtmpunpacked_dist_inforrstrategy wheel_objs r5r_z!editable_wheel._create_wheel_file6sJ------..{;; N hh{**,,-- #;;i;;#;;; $-66           +<@@@&l;;; &m<<<  0x 0c9 0!%hT5G0H0H0M!N!N  OD.0B C C C  $ $Xy~ > > >!55i3PSTTNE7,,YSAAH 0 099Z55 0E7333%%h/// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0sG5 G BG F0 *#F F0 FF0 F!F0 $ G0F4 4G7F4 8G; GG GG G G5G" "G5%G" &G55G9<G9categoryct|jd|d}|rB|r:td|d|d|dSdSdS)Nhas_z Installing z as non editableinstall_)getattrrO_loggerinfor)rKr has_categorys r5rzeditable_wheel._run_installRst02C2C2CTJJ  4LLNN 4 LLAxAAA B B B   222 3 3 3 3 3 4 4 4 4r7rEditableStrategyc\d|d|}t|j}t|j}|tjur:t t|jd|}t|j|||St|j}t||j |} |tj u} t|j dhkr| s| r@|j dd} t|j|t|| gSt!|j|S)zDDecides which strategy to use to implement an editable installation. __editable__.rrrDrk)rrIr$r6r(r< _empty_dir _LinkTreerO_find_packages_simple_layoutrSr+setrm _StaticPth_TopLevelFinder) rKr}rr build_namerIr( auxiliary_dirpackageshas_simple_layoutis_compat_modesrc_dirs r5rzeditable_wheel._select_strategyXs#2T11C11 4+,, $$TY// =' ' '&tD, (. (&**2s33Gd/['8R8R7STT Tt0$777r7)r8r9r:r; descriptionrr$ user_optionsrLrVrer[rtrr>r|_Pathrrrr r rrrrr_rrr?r7r5rArAis6K LK $!6!<"==>L  VVV >>>4 A A A'''&HSM&&&& 0#0#).0#;@0#KP0#0#0#0#d # # # d3ic3h.G(H      .3 @E PU  tCy$sCx.( )    ''',KCKKKK(84S4444 888 8  888888r7rAcJeZdZdddeedeeeffdZdZdZdS) rrrrrcdSrFr?)rKrrrs r5__call__zEditableStrategy.__call__t r7cdSrFr?rJs r5 __enter__zEditableStrategy.__enter__wrr7cdSrFr?rK _exc_type _exc_value _tracebacks r5__exit__zEditableStrategy.__exit__zrr7N) r8r9r:r r>r rrrr?r7r5rrssh k $s) d3PS8n            r7rcjeZdZdededeefdZdddeedeeeffd Z d Z d Z d S) rrNr} path_entriesc0||_||_||_dSrF)rNr}r)rKrNr}rs r5__init__z_StaticPth.__init__s  (r7rrrrcdd|jD}t|dd}|d|jd|dS)N c3XK|]%}t|V&dSrF)r>rn).0ps r5 z&_StaticPth.__call__..s2II!S--IIIIIIr7utf-8r.pth)rUrbyteswritestrr})rKrrrentriescontentss r5rz_StaticPth.__call__sb))IIt7HIIIJJG11 6ty666AAAAAr7cdtttj|jd}t |tz|S)Nz_ Editable install will be performed using .pth file to extend `sys.path` with: z )listrwrQfspathrrwarning_LENIENT_WARNINGrKr4s r5rz_StaticPth.__enter__sQ c")T.// 0 0    ../// r7cdSrFr?rs r5rz_StaticPth.__exit__rr7N) r8r9r:rr>r rrr rrrr?r7r5rr~s)\))DJ)))) BkB$s)Bd3PS8nBBBB      r7rceZdZdZdedededeffd Zddd eed e eefffd Z d ed e efdZ ddedefdZ dZdZdZxZS)ra` Creates a ``.pth`` file that points to a link tree in the ``auxiliary_dir``. This strategy will only link files (not dirs), so it can be implemented in any OS, even if that means using hardlinks instead of symlinks. By collocating ``auxiliary_dir`` and the original source code, limitations with hardlinks should be avoided. rNr}rrc t||_t||_|dj|_t|||jgdS)Nr) rrrnrr copy_file_filesuperr)rKrNr}rr __class__s r5rz_LinkTree.__init__sn "-00i0022))*55?  td&8%9:::::r7rrrrcz|||t|||dSrF) _create_linksrr)rKrrrrs r5rz_LinkTree.__call__s; 5'*** w/////r7filer)c*tt5t||j}t |tj dcdddS#1swxYwYdS)N/) r ValueErrorrrn relative_torr>replacerQsep)rKrrTs r5_normalize_outputz_LinkTree._normalize_outputs j ! ! 2 2::%%''33DNCCDt99$$RVS11 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2tsA&BB B Nrelative_outputsrc_filec|j|z }|js|jd||||dS)NT)parentslink)rrvis_dirrZr)rKrrr#dests r5 _create_filez_LinkTree._create_files\!O3{!!## , K  d  + + + 8T -----r7cjddtjrdnd}fd|D}|dd|D]3}|}|r||vr||4|D]\}}|||dS)NT)r!rXsymhardcBi|]\}}||Sr?)r)rkvrKs r5 z+_LinkTree._create_links..s=   1  " "1 % %q   r7r")rrZ_can_symlink_filesitemspoprr&)rKoutputsoutput_mapping link_typemappingsoutputrelativesrcs` r5rz_LinkTree._create_linkss    ===/0BCCOEE     &,,..     T4    4 4F--f55H 4HH44!!(F333%^^-- = =MHc   h)  < < < < = =r7cNd}t|tz|S)Nz=Strict editable install will be performed using a link tree. )rr _STRICT_WARNINGr s r5rz_LinkTree.__enter__s#No-... r7cPd|jd}tj|tdS)Nz\ Strict editable installation performed using the auxiliary directory: z Please be careful to not remove this directory, otherwise you might not be able to import/use your package. )rr0r1InformationOnlyrKrrrr4s r5rz_LinkTree.__exit__s8       c?+++++r7rF)r8r9r:r;rr>rrr r rrrr&rrr __classcell__)rs@r5rrs% ;  ; ; ; ; ; ; ; ; ;0k0$s)0d3PS8n000000chsm..C.3.... ===" ,,,,,,,r7rcZeZdZdedefdZdddeedeeeffdZd Z d Z d S) rrNr}c"||_||_dSrF)rNr})rKrNr}s r5rz_TopLevelFinder.__init__s  r7rrrrc |jjp tj}t t |jt |j}|jjpi}t|||}tt t|jj pg|dt|D}d|j d} t| } tt!| ||d} || d| td| d| dd} |d|j d | dS) Nc3K|]}|gfV dSrFr?)rnss r5rz+_TopLevelFinder.__call__..s& @ @"b"X @ @ @ @ @ @r7rz.finderrz.pyzimport z; z .install()r)rNrPrQrRrr_find_top_level_modulesrS_find_package_rootsdict_find_namespacesr_find_virtual_namespacesr}_make_identifierr_finder_templater) rKrrrrP top_levelrSroots namespaces_r}findercontents r5rz_TopLevelFinder.__call__sE9%2.335LTY5W5WXX i+1r #I{HEE,0 TY/52u = = @ @ 8 ? ? @ @ @2 2 - - 2ty111!$''(ukBBGLL &~~~w///>&>>F>>>HH 6ty666@@@@@r7cNd}t|tz|S)Nz=Editable install will be performed using a meta path finder. )rr r r s r5rz_TopLevelFinder.__enter__s$N../// r7c>d}tj|tdS)Nz Please be careful with folders in your working directory with the same name as your package as they may take precedence during imports. )r0r1r;r<s r5rz_TopLevelFinder.__exit__s#   c?+++++r7N) r8r9r:rr>rr r rrrr?r7r5rrs\AkA$s)Ad3PS8nAAAA& ,,,,,r7rbase_dirr)ctt|5}t|dt|d}}|ddt t tt5tj ||| r3| ddkr dddddddSdddn #1swxYwY tj ||n$#t$r}d}t||d}~wwxYw dddd S#1swxYwYdS) N)dirz file1.txtz file2.txtfile1r)encodingTzFile system does not seem to support either symlinks or hard links. Strict editable installs require one of them to be supported.F)rr>rnr write_textrAttributeErrorNotImplementedErrorOSErrorrQsymlink is_symlink read_textr#r`LinksNotSupported)rQrpath1path2rdr4s r5r.r.s H$4$4$6$6 7 7 8 8 8CC--tC/E/Eu 7333 n&97 C C   Jue $ $ $!! eoowo&G&G7&R&R                       1 GE5 ! ! ! ! 1 1 1P $C((b 0  1 !saAEAC1 E% E1C5 5E8C5 9E=DE D4D//D44EE  E rrSrIc"fd|D}|stidhfvStjd|Dt fd|DS)a[Return ``True`` if: - all packages are contained by the same parent directory, **and** - all packages become importable if the parent directory is added to ``sys.path``. >>> _simple_layout(['a'], {"": "src"}, "/tmp/myproj") True >>> _simple_layout(['a', 'a.b'], {"": "src"}, "/tmp/myproj") True >>> _simple_layout(['a', 'a.b'], {}, "/tmp/myproj") True >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"": "src"}, "/tmp/myproj") True >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "a", "b": "b"}, ".") True >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a", "b": "_b"}, ".") False >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a"}, "/tmp/myproj") False >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a.a1.a2": "_a2"}, ".") False >>> _simple_layout(['a', 'a.b'], {"": "src", "a.b": "_ab"}, "/tmp/myproj") False >>> # Special cases, no packages yet: >>> _simple_layout([], {"": "src"}, "/tmp/myproj") True >>> _simple_layout([], {"a": "_a", "": "src"}, "/tmp/myproj") False c4i|]}|t|Sr?r)rpkgrSrIs r5r-z"_simple_layout..4s8  sK = =r7rDc4g|]\}}t||Sr?) _parent_path)rr+r,s r5 z"_simple_layout..:s& O O O1a!3!3 O O Or7c 3K|]E\}}ttg|dRt|kVFdSrkN)_normalize_pathrsplit)rkeyvaluervs r5rz!_simple_layout..;sj C V5ciinn55566/%:P:PPr7)rrQrT commonpathr/all)rrSrIlayoutrvs `` @r5rrs>F .;B:-- W   O O  O O O P PF  ,,..  r7c||r|dt| n|}|dtjzS)a7Infer the parent path containing a package, that if added to ``sys.path`` would allow importing that package. When ``pkg`` is directly mapped into a directory with a different name, return its own path. >>> _parent_path("a", "src/a") 'src' >>> _parent_path("b", "src/c") 'src/c' Nr)endswithlenrstriprQr)rbpkg_pathrvs r5rdrdAsJ&.%6%6s%;%; IXjCyj ! !F ==rv & &&r7rNc#Kt|jpgEd{V|jpg}d|D}|jr |jVn|jpg}|d|Dz }|D]}|d\}}}|V dS)Ncg|]}d|v| Srkr?rmods r5rez"_find_packages..Ss>>>c3#::c:::r7c.g|]}d|jv |jSrvr}rxs r5rez"_find_packages..Xs!HHHa#--16---r7rk)iterr py_modules ext_package ext_modules rpartition)rNr~nested_modulesrmodulepackage_s r5rrOsDM'R(((((((((&BJ>>Z>>>N I&," HH;HHHH ))#.. A r7c#K|jpg}d|DEd{V|js|jpg}d|DEd{VdSdS)Nc3"K|] }d|v|V dSrgr?rws r5rz*_find_top_level_modules..as&<<S^^^^^^<.es0EEq3af3D3DAF3D3D3D3DEEr7)r~rr)rNr~rs r5rCrC_s&BJ<.ms@!!!  ^-c;II J J!!!r7)sorted_remove_nested)rrSrP pkg_rootss `` r5rDrDhsI !!!!!(##!!!I ) $ $$r7rTct|}|j}|r!t|St||jz S)z(Works for packages and top-level modules)rrvrr>rnr})rTpath_rvs r5rrusY JJE \F ||~~25==??###6>>##ej0111r7rc #>K|D]}d|vr|d}tt|dz ddD]Y}d|d|}t t ||d}|r||vr|VZdS)a8By carefully designing ``package_dir``, it is possible to implement the logical structure of PEP 420 in a package without the corresponding directories. Moreover a parent package can be purposefully/accidentally skipped in the discovery phase (e.g. ``find_packages(include=["mypkg.*"])``, when ``mypkg.foo`` is included by ``mypkg`` itself is not). We consider this case to also be a virtual namespace (ignoring the original directory) to emulate a non-editable installation. This function will try to find these kinds of namespaces. rkrNrD)rirangerqrUrrr)rrbpartsi partial_namerTs r5rGrGs # # c>>  #s5zzA~q"-- # #A88E"1"I..L), 2FFGGD;;== #L $A$A""""  # # #r7c#K|D]]}t||d}t|r)t|ds||gfV^dS)NrDz __init__.py)rrr)rrrbrTs r5rFrFs|   i44 ::     tD-'@'@'G'G'I'I -     r7c:t|}tt|D]H\t fd|Dr|I|S)Nc3NK|]\}}|kot||V dSrF) _is_nested)rother other_pathrTrbs r5rz!_remove_nested..sR  !z 5L EZT5*EE      r7)rEcopyreversedrr/anyr0)rr5rTrbs @@r5rrs ).."" # #Fd9??#4#45566 T      %.__%6%6       JJsOOO Mr7rbrsrv parent_pathct|}||dddd}||o|tt |g|RkS)a Return ``True`` if ``pkg`` is nested inside ``parent`` both logically and in the file system. >>> _is_nested("a.b", "path/a/b", "a", "path/a") True >>> _is_nested("a.b", "path/a/b", "a", "otherpath/a") False >>> _is_nested("a.b", "path/a/b", "c", "path/c") False >>> _is_nested("a.a", "path/a/a", "a", "path/a") True >>> _is_nested("b.a", "path/b/a", "a", "path/a") False rDrrk)rhrstripri startswithr)rbrsrvr norm_pkg_pathrests r5rrs|$H--M ;;vr1 % % + +C 0 0 6 6s ; ;D v G _T+-E-E-E-EFF Fr7filenamectjdkrtj|n|}tjtjtj|S)z1Normalize a file/dir name for comparison purposescygwin)sysplatformrQrTabspathnormcaserealpathnormpath)rrs r5rhrhs^), (@(@27??8 $ $ $hD 7  BG,,RW-=-=d-C-CDD E EEr7dir_cZtj|dtj||S)zFCreate a directory ensured to be empty. Existing files may be removed.T) ignore_errors)rrmtreerQmakedirs)rs r5rrs, M$d++++K Kr7r}c2tjdd|}|S)zMake a string safe to be used as Python identifier. >>> _make_identifier("12abc") '_12abc' >>> _make_identifier("__editable__.myns.pkg-78.9.3_local") '__editable___myns_pkg_78_9_3_local' z \W|^(?=\d)r)resub)r}safes r5rHrHs 6-d + +D Kr7c eZdZdZdZdZdS)rocZ||_||_||_||_g|_d|_dS)NF)rOrPrq editable_namer1dry_run)rKrOrqrrPs r5rz_NamespaceInstaller.__init__s3(  0*  r7cVtj|j|jS)zInstallation target.)rQrTrUrqrrJs r5 _get_targetz_NamespaceInstaller._get_targetsw||D143EFFFr7cDtt|jS)z1Where the modules/packages should be loaded from.)reprr>rPrJs r5 _get_rootz_NamespaceInstaller._get_rootsC &&'''r7N)r8r9r:rrrr?r7r5rorosDGGG(((((r7roa< import sys from importlib.machinery import ModuleSpec from importlib.machinery import all_suffixes as module_suffixes from importlib.util import spec_from_file_location from itertools import chain from pathlib import Path MAPPING = {mapping!r} NAMESPACES = {namespaces!r} PATH_PLACEHOLDER = {name!r} + ".__path_hook__" class _EditableFinder: # MetaPathFinder @classmethod def find_spec(cls, fullname, path=None, target=None): for pkg, pkg_path in reversed(list(MAPPING.items())): if fullname == pkg or fullname.startswith(f"{{pkg}}."): rest = fullname.replace(pkg, "", 1).strip(".").split(".") return cls._find_spec(fullname, Path(pkg_path, *rest)) return None @classmethod def _find_spec(cls, fullname, candidate_path): init = candidate_path / "__init__.py" candidates = (candidate_path.with_suffix(x) for x in module_suffixes()) for candidate in chain([init], candidates): if candidate.exists(): return spec_from_file_location(fullname, candidate) class _EditableNamespaceFinder: # PathEntryFinder @classmethod def _path_hook(cls, path): if path == PATH_PLACEHOLDER: return cls raise ImportError @classmethod def _paths(cls, fullname): # Ensure __path__ is not empty for the spec to be considered a namespace. return NAMESPACES[fullname] or MAPPING.get(fullname) or [PATH_PLACEHOLDER] @classmethod def find_spec(cls, fullname, target=None): if fullname in NAMESPACES: spec = ModuleSpec(fullname, None, is_package=True) spec.submodule_search_locations = cls._paths(fullname) return spec return None @classmethod def find_module(cls, fullname): return None def install(): if not any(finder == _EditableFinder for finder in sys.meta_path): sys.meta_path.append(_EditableFinder) if not NAMESPACES: return if not any(hook == _EditableNamespaceFinder._path_hook for hook in sys.path_hooks): # PathEntryFinder is needed to create NamespaceSpec without private APIS sys.path_hooks.append(_EditableNamespaceFinder._path_hook) if PATH_PLACEHOLDER not in sys.path: sys.path.append(PATH_PLACEHOLDER) # Used just to trigger the path hook rrctt|d}t|||S)z_Create a string containing the code for the``MetaPathFinder`` and ``PathEntryFinder``. c|dS)Nrr?)rs r5z"_finder_template..?s 1r7)rjr}rr)rErr/_FINDER_TEMPLATEformatrs r5rIrI9sC 6'--//~~>>>??G  " "g* " U UUr7ceZdZdZdS)r;zCurrently there is no clear way of displaying messages to the users that use the setuptools backend directly via ``pip``. The only thing that might work is a warning, although it is not the most appropriate tool for the job... Nr8r9r:r;r?r7r5r;r;Csr7r;ceZdZdZdS)r]zCFile system does not seem to support either symlinks or hard links.Nrr?r7r5r]r]KsMMMMr7r])Wr;loggingrQrrrrar0 contextlibrenumrinspectr itertoolsrpathlibrtempfilertypingr r r r r rrrrr setuptoolsrrrrsetuptools.command.build_pyrrsetuptools.discoveryrsetuptools.distrrr version_infortyping_extensionsabcr r>rr! getLoggerr8rr$r9r rArrrrboolr.rrdrrCrDrrGrFrrrhrrH InstallerrorrI UserWarningr; FileErrorr]r?r7r5rs   ''''''                        QPPPPPPPPPPP@@@@@@222222((((((*))))))v$*******###### c4i WT ' H % %!$!$!$!$!$D!$!$!$H G8G8G8G8G8WG8G8G8T     x           .D,D,D,D,D, D,D,D,N",",",",",",",",J$()sm)*.sCx.)GK) ))))X ' ' '  (3-     F,F8C=FFFF %sm %c" % % #s(^ % % % %2232222#S#X#8C=####0 3i $(cN  eCcN#$     d38n c3h    C3#$.FeFFFFFRB 3 3    (((((*.((($EPV VS)V7;CcN7KVVVVVkNNNNN(NNNNNr7