
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \õ  ã               @   s¾   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZdddgZdZej	j
dƒrXdZnejƒ ZG dd„ deƒZe jd	d
„ ƒZdd„ Zddd„Zddd„Zdd„ Zddd„Zedkrºeƒ  dS )é    NÚZipAppErrorÚcreate_archiveÚget_interpreterz8# -*- coding: utf-8 -*-
import {module}
{module}.{fn}()
Úwinzutf-8c               @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r	   r	   ú/usr/lib64/python3.6/zipapp.pyr   !   s   c          	   c   sF   t | tjƒrt| ƒ} t | tƒr<t| |ƒ�}|V  W d Q R X n| V  d S )N)Ú
isinstanceÚpathlibÚPathÚstrÚopen)ÚarchiveÚmodeÚfr	   r	   r
   Ú_maybe_open%   s    
r   c             C   s$   |r d|j tƒ d }| j|ƒ dS )zWrite a shebang line.s   #!ó   
N)ÚencodeÚshebang_encodingÚwrite)r   ÚinterpreterZshebangr	   r	   r
   Ú_write_file_prefix0   s    r   c             C   s–   t | dƒ�Z}|jdƒ}|dkr*d}|jƒ  t |dƒ�&}t||ƒ |j|ƒ tj||ƒ W dQ R X W dQ R X |r’t|tƒr’t	j
|t	j|ƒjtjB ƒ dS )z8Copy an application archive, modifying the shebang line.Úrbé   s   #!ó    ÚwbN)r   ÚreadÚreadliner   r   ÚshutilZcopyfileobjr   r   ÚosÚchmodÚstatÚst_modeÚS_IEXEC)r   Znew_archiver   ÚsrcZfirst_2Údstr	   r	   r
   Ú_copy_archive7   s    


 r(   c             C   sÞ  d}t | dƒrt | dƒrd}ntj| ƒ} | jƒ r4d}|rHt| ||ƒ dS | jƒ sXtdƒ‚| d jƒ }|rt|rttdƒ‚|pz|s„td	ƒ‚d}|rö|jd
ƒ\}}}	tdd„ |j	dƒD ƒƒ}
tdd„ |	j	dƒD ƒƒ}|d
koÚ|
oÚ|sètd| ƒ‚t
j||	d�}|dk�r| jdƒ}nt |dƒ�s"tj|ƒ}t|dƒ�~}t||ƒ tj|dƒ�\}tj| ƒ}x2|jdƒD ]$}t|j|ƒƒ}|jt|ƒ|ƒ �q\W |�rœ|jd|jdƒƒ W dQ R X W dQ R X |�rÚt |dƒ �rÚ|j|jƒ jtjB ƒ dS )ab  Create 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   TNzSource does not existz__main__.pyz8Cannot specify entry point if the source has __main__.pyzArchive has no entry pointú:c             s   s   | ]}|j ƒ V  qd S )N)Úisidentifier)Ú.0Úpartr	   r	   r
   ú	<genexpr>|   s    z!create_archive.<locals>.<genexpr>Ú.c             s   s   | ]}|j ƒ V  qd S )N)r*   )r+   r,   r	   r	   r
   r-   }   s    zInvalid entry point: )ÚmoduleÚfnz.pyzr   r   ÚwÚ*zutf-8)Úhasattrr   r   Úis_filer(   Úexistsr   Ú	partitionÚallÚsplitÚMAIN_TEMPLATEÚformatZwith_suffixr   r   ÚzipfileZZipFileZrglobr   Zrelative_tor   Zwritestrr   r"   r#   r$   r%   )ÚsourceÚtargetr   ÚmainZsource_is_fileZhas_mainZmain_pyÚmodÚsepr0   Zmod_okZfn_okÚfdÚzÚrootZchildZarcnamer	   r	   r
   r   N   sP    




&c          	   C   s:   t | dƒ�&}|jdƒdkr,|jƒ jƒ jtƒS W d Q R X d S )Nr   r   s   #!)r   r   r   ÚstripÚdecoder   )r   r   r	   r	   r
   r   •   s    c             C   s   ddl }|jƒ }|jddddd� |jdddd	d� |jd
dddd� |jddddd� |jddd� |j| ƒ} | jr²tjj| jƒsŒt	dƒ‚t
| jƒ}tdj|p¢dƒƒ tjdƒ tjj| jƒ�r| jdksìtjj| jƒrôtjj| j| jƒrôt	dƒ‚| j�rt	dƒ‚t| j| j| j| jd� dS )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.
    r   Nz--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--infoFÚ
store_truez)Display the interpreter from the archive.)rF   ÚactionrG   r<   z'Source directory (or existing archive).)rG   z%Can only get info for an archive filezInterpreter: {}z<none>z-In-place editing of archives is not supportedz,Cannot change the main function when copying)r   r>   )ÚargparseÚArgumentParserÚadd_argumentÚ
parse_argsÚinfor!   ÚpathÚisfiler<   Ú
SystemExitr   Úprintr:   ÚsysÚexitÚoutputr5   Úsamefiler>   r   Úpython)ÚargsrJ   Úparserr   r	   r	   r
   r>   ›   s6    







r>   Ú__main__)N)NNN)N)Ú
contextlibr!   r   r    r#   rS   r;   Ú__all__r9   ÚplatformÚ
startswithr   ÚgetfilesystemencodingÚ
ValueErrorr   Úcontextmanagerr   r   r(   r   r   r>   r   r	   r	   r	   r
   Ú<module>   s(   


G
-