K i+TddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZddlmZmZe rddlmZddlmZdd lmZdd lmZGd d ed ZGddeZGddeZGddZGddeZGddeZ dZ!dZ"dZ#dZ$dZ%y)) annotationsN)Iterable) TYPE_CHECKING TypedDict)metadata resources)Self)SetuptoolsWarning) first_line_re) get_platformc"eZdZUded<ded<y) _SplitArgsboolcommentsposixN)__name__ __module__ __qualname____annotations__Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/_scripts.pyrrs N KrrF)totalceZdZUdZgZded<eZedZ edZ eddZ edZ eddZ dd Zed Zd Zed Zed Zy) CommandSpeczm A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. z list[str]optionsc|S)zV Choose the best CommandSpec class based on environmental conditions. rclss rbestzCommandSpec.best's  rctjjtj}tj j d|S)N__PYVENV_LAUNCHER__)ospathnormpathsys executableenvironget)r _defaults r_sys_executablezCommandSpec._sys_executable.s077##CNN3zz~~3X>>rct||r|St|tr|j|St|tr||S||j St dt |)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. z!Argument has an unsupported type ) isinstancestr from_stringrfrom_environment TypeErrortype)r params r from_paramzCommandSpec.from_param3sk eS !L eS !??5) ) eX &u:  ='') );DK=IJJrc0||jgSN)r,rs rr1zCommandSpec.from_environmentCsC'')*++rcRtj|fi|j}||S)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )shlexsplit split_args)r stringitemss rr0zCommandSpec.from_stringGs%  F5cnn55zrctj|j||_t j |}t |sdg|jddyy)Nz-xr)r9r:_extract_optionsr subprocess list2cmdlineisascii)self script_textcmdlines rinstall_optionszCommandSpec.install_optionsPsL{{4#8#8#EF ))$/w $vDLL!  rc|dzjd}tj|}|r|jdxsdnd}|j S)zH Extract any options from the first line of the script.  rr) splitlines_first_line_rematchgroupstrip) orig_scriptfirstrLrs rr?zCommandSpec._extract_optionsVsQ t#//1!4 &&u-*/%++a.&BR}}rcP|j|t|jzSr7)_renderlistr)rCs r as_headerzCommandSpec.as_header`s||D4 #5566rcld}|D],}|j|s|j|s'|ddcS|S)Nz"'r) startswithendswith)item_QUOTESqs r _strip_quoteszCommandSpec._strip_quotescs@ "Aq!dmmA&6Abz! " rcJtjd|D}d|zdzS)Nc3bK|]'}tj|j)ywr7)rr\rN).0rYs r z&CommandSpec._render..ms&* 8tjdtjj |j }||j}|jd|j}dD]}|d}|jj|D]h}|j}|j|j|jtz}|j||j||} | Ed{jy7 w)z Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. entry_pointsz%Unsupported distribution encountered.Nz==consolegui_scripts)rM)hasattrr emitr Distributionategg_info get_headernameversionrjselect_ensure_safe_nametemplatelocals_get_script_args) r distheaderspectype_rMeprurDargss rget_argszScriptWriter.get_argsst^,  " "#J K((++DMM:D >^^%F))Bt||n-% EgX&E''..U.; ww%%bgg.!llVX5 ++E277FKP    sDDD DcJtjd|}|r tdy)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)research ValueError)ru has_path_seps rrxzScriptWriter._ensure_safe_names( yy40 JK K rctjdk(s&tjdk(r'tjdk(rt j S|S)zD Select the best ScriptWriter for this environment. win32javant)r'platformr$ru_nameWindowsScriptWriterr!rs rr!zScriptWriter.bests: <<7 "rww&'8RXX=M&++- -Jrc#K|||zfywr7r)r rrur}rDs rr{zScriptWriter._get_script_argssVk)**s c|jjj|}|j||j S)z;Create a #! line, getting options (if any) from script_text)command_spec_classr!r5rFrT)r rDr(cmds rrtzScriptWriter.get_headers=$$))+66zB K(}}rr7)rIN)rDr/r(z(str | CommandSpec | Iterable[str] | Nonerar/)rrrrbtextwrapdedentlstripryrrrcrrdrxr!r{rtrrrrhrhws x! #F fhG J%  0LL++?C= rrhcPeZdZeZedZedZedZe dZ y)rcntt|}tjj dd}||S)zC Select the best ScriptWriter suitable for Windows )r(naturalSETUPTOOLS_LAUNCHERr()dictWindowsExecutableLauncherWriterr$r)r*)r writer_lookuplaunchers rr!zWindowsScriptWriter.bests6 6 ::>>"7FX&&rc#Ktdd|}|tjdjj dvr/dj d it }tj|gd}|j||j||}|Dcgc]}||z } }||z||zd| fy cc}ww) z For Windows, add a .py extension.pya.pywrkPATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)r.py -script.py.pyc.pyor.exetNr) rr$r)lowerr:formatrzr rpremove_adjust_header) r rrur}rDextmsgoldxblockerss rr{z$WindowsScriptWriter._get_script_argss6v.u5 bjj+11399#> >-f!x!C  " "3 'K 3##E62&)*D1H**Sj&;.X==+sBC B<+Ccd}d}|dk(r||}}tjtj|tj}|j ||}|j |r|S|S)z Make sure 'pythonw' is used for gui and 'python' is used for console (regardless of what sys.executable is). z pythonw.exez python.exerm)r<repl)rcompileescape IGNORECASEsub _use_header)r r orig_headerpatternr pattern_ob new_headers rrz"WindowsScriptWriter._adjust_headersc   E> 'TGZZ ' 2BMMB ^^;T^B  __Z8zIkIrc~|ddjd}tjdk7xstj|S)z Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. rV"r)rNr'rshutilwhich)r clean_headers rrzWindowsScriptWriter._use_headers8"!B'--c2 ||w&D&,,|*DDrN) rrrrfrrcr!r{rrdrrrrrrsZ+ ' ' > > J J E ErrceZdZedZy)rc# K|dk(rd}d}dg}nd}d}gd}|j||}|D cgc]} || z } } ||z||zd| f|dzt|d fts|d z} | t|dfy y cc} ww) zG For Windows, add a .py extension and an .exe launcher rmz -script.pywrclir)rrrrrbz .exe.manifestN)rget_win_launcheris_64bitload_launcher_manifest) r rrur}rD launcher_typerrhdrrrm_names rr{z0WindowsExecutableLauncherWriter._get_script_argss E>!MC(C!MC)C  /&)*D1H**cz3,c8<< 6M ] +   z O+F1$7= =+s,B A>A BN)rrrrcr{rrrrrs>>rrc|d}tr3tdk(r|jdd}n%|jdd}n|jdd}tjdj |j S)z Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. rz win-arm64.z-arm64.z-64.z-32. setuptools)rr replacer filesjoinpath read_bytes)r3 launcher_fns rrr<swF$-Kz >[ (%--c9=K%--c6:K!))#v6 ??< ( 1 1+ > I I KKrctjtjd}|j dt zS)Nzlauncher manifest.xmlzutf-8)encoding)r rrr read_textvars)ruress rrrOs4 //( # , ,-D EC =='= *TV 33rcttjtrtSt j tjj S)z_ Return a regular expression based on first_line_re suitable for matching strings. )r.r rr/rrdecoderrrrKrKTs: -''- ::m++224 55rc2tjddk(S)NP)structcalcsizerrrrr`s ??3 1 $$rcF |jdy#t$rYywxYw)NasciiFT)encode UnicodeError)ss rrBrBds,   s   )& __future__rr$rr9rrr@r'rcollections.abcrtypingrr _importlibrr typing_extensionsr warningsr distutils.command.build_scriptsr distutils.utilr rrSrrfrhrrrrrKrrBrrrrs"  $++&'9'% R%$R%j))ggT8E,8Ev>&9>@L&4 6%r