� !A?ho��*�ddlZddlZddlZddlZddlZddlZddlZgd�ZdZej � d��rdZ nej ��Z Gd�de ��Zejd���Zd �Zdd �Z dd �Zd �Zdd�Zedkr e��dSdS)�N)� ZipAppError�create_archive�get_interpreterz8# -*- coding: utf-8 -*- import {module} {module}.{fn}() �win�utf-8c��eZdZdS)rN)�__name__� __module__� __qualname__���3/opt/alt/python-internal/lib64/python3.11/zipapp.pyrr!s�������Dr rc#�K�t|ttjf��r/t ||��5}|V�ddd��dS#1swxYwYdS|V�dS�N)� isinstance�str�os�PathLike�open)�archive�mode�fs r� _maybe_openr%s������'�C���-�.�.�� �'�4� � � �A��G�G�G� � � � � � � � � � � � ���� � � � � � �� � � � � s�A�A � A c�x�|r7d|�t��zdz}|�|��dSdS)zWrite a shebang line.�#!� N)�encode�shebang_encoding�write)r� interpreter�shebangs r�_write_file_prefixr".sJ�����+�,�,�-=�>�>�>��F�� ����������r c�$�t|d��5}|�d��}|dkrd}|���t|d��5}t||��|�|��t j||��ddd��n #1swxYwYddd��n #1swxYwY|rPt|t��r=tj |tj |��j tj z��dSdSdS)z8Copy an application archive, modifying the shebang line.�rb�rr �wbN)r�read�readliner"r�shutil� copyfileobjrrr�chmod�stat�st_mode�S_IEXEC)r� new_archiver �src�first_2�dsts r� _copy_archiver35s��� �W�d� #� #�)�s��(�(�1�+�+�� �e� � ��G� �L�L�N�N�N� ��d� +� +� )�s� �s�K� 0� 0� 0� �I�I�g� � � � � �s�C� (� (� (�  )� )� )� )� )� )� )� )� )� )� )���� )� )� )� )�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)�"�K�z�+�s�3�3�K� ���b�g�k�2�2�:�T�\�I�J�J�J�J�J�K�K�K�Ks6�AB1�;B� B1�B �B1�!B �"B1�1B5�8B5Fc��d}t|d��rt|d��rd}n*tj|��}|���rd}|rt |||��dS|���st d���|dz ���}|r|rt d���|s|st d ���d}|r�|�d ��\} } } td �| � d ��D����} td �| � d ��D����} | d kr| r| st d|z���t� | | ���}|�|� d��}n$t|d��stj|��}t|d��5}t||��|r tjn tj}tj|d|���5}|�d��D]L}|�|��}|� ||��r(|�||������M|r)|�d|�d����ddd��n #1swxYwYddd��n #1swxYwY|rKt|d��s=|�|���jt4jz��dSdSdS)abCreate an application archive from SOURCE. The SOURCE can be the name of a directory, or a filename or a file-like object referring to an existing archive. The content of SOURCE is packed into an application archive in TARGET, which can be a filename or a file-like object. If SOURCE is a directory, TARGET can be omitted and will default to the name of SOURCE with .pyz appended. The created application archive will have a shebang line specifying that it should run with INTERPRETER (there will be no shebang line if INTERPRETER is None), and a __main__.py which runs MAIN (if MAIN is not specified, an existing __main__.py will be used). It is an error to specify MAIN for anything other than a directory source with no __main__.py, and it is an error to omit MAIN if the directory has no __main__.py. Fr'r(TNzSource does not existz __main__.pyz8Cannot specify entry point if the source has __main__.pyzArchive has no entry point�:c3�>K�|]}|���V��dSr�� isidentifier��.0�parts r� z!create_archive..{s.����D�D�T�T�&�&�(�(�D�D�D�D�D�Dr �.c3�>K�|]}|���V��dSrr7r9s rr<z!create_archive..|s.����B�B�D�D�%�%�'�'�B�B�B�B�B�Br zInvalid entry point: )�module�fnz.pyzrr&�w)� compression�*r)�hasattr�pathlib�Path�is_filer3�existsr� partition�all�split� MAIN_TEMPLATE�format� with_suffixrr"�zipfile� ZIP_DEFLATED� ZIP_STORED�ZipFile�rglob� relative_tor�as_posix�writestrrr+r,r-r.)�source�targetr �main�filter� compressed�source_is_file�has_main�main_py�mod�sepr@�mod_ok�fn_ok�fdrB�z�child�arcnames rrrLs���*�N��v�v���"�7�6�:�#>�#>�"������f�%�%�� �>�>� � � "�!�N����f�f�k�2�2�2��� �=�=�?�?�3��1�2�2�2���&�/�/�1�1�H� �H��H�� F�H�H� H� �8�H�8��6�7�7�7��G� �:��~�~�c�*�*� ��S�"��D�D�S�Y�Y�s�^�^�D�D�D�D�D���B�B�B�H�H�S�M�M�B�B�B�B�B���s� � �v� �%� ��5��<�=�=� =��&�&�c�b�&�9�9�� �~��#�#�F�+�+��� �V�W� %� %�&���f�%�%�� �V�T� "� "� C�b��2�{�+�+�+�/9�*�w�+�+��)� � �_�R��+� >� >� >� C�!����c�*�*� 7� 7���+�+�F�3�3���>�V�V�G�_�_�>��G�G�E�7�#3�#3�#5�#5�6�6�6��� C�� � �=�'�.�.��*A�*A�B�B�B�  C� C� C� C� C� C� C� C� C� C� C���� C� C� C� C� C� C� C� C� C� C� C� C� C� C� C���� C� C� C� C��;�7�6�7�3�3�;�� � �V�[�[�]�]�*�T�\�9�:�:�:�:�:�;�;�;�;s8�>AJ1�BJ� J1�J �J1�!J �"J1�1J5�8J5c� �t|d��5}|�d��dkrJ|�������t ��cddd��S ddd��dS#1swxYwYdS)Nr$r%r)rr'r(�strip�decoder)rrs rrr�s��� �W�d� #� #�A�q� �6�6�!�9�9�� � ��:�:�<�<�%�%�'�'�.�.�/?�@�@�A�A�A�A�A�A�A�A� �A�A�A�A�A�A�A�A�A�A�A�A����A�A�A�A�A�As�AB�B� Bc�*�ddl}|���}|�dddd���|�dddd ���|�d d dd ���|�d ddd���|�dddd���|�dd���|�|��}|jrt j�|j��std���t|j��}td� |pd����tjd��t j�|j��rz|j�Nt j�|j��r9t j�|j|j��rtd���|jrtd���t'|j|j|j|j|j���dS)z�Run the zipapp command line interface. The ARGS parameter lets you specify the argument list directly. Omitting ARGS (or setting it to None) works as for argparse, using sys.argv[1:] as the argument list. rNz--outputz-ozAThe name of the output archive. Required if SOURCE is an archive.)�default�helpz--pythonz-pzEThe name of the Python interpreter to use (default: no shebang line).z--mainz-mzLThe main function of the application (default: use an existing __main__.py).z --compressz-c� store_truezQCompress files with the deflate method. Files are stored uncompressed by default.)�actionrlz--infoFz)Display the interpreter from the archive.)rkrnrlrWz'Source directory (or existing archive).)rlz%Can only get info for an archive filezInterpreter: {}zz-In-place editing of archives is not supportedz,Cannot change the main function when copying)r rYr[)�argparse�ArgumentParser� add_argument� parse_args�infor�path�isfilerW� SystemExitr�printrM�sys�exit�outputrH�samefilerYr�python�compress)�argsro�parserr s rrYrY�sI���O�O�O� � $� $� &� &�F� ��� �D�$�5��6�6�6� ��� �D�$�/��0�0�0� ����$��;��<�<�<� ��� �d�<�=��>�>�>� ����%� �<��>�>�>� ����:��<�<�<� � � �T� "� "�D� �y���w�~�~�d�k�*�*� F��D�E�E� E�%�d�k�2�2� � ��&�&�{�'>�h�?�?�@�@�@� ��� � � � �w�~�~�d�k�"�"�M� �;� �2�7�>�>�$�+�#>�#>� �#%�7�#3�#3�D�K���#M�#M� ��L�M�M� M� �9� M��K�L�L� L��4�;�� �#�{���"�m�-�-�-�-�-�-r �__main__r)NNNNF)� contextlibrrEr)r,rxrO�__all__rL�platform� startswithr�getfilesystemencoding� ValueErrorr�contextmanagerrr"r3rrrYr r r r�r�sk������ � � � ����� � � � � � � � � � � � ����� >� >� >��� ��<���5�!�!�3����0�s�0�2�2�� � � � � �*� � � � ����������K�K�K�K�.@D�+0�G;�G;�G;�G;�TA�A�A� .-�.-�.-�.-�b �z����D�F�F�F�F�F��r