K .dZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z ddlmZddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZmZmZmZd dl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&d dl#m'Z'd dl(m)Z)m*Z*d dl+m,Z,d dl-m.Z.d dl/m0Z0m1Z1ddl2m2Z3ddl4m4Z5ddl6m6Z7ddl8m8Z9ddl:m:Z;ddlm?Z?d dl@mAZAede'ZBejCeDZEGdd eZFd!ZGd"ZHGd#d$e!ZIGd%d&eZJGd'd(ZKGd)d*eKZLGd+d,ZMd_d1ZNd`d5ZOdad<ZPd=ZQdbdAZRdbdBZSdcdEZTdddGZUdedIZVdfdLZWdgdMZXdhdRZYdidTZZGdUdVe&j[Z\dWZ]djd\Z^Gd]d^e%j_Z`dS)ka 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``. ) annotationsN)IterableIteratorMapping)suppress)Enum)cleandoc)chainstarmap)Path)TemporaryDirectory) TracebackType) TYPE_CHECKINGProtocolTypeVarcast)Command_normalization_path_shutilerrors namespaces)StrPath)py310py312find_package_path) Distribution)InformationOnlySetuptoolsDeprecationWarning)build)build_py) dist_info)egg_info)install)install_scripts)Self WheelFile_P)boundc6eZdZdZdZdZdZed dZd S) _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). strictlenientcompatmode str | Nonereturnc|s tjS|}|tjvrt jd|d|dkrt jdddt|S)NzInvalid editable mode: z. Try: 'strict'.COMPATzCompat editable installsa  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. zuserguide/development_mode.html)see_docs)r/LENIENTupper __members__r OptionErrorr!emit)clsr3_modes s/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/setuptools/command/editable_wheel.pyconvertz_EditableMode.convert@s ) ( (   1 1 1$%Wt%W%W%WXX X H   ( -* ;     U##N)r3r4r5r/) __name__ __module__ __qualname____doc__STRICTr9r7 classmethodrArBr@r/r/4sMFG F$$$[$$$rBr/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. ceZdZdZdZddddeejpdfgZdZd&d Z d&d Z d Z dZ d'dZ d(dZdZd)dZd*dZd&dZd+dZd Zd,d"Zd-d%ZdS).editable_wheelzBuild 'editable' wheel for development. This command is private and reserved for internal use of setuptools, users should rely on ``setuptools.build_meta`` APIs. zBDO NOT CALL DIRECTLY, INTERNAL ONLY: create 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_dirr3selfs r@initialize_optionsz!editable_wheel.initialize_optionsus$ ! rBr5Nonec|j}|jp tj|_|jpi|_t |jp$tj |jd|_dS)Ndist) distributionsrc_rootoscurdirrS package_dirr rQpathjoin)rUrYs r@finalize_optionszeditable_wheel.finalize_options{sX =5BI+1rT]Tbgll4;KV.T.TUU rBc |jd||d|d}||j||dS#t$rD}|j j p|j }tj |d|dd}~wwxYw)NT)exist_ok bdist_wheelz3An error occurred when building editable wheel for zl. See debugging tips in: https://setuptools.pypa.io/en/latest/userguide/development_mode.html#debugging-tips)rQmkdir_ensure_dist_inforeinitialize_commandget_finalized_commandwrite_wheelfilerR_create_wheel_file ExceptionrZnameget_nameradd_note)rUrdexprojects r@runzeditable_wheel.runs  M    . . .  " " $ $ $  % %m 4 4 444]CCK  ' '(: ; ; ;  # #K 0 0 0 0 0   ',L0A0J0J0L0LG Nfgfff     sBB C?CCc|jjtt|d}|j|_|||j|_dSt|j dsJt|jd sJdS)Nr%z .dist-infoMETADATA) rRr dist_info_clsrgrQ output_dirensure_finalizedrqstrendswithr exists)rUr%s r@rfz editable_wheel._ensure_dist_infos   %]D,E,Ek,R,RSSI#'=I  & & ( ( ( MMOOO!*!8D   t)**33LAA A AA*J77>>@@ @ @@ @ @rBc|j}|jsdSt|j|jdd}t||||}|dS)NrN.) rZnamespace_packagesr rSr^getresolve_NamespaceInstallerinstall_namespaces)rUinstallation_dir pth_prefixrYr[ installers r@_install_namespacesz"editable_wheel._install_namespacessw &  F($*:*>*>r3*G*GHHPPRR'.> HUU $$&&&&&rBr4c|jrt|jjn t}tt|d}t |dS)Nz *.egg-info)rRr parentmaprwglobnext)rU parent_dir candidatess r@_find_egg_info_dirz!editable_wheel._find_egg_info_dirsT8<8JVT$,--44PTPVPV jool;;<< J%%%rBrlrwunpacked_wheelr build_libtmp_dirc|j}t|}t|}tt||dd}tt||dd}tt||dd} tt|dd} t|| _d| _tt|dd} tt|d d} |x| _ x| _ | _ |x| _ x| _| _| x| _| _|| _|| _|d } d | _tt,|d }d|_t|| _tt2|d }d|_||_|| | dS)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.datadataheadersscriptsr&T)reinit_subcommandsr#r' build_scriptspythonr(r$FN)rZrwr r egg_info_clsrgegg_baseignore_egg_info_in_manifest build_cls install_cls build_platlib build_purelibrinstall_purelibinstall_platlib install_libr(rinstall_headers install_dataget_command_obj executableinstall_scripts_clsno_ep build_temp build_py_clscompilerexisting_egg_info_dir_set_editable_moderv)rUrlrrrrYwheelrrrr&r#r'rr(r$s r@_configure_buildzeditable_wheel._configure_builds4 N## NN 44??@@d>d>>>9EEFFd>d>>>9EEFF $33JSW3XX   LL/3, t00T0RR   229QU2VV  GPOOe1EORWWW'"9G>>g~rB dist_namec|||||||\}}|d|d|d||fS)Nrrr)r_run_build_subcommandsr _run_install)rUrrrrrrs r@_run_build_commandsz"editable_wheel._run_build_commandss iGLLL ##%%%4466w )$$$ )$$$ &!!!g~rBc|d}|D]^}||}|dkr,t|tur||I||_dS)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. r#r$N)rhrtyper _safely_run run_command)rUr#rlrs r@rz%editable_wheel._run_build_subcommandss**733**,, ' 'D,,T22Cz!!d3ii|&C&C  &&&&  &&&&  ' 'rBrc  ||S#t$r4tjddt jd|d|dYdSwxYw)Nz0Customization incompatible with editable installz z If you are seeing this warning it is very likely that a setuptools plugin or customization overrides the `a` command, without taking into consideration how editable installs run build steps starting from setuptools v64.0.0. Plugin authors and developers relying on custom build steps are encouraged to update their `aa` implementation considering the information about editable installs in https://setuptools.pypa.io/en/latest/userguide/extension.html. For the time being `setuptools` will silence this error and ignore the faulty command, but this behavior will change in future versions. )rrkr!r= traceback format_exc)rUrs r@rzeditable_wheel._safely_run-s ##H-- -    ( -B%''9A .6       s:AAc ddlm}|d}|j}d|}d}|d|d|d}t |j|}|r| t|} td} td } | 5} | 5} | 5}t | t |j j}tj |j ||| |||| | |\}}|||| }|5||d 5}|||||| dddn #1swxYwYdddn #1swxYwYdddn #1swxYwYdddn #1swxYwYdddn #1swxYwY|S) Nrr*r%-z 0.editablez.whl)suffixz .build-libz .build-tempw)wheel.wheelfiler+rhrlr`get_tagr rQryunlinkr rRshutilcopytreerr_select_strategy write_files)rUrdr+r%rtag build_tag archive_name wheel_pathrr build_tmpunpackedlibtmpunpacked_dist_inforrstrategy wheel_objs r@rjz!editable_wheel._create_wheel_fileIsH------..{;; N hh{**,,-- #;;i;;#;;; $-66           +<@@@&l;;; &m<<<  0x 0c9 0!%hT5G0H0H0M!N!N  OD.0B C C C  $ $Xy 9 9 9!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 0sG0 G B G F+ %#F  F+ FF+ FF+  G+F/ /G2F/ 3G6 GG G G G G0G G0 G !G00G47G4categoryct|jd|d}|rB|r:td|d|d|dSdSdS)Nhas_z Installing z as non editableinstall_)getattrrZ_loggerinfor)rUr has_categorys r@rzeditable_wheel._run_installest02C2C2CTJJ  4LLNN 4 LLAxAAA B B B   222 3 3 3 3 3 4 4 4 4rBrEditableStrategyc\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__.rr#rNr{)r rSr/rAr3rG _empty_dir _LinkTreerZ_find_packages_simple_layoutr^r7setr} _StaticPth_TopLevelFinder) rUrlrr build_namerSr3 auxiliary_dirpackageshas_simple_layoutis_compat_modesrc_dirs r@rzeditable_wheel._select_strategyks#2T11C11 4+,, $$TY// =' ' '&tD, (. (&**2s33Gd/['8R8R7STT Tt0$777rBr5rW)r5r4)rlrwrrrrrr)r5r) rrwrrrrrrr5r)rrw)rrw)rlrwrrwrrr5r)rCrDrErF descriptionr r/ user_optionsrVrarqrfrrrrrrrrrjrrrIrBr@rKrKgsm WK LK $!6!<"==>L  VVVV * A A A'''&&&& =#=#=#=#~ # # #        '''',884444 888888rBrKc&eZdZdd Zdd ZddZdS)rrr+r list[str]rMapping[str, str]r5objectcdSrPrI)rUrrrs r@__call__zEditableStrategy.__call__srBr)cdSrPrIrTs r@ __enter__zEditableStrategy.__enter__srB _exc_typetype[BaseException] | None _exc_valueBaseException | None _tracebackTracebackType | NonecdSrPrIrUrrrs r@__exit__zEditableStrategy.__exit__s rBN)rr+rrrrr5rr5r))rrrrrrr5r)rCrDrErrr rIrBr@rrsJ%$$$rBrc.eZdZdd ZddZddZddZdS)rrYrrlrw path_entries list[Path]r5rWc0||_||_||_dSrP)rYrlr)rUrYrlrs r@__init__z_StaticPth.__init__s  (rBrr+rrrrcdd|jD}t|d}|d|jd|dS)N c3XK|]%}t|V&dSrP)rwr~).0ps r@ z&_StaticPth.__call__..s2HHC ,,HHHHHHrBr.pth)r`r _encode_pthwritestrrl)rUrrrentriescontentss r@rz_StaticPth.__call__s`))HHd6GHHHHH'~~~.. 6ty666AAAAArBr)cdtttj|jd}t |tz|S)Nz_ Editable install will be performed using .pth file to extend `sys.path` with: z )listrr\fspathrrwarning_LENIENT_WARNINGrUmsgs r@rz_StaticPth.__enter__sQ c")T.// 0 0    ../// rBrrrrcdSrPrIr s r@r z_StaticPth.__exit__s rBN)rYrrlrwrrr5rWrr+rrrrr rrrrrrr5rW)rCrDrErrrr rIrBr@rrsh)))) BBBB       rBrcZeZdZdZd#fd Zd$fd Zd%dZd&d'dZd(dZd)dZ d*d"Z xZ S)+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. rYrrlrwrrrr5rWc t||_t||_|dj|_t|||jgdS)Nr$) r rr~rr copy_file_filesuperr)rUrYrlrr __class__s r@rz_LinkTree.__init__sn"-00i0022))*55?  td&8%9:::::rBrr+rrrrcz|||t|||dSrP) _create_linksr+r)rUrrrr,s r@rz_LinkTree.__call__s; 5'*** w/////rBfiler4c*tt5t||j}t |tj dcdddS#1swxYwYdS)N/) r ValueErrorr r~ relative_torrwreplacer\sep)rUr/r_s r@_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)rris_dirrer*)rUr7r8r<dests r@ _create_filez_LinkTree._create_files\!O3{!!## , K  d  + + + 8T -----rBoutput_mappingcjddtjrdnd}fd|D}d|D}|D]3}|}|r||vr||4|D]\}}|||dS)NT)r:rcsymhardc3LK|]\}}||fVdSrP)r6)rkvrUs r@rz*_LinkTree._create_links..s:XXAt--a00!4XXXXXXrBci|] \}}||| SrPrI)rrErFs r@ z+_LinkTree._create_links..sAAATQ1=Aq===rBr;)rre_can_symlink_filesitemsr6r?) rUoutputsr@ link_type normalisedmappingsoutputrelativesrcs ` r@r.z_LinkTree._create_linkss    ===/0BCCOEE XXXXAUAUAWAWXXX AAZAAA 4 4F--f55H 4HH44!!(F333%^^-- = =MHc   h)  < < < < = =rBr)cNd}t|tz|S)Nz=Strict editable install will be performed using a link tree. )rr _STRICT_WARNINGr"s r@rz_LinkTree.__enter__s#No-... rBrrrrcFd|jd}tjd|dS)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. Editable installation.)rr r=rUrrrr#s r@r z_LinkTree.__exit__s:       5s;;;;;rB) rYrrlrwrrrrr5rWr%)r/rwr5r4rP)r7rwr8rw)r@rr r&) rCrDrErFrrr6r?r.rr  __classcell__)r,s@r@rrs ; ; ; ; ; ;000000..... = = = = < < < < < < < eZdZddZdd Zdd ZddZddZd dZdS)!rrYrrlrwr5rWc"||_||_dSrP)rYrl)rUrYrls r@rz_TopLevelFinder.__init__s  rB5tuple[str, str, dict[str, str], dict[str, list[str]]]c  jjp tj}t t jt j}jjpi}t||| tt tjj pg dt D} fdjj pgD}i |}djd}tj|}||||fS)Nc3K|]}|gfV dSrPrI)rnss r@rz0_TopLevelFinder.template_vars.. s&DDb"bDDDDDDrBcLi|] }|t|jjpd!S)rN)rrYr[)rpkgrootsrUs r@rHz1_TopLevelFinder.template_vars.. sB    "3ty/A/GRHH   rBrz.finder)rYr[r\r]r r_find_top_level_modulesr^_find_package_rootsdict_find_namespacesr_find_virtual_namespacesr|rlrsafe_identifier) rUr[ top_levelr^ namespaces_legacy_namespacesrrlfinderr`s ` @r@ template_varsz_TopLevelFinder.template_varss#9%2.335LTY5W5WXX i+1r #I{HEE  !3!9r5AADD$>> _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|SrIr)rr_r^rSs r@rHz"_simple_layout..s( X X Xc$S+{CC X X XrBrNc 3K|]:\}}tjtg|dR|V;dSr{N)r same_pathr split)rkeyvaluers r@rz!_simple_layout..sa C V5ciinn555u==rB)rr\r_ commonpathr _parent_pathrJall)rr^rSlayoutrs `` @r@rrcs>Y X X X Xx X X XF .;B:-- W   fllnn E E F FF  ,,..  rBc||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' Nr1)rxlenrstripr\r5)r_pkg_pathrs r@rrsJ'/&7&7&<&< JXkS k " "(F ==rv & &&rBrYr Iterator[str]c#Kt|jpgEd{V|jpg}d|D}|jr |jVn|jpg}|d|Dz }|D]}|d\}}}|V dS)Ncg|]}d|v| Sr{rIrmods r@ z"_find_packages..s>>>c3#::c:::rBc.g|]}d|jv |jSrrlrxs r@rz"_find_packages..s!HHHa#--16---rBr{)iterr py_modules ext_package ext_modules rpartition)rYrnested_modulesrmodulepackage_s r@rrsDM'R(((((((((&BJ>>Z>>>N I&," HH;HHHH ))#.. A rBc#K|jpg}d|DEd{V|js|jpg}d|DEd{VdSdS)Nc3"K|] }d|v|V dSrrIrs r@rz*_find_top_level_modules..s&<<S^^^^^^<.s0EEq3af3D3DAF3D3D3D3DEErB)rrr)rYrrs r@raras&BJ<.s@!!!  ^-c;II J J!!!rB)sorted_remove_nested)rr^r[ pkg_rootss `` r@rbrbsI !!!!!(##!!!I ) $ $$rBr_ct|}|j}|r!t|St||jz S)z(Works for packages and top-level modules)r rryrwr~rl)r_path_rs r@rrsY JJE \F ||~~25==??###6>>##ej0111rBrc #>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. r{r"rNrN)rrangerr`r rry)rr_partsi partial_namer_s r@reres # # c>>  #s5zzA~q"-- # #A88E"1"I..L), 2FFGGD;;== #L $A$A""""  # # #rBrIterator[tuple[str, list[str]]]c#K|D]]}t||d}t|r)t|ds||gfV^dS)NrNz __init__.py)rr ry)rrr_r_s r@rdrds|   i44 ::     tD-'@'@'G'G'I'I -     rBc:t|}tt|D]H\t fd|Dr|I|S)Nc3NK|]\}}|kot||V dSrP) _is_nested)rother other_pathr_r_s r@rz!_remove_nested..sR  !z 5L EZT5*EE      rB)rccopyreversedrrJanypop)rrOr_r_s @@r@rrs ).."" # #Fd9??#4#45566 T      %.__%6%6       JJsOOO MrBr_rr parent_pathctj|}||dddd}||o"|tjt |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 rNr"r{)rnormpathr4stripr startswithr )r_rrr norm_pkg_pathrests r@rrsN8,,M ;;vr1 % % + +C 0 0 6 6s ; ;D >>& ! ! mu~ [ 4   88'rBdir_cZtj|dtj||S)zFCreate a directory ensured to be empty. Existing files may be removed.T) ignore_errors)rrmtreer\makedirs)rs r@rrs, N4t,,,,K KrBc"eZdZddZdZdZdS)rr5rWcZ||_||_||_||_g|_d|_dS)NF)rZr[r editable_namerKdry_run)rUrZrrr[s r@rz_NamespaceInstaller.__init__s3(  0*"$  rBcftj|j|j|jzS)zInstallation target.)r\r_r`rr nspkg_extrTs r@_get_nspkg_filez#_NamespaceInstaller._get_nspkg_files%w||D143E3VWWWrBcDtt|jS)z1Where the modules/packages should be loaded from.)reprrwr[rTs r@ _get_rootz_NamespaceInstaller._get_root#sC &&'''rBNr)rCrDrErrrrIrBr@rrsIXXX(((((rBra from __future__ import annotations import sys from importlib.machinery import ModuleSpec, PathFinder 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: dict[str, str] = {mapping!r} NAMESPACES: dict[str, list[str]] = {namespaces!r} PATH_PLACEHOLDER = {name!r} + ".__path_hook__" class _EditableFinder: # MetaPathFinder @classmethod def find_spec(cls, fullname: str, path=None, target=None) -> ModuleSpec | None: # type: ignore # Top-level packages and modules (we know these exist in the FS) if fullname in MAPPING: pkg_path = MAPPING[fullname] return cls._find_spec(fullname, Path(pkg_path)) # Handle immediate children modules (required for namespaces to work) # To avoid problems with case sensitivity in the file system we delegate # to the importlib.machinery implementation. parent, _, child = fullname.rpartition(".") if parent and parent in MAPPING: return PathFinder.find_spec(fullname, path=[MAPPING[parent]]) # Other levels of nesting should be handled automatically by importlib # using the parent path. return None @classmethod def _find_spec(cls, fullname: str, candidate_path: Path) -> ModuleSpec | None: 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) return None class _EditableNamespaceFinder: # PathEntryFinder @classmethod def _path_hook(cls, path) -> type[_EditableNamespaceFinder]: if path == PATH_PLACEHOLDER: return cls raise ImportError @classmethod def _paths(cls, fullname: str) -> list[str]: paths = NAMESPACES[fullname] if not paths and fullname in MAPPING: paths = [MAPPING[fullname]] # Always add placeholder, for 2 reasons: # 1. __path__ cannot be empty for the spec to be considered namespace. # 2. In the case of nested namespaces, we need to force # import machinery to query _EditableNamespaceFinder again. return [*paths, PATH_PLACEHOLDER] @classmethod def find_spec(cls, fullname: str, target=None) -> ModuleSpec | None: # type: ignore 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) -> None: 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 rlrrdict[str, list[str]]ctt|d}t|||S)z_Create a string containing the code for the``MetaPathFinder`` and ``PathEntryFinder``. c|dS)NrrI)rs r@z"_finder_template..s 1rB)rrlrr)rcrrJ_FINDER_TEMPLATEformatrs r@rprpsC 6'--//~~>>>??G  " "g* " U UUrBceZdZdZdS)rzCFile system does not seem to support either symlinks or hard links.N)rCrDrErFrIrBr@rrsMMMMrBr)rqrwr5ro)rr r5r)rrr^rrSrr5r)rYrr5r)rrr^rr[rr5r)r_rr5rw)rrr5r)rrrrr5r)rrr5r) r_rwrrwrrwrrwr5r)rr,r5r,)rlrwrrrrr5rw)arF __future__rryloggingr\rrcollections.abcrrr contextlibrenumrinspectr itertoolsr r pathlibr tempfiler typesrtypingrrrrrNrrrrrrrr2rr discoveryrrYrwarningsr r!r#rr$rr%rtr&rr'rr(rtyping_extensionsr)_vendor.wheel.wheelfiler+r, getLoggerrCrr/rSr!rKrrrrrrIrrrrarbrrerdrrr Installerrrrp FileErrorrrIrBr@rs  #"""""  7777777777$$$$$$$$''''''999999999999JJJJJJJJJJJJJJJJ!!!!!!!!))))))DDDDDDDD%%%%%%......111111......++++++CCCCCC4&&&&&&333333 WT!!! ' H % %&$&$&$&$&$D&$&$&$R \8\8\8\8\8W\8\8\8~     x           8I<I<I<I<I< I<I<I