Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
_scripts.cpython-313.pyc161 linesDownload Raw Back to __pycache__
1�

2��j�+��X�SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK3Jr SSKJ
r
Jr SSKJrJr \
(aSSKJr SSKJr SS	KJr SS4KJr "SS\S
S9r"SS\5r"SS\5r"SS5r"SS\5r"SS\5r Sr!Sr"Sr#Sr$Sr%g)�)�annotationsN)�Iterable)�
TYPE_CHECKING�	TypedDict�)�metadata�	resources)�Self)�SetuptoolsWarning)�
first_line_re)�get_platformc�*�\rSrSr%S\S'S\S'Srg)�5_SplitArgs��bool�comments�posix�N)�__name__�6__module__�__qualname__�__firstlineno__�__annotations__�__static_attributes__r��YD:\code\apps\devtools\python\user_packages\Python313\site-packages\setuptools/_scripts.pyrrs���N��KrrF)�totalc���\rSrSr%Sr/rS\S'\"5r\	S5r7\	S5r\	SSj5r\	S5r
\	SS	j5rSS8jr\S5rSr\S
5r\S5rSrg)�CommandSpec�za9A command spec for a #! header, specified as a list of arguments akin to10those passed to Popen.11z	list[str]�optionsc��U$)zF12Choose the best CommandSpec class based on environmental conditions.13r��clss r�best�CommandSpec.best's	��14�15rc��[RR[R5n[R16R
SU5$)N�__PYVENV_LAUNCHER__)�os�path�normpath�sys�17executable�environ�get)r$�_defaults  r�_sys_executable�CommandSpec._sys_executable.s0���7�7�#�#�C�N�N�3���z�z�~�~�3�X�>�>rc��[X5(aU$[U[5(aURU5$[U[5(aU"U5$UcUR	5$[S[
U535e)zO18Construct a CommandSpec from a parameter to build_scripts, which may19be None.20z!Argument has an unsupported type )�21isinstance�str�from_stringr�from_environment�	TypeError�type)r$�params  r�22from_param�CommandSpec.from_param3sr���e�!�!��L��e�S�!�!��?�?�5�)�)��e�X�&�&��u�:���=��'�'�)�)��;�D��K�=�I�J�Jrc�0�U"UR5/5$�N)r1r#s rr7�CommandSpec.from_environmentCs���C�'�'�)�*�+�+rc�T�[R"U40URD6nU"U5$)ze23Construct a command spec from a simple string representing a command24line parseable by shlex.split.25)�shlex�split�26split_args)r$�string�itemss   rr6�CommandSpec.from_stringGs%�����F�5�c�n�n�5���5�z�rc���[R"URU55Ul[R27"U5n[
U5(dS/URSS&gg)Nz-xr)rArB�_extract_optionsr!�28subprocess�list2cmdline�isascii)�self�script_text�cmdlines   r�install_options�CommandSpec.install_optionsPsO���{�{�4�#8�#8��#E�F����)�)�$�/���w��� $�v�D�L�L��!�� rc���US-R5Sn[5RU5nU(aURS5=(d SOSnUR	5$)z829Extract any options from the first line of the script.30�31rr�)�32splitlines�_first_line_re�match�group�strip)�orig_script�firstrVr!s    rrH�CommandSpec._extract_optionsVsR��33�t�#�/�/�1�!�4��� �&�&�u�-��*/�%�+�+�a�.�&�B��R���}�}��rc�P�URU[UR5-5$r>)�_render�listr!)rLs r�	as_header�CommandSpec.as_header`s���|�|�D�4����#5�5�6�6rc��SnUH8nURU5(dMURU5(dM3USSs $ U$)Nz"'r�����)�34startswith�endswith)�item�_QUOTES�qs   r�
_strip_quotes�CommandSpec._strip_quotescsA�����A����q�!�!�d�m�m�A�&6�&6��A�b�z�!���rc�L�[R"SU55nSU-S-$)Nc3�h# �UH(n[RUR55v� M* g7fr>)rrhrX)�.0res  r�	<genexpr>�&CommandSpec._render.<locals>.<genexpr>ms'���*35�@E��K�%�%�d�j�j�l�3�3��s�02z#!rR)rIrJ)rErNs  rr]�CommandSpec._renderks0���)�)�*36�@E�*37�38���g�~��$�$r)r!N)r:z!Self | str | Iterable[str] | None�returnr39)rDr5rpr40)rMr5)rrrr�__doc__r!rrrC�classmethodr%r1r;r7r6rO�staticmethodrHr_rhr]rrrrrrs����41�G�Y����J������?��?��
K��
K��,��,�����&�����7������%��%rrc� �\rSrSr\"SS9rSrg)�WindowsCommandSpec�sF)rrN)rrrrrrCrrrrruruss���%�(�Jrruc���\rSrSrSr\R"S5R5r\	r42\SSj5r\
S5r\S5r\S5r\SS
S	jj5rS43rg)�ScriptWriter�wzT44Encapsulates behavior around writing entry point scripts for console and45gui apps.46aJ47        # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r48        import re49        import sys50 51        # for compatibility with easy_install; see #219852        __requires__ = %(spec)r53 54        try:55            from importlib.metadata import distribution56        except ImportError:57            try:58                from importlib_metadata import distribution59            except ImportError:60                from pkg_resources import load_entry_point61 62 63        def importlib_load_entry_point(spec, group, name):64            dist_name, _, _ = spec.partition('==')65            matches = (66                entry_point67                for entry_point in distribution(dist_name).entry_points68                if entry_point.group == group and entry_point.name == name69            )70            return next(matches).load()71 72 73        globals().setdefault('load_entry_point', importlib_load_entry_point)74 75 76        if __name__ == '__main__':77            sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])78            sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())79        Nc#�0# �[US5(d?[R"S5 [RRUR5nUcUR5nURSUR3nSH�nUS3nURRUS9HgnURnURUR5 UR[5-nURXFRX(5n	U	Shv�N Mi M� gN
7f)zi80Yield write_script() argument tuples for a distribution's81console_scripts and gui_scripts entry points.82�entry_pointsz%Unsupported distribution encountered.Nz==��console�gui�_scripts)rW)�hasattrr�emitr�Distribution�at�egg_info�83get_header�name�versionr{�select�_ensure_safe_name�template�locals�_get_script_args)84r$�dist�header�spec�type_rW�epr�rM�argss85          r�get_args�ScriptWriter.get_args�s�����t�^�,�,��"�"�#J�K��(�(�+�+�D�M�M�:�D��>��^�^�%�F��)�)��B�t�|�|�n�-��%�E��g�X�&�E��'�'�.�.�U�.�;���w�w���%�%�b�g�g�.�!�l�l�V�X�5���+�+�E�7�7�F�P�����<�&� �s�DD�D�Dc�V�[R"SU5nU(a[S5eg)z/86Prevent paths in *_scripts entry point names.87z[\\/]z+Path separators not allowed in script namesN)�re�search�88ValueError)r��has_path_seps  rr��ScriptWriter._ensure_safe_name�s(��89�y�y��4�0����J�K�K�rc��[RS:Xd([RS:Xa([RS:Xa[90R
5$U$)z491Select the best ScriptWriter for this environment.92�win32�java�nt)r,�platformr)r��_name�WindowsScriptWriterr%r#s rr%�ScriptWriter.best�s:��93�<�<�7�"�r�w�w�&�'8�R�X�X��=M�&�+�+�-�-��Jrc#�# �X#U-4v� g7fr>r)r$r�r�r�rMs     rr��ScriptWriter._get_script_args�s����k�)�*�*�s�94c��URR5RU5nURU5 UR	5$)z;Create a #! line, getting options (if any) from script_text)�command_spec_classr%r;rOr_)r$rMr-�cmds    rr��ScriptWriter.get_header�s=���$�$�)�)�+�6�6�z�B�����K�(��}�}��rrr>)rSN)rMr5r-z(str | CommandSpec | Iterable[str] | Nonerpr5)rrrrrq�textwrap�dedent�lstripr�rr�rrr�rsr�r%r�r�rrrrrxrxws����95���!	�#�F
�f�h�G
�J%��� �� �0�L��L������+��+���?C����=��96
�	��rrxc�X�\rSrSr\r\S5r\S5r\S5r	\97S5rSrg)r���c�f�[[US9n[RR	SS5nX$)z398Select the best ScriptWriter suitable for Windows99)r-�natural�SETUPTOOLS_LAUNCHERr-)�dict�WindowsExecutableLauncherWriterr)r.r/)r$�
writer_lookup�launchers   rr%�WindowsScriptWriter.best�s4��100�6��101�
�102�:�:�>�>�"7��F���&�&rc#�# �[SSS9UnU[RSR5R	S5;a0SR103"S1040[
5D6n[R"U5 /SQnURU5 URX5nUVs/sHo�U-PM	 n	nX%-X4-SU	4v� g	s snf7f)z For Windows, add a .py extension�.pya�.pywr|�PATHEXT�;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)r��.py�105-script.py�.pyc�.pyor��.exe�tNr)r�r)r.�lowerrB�formatr�rr��remove�_adjust_header)106r$r�r�r�rM�ext�msg�old�x�blockerss107          rr��$WindowsScriptWriter._get_script_args�s�����6�v�.�u�5���b�j�j��+�1�1�3�9�9�#�>�>�-��f��!��x�!�C�
�"�"�3�'�K���108�109�3���#�#�E�2��&)�*�c��1�H�c��*��j�&�.��X�=�=��+�s�BC�B;�,Cc���SnSnUS:XaXCpC[R"[R"U5[R5nUR	X$S9nURU5(aU$U$)zn110Make sure 'pythonw' is used for gui and 'python' is used for111console (regardless of what sys.executable is).112zpythonw.exez113python.exer~)rD�repl)r��compile�escape�114IGNORECASE�sub�_use_header)r$r��orig_header�patternr��115pattern_ob�116new_headers       rr��"WindowsScriptWriter._adjust_headers`�� �����E�>� �T��Z�Z��	�	�'� 2�B�M�M�B�117��^�^�;�^�B�118� �_�_�Z�8�8�z�I�k�Irc��USSRS5n[RS:g=(d [R"U5$)z�119Should _adjust_header use the replaced header?120 121On non-windows systems, always use. On122Windows systems, only use the replaced header if it resolves123to an executable on the system.124�rb�"r�)rXr,r��shutil�which)r��clean_headers  rr��WindowsScriptWriter._use_headers8��"�!�B�'�-�-�c�2���|�|�w�&�D�&�,�,�|�*D�DrrN)
rrrrrur�rrr%r�r�rsr�rrrrr�r��sZ��+���125'��126'��
>��
>��J��J��	E��	Err�c�$�\rSrSr\S5rSrg)r�ic#�# �US:XaSnSnS/nOSnSn/SQnURX5nUV	s/sHo�U	-PM	 n127n	X&-X�-SU1284v� US-[U5S	4v� [5(dUS129-nU[U5S4v� ggs sn	f7f)z7130For Windows, add a .py extension and an .exe launcher131r~z-script.pywr��clir�)r�r�r�r�r��bz
.exe.manifestN)r��get_win_launcher�is_64bit�load_launcher_manifest)r$r�r�r�rM�
launcher_typer�r��hdrr�r��m_names            rr��0WindowsExecutableLauncherWriter._get_script_argss����132�E�>�!�M��C��(�C�!�M��C�)�C�� � ��/��&)�*�c��1�H�c��*��z�3�,�c�8�<�<��6�M��]�+��133�	134�135�z�z��O�+�F��1�$�7��=�=���+�s�,B�B�ABrN)rrrrrrr�rrrrr�r�s���>��>rr�c��US3n[5(a4[5S:XaURSS5nO%URSS5nOURSS5n[R"S5RU5R
5$)z�136Load the Windows launcher (executable) suitable for launching a script.137 138`type` should be either 'cli' or 'gui'139 140Returns the executable as a byte string.141r�z	win-arm64�.z-arm64.z-64.z-32.�142setuptools)r�r
�replacer	�files�joinpath�143read_bytes)r9�launcher_fns  rr�r�<sy���F�$�-�K��z�z��>�[�(�%�-�-�c�9�=�K�%�-�-�c�6�:�K�!�)�)�#�v�6���?�?�<�(�1�1�+�>�I�I�K�Krc��[R"[5RS5nUR	SS9[5-$)Nzlauncher manifest.xmlzutf-8)�encoding)r	r�rr��	read_text�vars)r��ress  rr�r�Os4��144�/�/�(�145#�146,�147,�-D�148E�C��=�=�'�=�*�T�V�3�3rc��[[R[5(a[$[R149"[RR
55$)zS150Return a regular expression based on first_line_re suitable for matching151strings.152)r4rr�r5r�r��decoderrrrUrUTs=��153�-�'�'��-�-����:�:�m�+�+�2�2�4�5�5rc�4�[R"S5S:H$)N�P�)�struct�calcsizerrrr�r�`s���?�?�3��1�$�$rc�H�URS5 g![a gf=f)N�asciiFT)�encode�UnicodeError)�ss rrKrKds,���	�����������s��154!�!)&�155__future__rr)r�rAr�r�rIr,r��collections.abcr�typingrr�156_importlibrr	�typing_extensionsr157�warningsr�distutils.command.build_scriptsr�distutils.utilr
rr^rrurxr�r�r�r�rUr�rKrrr�<module>r158s���"�	�	��
�
��159��$�+�+��&�'�9�'���%��160R%�$�R%�j)��)�g�g�T8E�,�8E�v>�&9�>�@L�&4�161	6�%�r
codekingpro/portable-devtools · Team Ai