� c��jw��"�ddlZddlZddlZddlZddlZddlZddlZgd�ZdZejjd�rdZ nej�Z Gd�de �Zejd��Zd �Zdd �Z dd �Zd �Zdd �Zedk(re�yy)�N)� ZipAppError�create_archive�get_interpreterz8# -*- coding: utf-8 -*- import {module} {module}.{fn}() �win�utf-8c� �eZdZy)rN)�__name__� __module__� __qualname__���/usr/lib64/python3.12/zipapp.pyrr!s��r rc#�K�t|ttjf�rt ||�5}|��ddd�y|��y#1swYyxYw�w�N)� isinstance�str�os�PathLike�open)�archive�mode�fs r� _maybe_openr%sA�����'�C����-�.� �'�4� �A��G�!� �� �!� �s�-A�A�A�A �Ac�b�|r-d|jt�zdz}|j|�yy)zWrite a shebang line.�#!� N)�encode�shebang_encoding�write)r� interpreter�shebangs r�_write_file_prefixr".s1����+�,�,�-=�>�>��F�� �����r c���t|d�5}|jd�}|dk(rd}|j�t|d�5}t||�|j |�t j ||�ddd�ddd�|rVt|t�rEtj|tj|�jtjz�yyy#1swY�jxYw#1swY�nxYw)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� ��d� +�s� �s�K� 0� �I�I�g� � � � �s�C� (� ,� $�"�z�+�s�3� ����b�g�g�k�2�:�:�T�\�\�I�J�4�{�,� +�� $� #�s#�5C+�4C�6C+�C( �$C+�+C4c�H�d}t|d�rt|d�rd}n'tj|�}|j�rd}|rt |||�y|j �s t d��|dz j�}|r |r t d��|s |s t d ��d}|r�|jd �\} } } td �| jd �D��} td �| jd �D��} | d k(r| r| st d|z��tj| | ��}|�|jd�}n!t|d�stj|�}t|d�5}t||�|rtj ntj"}tj$|d|��5}t'|j)d��D]>}|j+|�}|� ||�s�|j-||j/���@|r!|j1d|j3d��ddd�ddd�|rHt|d�s;|j5|j7�j8t6j:z�yyy#1swY�\xYw#1swY�`xYw)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�|]}|j����y�wr�� isidentifier��.0�parts r� z!create_archive..{s����D�^�T�T�&�&�(�^����.c3�<K�|]}|j����y�wrr7r9s rr<z!create_archive..|s����B�M�D�D�%�%�'�M�r=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�sorted�rglob� relative_tor�as_posix�writestrrr+r,r-r.)�source�targetr �main�filter� compressed�source_is_file�has_main�main_py�mod�seprA�mod_ok�fn_ok�fdrC�z�child�arcnames rrrLsE��*�N��v�v��7�6�:�#>������f�%�� �>�>� �!�N���f�f�k�2�� �=�=�?��1�2�2���&�/�/�1�H� ��� F�H� H� �H��6�7�7��G� ��~�~�c�*� ��S�"��D�S�Y�Y�s�^�D�D���B�B�H�H�S�M�B�B���s� �v�%��5��<�=� =��&�&�c�b�&�9�� �~��#�#�F�+�� �V�W� %����f�%�� �V�T� "�b��2�{�+�/9�w�+�+��)�)� � �_�_�R��+� >�!��� � �S� 1�2���+�+�F�3���>�V�G�_��G�G�E�7�#3�#3�#5�6�3��� � �=�'�.�.��*A�B� ?� #��7�6�7�3�� � �V�[�[�]�*�*�T�\�\�9�:�4�{�?� >�� #� "�s,�+AJ�29J �,AJ �1J� J �J�J!c���t|d�5}|jd�dk(r:|j�j�j t �cddd�S ddd�y#1swYyxYw)Nr$r%r)rr'r(�strip�decoder)rrs rrr�sS�� �W�d� #�q� �6�6�!�9�� ��:�:�<�%�%�'�.�.�/?�@� $� #� � $� #� #�s �AA&�&A/c�B�ddl}|j�}|jdddd��|jdddd ��|jd d dd ��|jd ddd��|jdddd��|jdd��|j|�}|jr|t j j|j�s td��t|j�}tdj|xsd��tjd�t j j|j�r�|j�]t j j!|j�r?t j j#|j|j�r td��|j$r td��t'|j|j|j(|j$|j*��y)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.)�actionrnz--infoFz)Display the interpreter from the archive.)rmrprnrYz'Source directory (or existing archive).)rnz%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 r[r])�argparse�ArgumentParser� add_argument� parse_args�infor�path�isfilerY� SystemExitr�printrN�sys�exit�outputrI�samefiler[r�python�compress)�argsrq�parserr s rr[r[�s���� � $� $� &�F� ��� �D�$�5��6� ��� �D�$�/��0� ����$��;��<� ��� �d�<�=��>� ����%� �<��>� ����:��<� � � �T� "�D� �y�y��w�w�~�~�d�k�k�*��D�E� E�%�d�k�k�2� � ��&�&�{�'>�h�?�@� ���� � �w�w�~�~�d�k�k�"� �;�;� �2�7�7�>�>�$�+�+�#>�#%�7�7�#3�#3�D�K�K����#M��L�M� M� �9�9��K�L� L��4�;�;�� � �#�{�{����"�m�m�-r �__main__r)NNNNF)� contextlibrrFr)r,rzrP�__all__rM�platform� startswithr�getfilesystemencoding� ValueErrorr�contextmanagerrr"r3rrr[r r r r�r�s���� �� � � �� >��� ��<�<���5�!���0�s�0�0�2�� �*� � �������K�.@D�+0�G;�TA� .-�b �z���F�r