<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    ÀÒ.e¢?  ã                   @   s¬   d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm	Z	m
Z
 ddlmZ ddlmZmZmZmZmZ e e¡Zd ¡ Ze d¡Zd	Zd
d„ ZG dd„ deƒZdS )é    )ÚBytesIONé   )Ú	sysconfigÚdetect_encodingÚZipFile)Úfinder)ÚFileOperatorÚget_export_entryÚconvert_pathÚget_executableÚin_venvañ  
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity version="1.0.0.0"
 processorArchitecture="X86"
 name="%s"
 type="win32"/>

 <!-- Identify the application security requirements. -->
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
 <security>
 <requestedPrivileges>
 <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
 </requestedPrivileges>
 </security>
 </trustInfo>
</assembly>s   ^#!.*pythonw?[0-9.]*([ 	].*)?$zÍ# -*- coding: utf-8 -*-
import re
import sys
from %(module)s import %(import_name)s
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(%(func)s())
c                 C   sX   d| krT|   d¡rB|  dd¡\}}d|krT|  d¡sTd||f } n|   d¡sTd|  } | S )Nú z/usr/bin/env r   ú"z%s "%s"z"%s")Ú
startswithÚsplit)Ú
executableÚenvZ_executable© r   ú?/usr/lib/python3.8/site-packages/pip/_vendor/distlib/scripts.pyÚ_enquote_executable3   s    

r   c                   @   sÚ   e Zd ZdZeZdZd'dd„Zdd„ Ze	j
 d	¡rBd
d„ Zdd„ Zdd„ Zd(dd„Zdd„ ZeZdd„ Zdd„ Zd)dd„Zdd„ Zedd„ ƒZejdd„ ƒZejd ksºejd	krÂejd krÂd!d"„ Zd*d#d$„Zd+d%d&„ZdS ),ÚScriptMakerz_
    A class to copy or create scripts from source scripts or callable
    specifications.
    NTFc                 C   sz   || _ || _|| _d| _d| _tjdkp:tjdko:tjdk| _t	dƒ| _
|pRt|ƒ| _tjdkprtjdkortjdk| _d S )NFÚposixÚjava)Ú úX.YÚnt)Ú
source_dirÚ
target_dirÚadd_launchersÚforceÚclobberÚosÚnameÚ_nameÚset_modeÚsetÚvariantsr   Ú_fileopÚ_is_nt)Úselfr   r   r   Údry_runZfileopr   r   r   Ú__init__L   s    ÿ

ÿzScriptMaker.__init__c                 C   s@   |  dd¡r<| jr<tj |¡\}}| dd¡}tj ||¡}|S )NÚguiFÚpythonZpythonw)Úgetr(   r!   Úpathr   ÚreplaceÚjoin)r)   r   ÚoptionsZdnÚfnr   r   r   Ú_get_alternate_executable\   s
    z%ScriptMaker._get_alternate_executabler   c              
   C   s\   z0t |ƒ}| d¡dkW  5 Q R £ W S Q R X W n& ttfk
rV   t d|¡ Y dS X dS )zl
            Determine if the specified executable is a script
            (contains a #! line)
            é   z#!zFailed to open %sFN)ÚopenÚreadÚOSErrorÚIOErrorÚloggerÚwarning)r)   r   Úfpr   r   r   Ú	_is_shelld   s    
&zScriptMaker._is_shellc                 C   sD   |   |¡r*dd l}|jj d¡dkr<|S n| ¡  d¡r<|S d| S )Nr   zos.nameZLinuxz
jython.exez/usr/bin/env %s)r=   r   ZlangZSystemZgetPropertyÚlowerÚendswith)r)   r   r   r   r   r   Ú_fix_jython_executablep   s    
z"ScriptMaker._fix_jython_executablec                 C   s‚   t jdkrd}n8t|ƒt|ƒ d }tjdkr4d}nd}d|koF||k}|r^d| | d	 }n d
}|d| | d 7 }|d7 }|S )a  
        Build a shebang line. In the simple case (on Windows, or a shebang line
        which is not too long or contains spaces) use a simple formulation for
        the shebang. Otherwise, use /bin/sh as the executable, with a contrived
        shebang which allows the script to run either under Python or sh, using
        suitable quoting. Thanks to Harald Nordgren for his input.

        See also: http://www.in-ulm.de/~mascheck/various/shebang/#length
                  https://hg.mozilla.org/mozilla-central/file/tip/mach
        r   Té   Údarwini   é   ó    s   #!ó   
s
   #!/bin/sh
s	   '''exec' s    "$0" "$@"
s   ' ''')r!   r"   ÚlenÚsysÚplatform)r)   r   Úpost_interpZsimple_shebangZshebang_lengthZmax_shebang_lengthÚresultr   r   r   Ú_build_shebang|   s    

ÿzScriptMaker._build_shebangó    c                 C   s`  d}| j r| j }d}n^t ¡ s&tƒ }nNtƒ rLtj t d¡dt 	d¡ ¡}n(tj t 	d¡dt 	d¡t 	d¡f ¡}|r„|  
||¡}tj d	¡rš|  |¡}tj |¡}|r²t|ƒ}| d
¡}tjdkrÞd|krÞd|krÞ|d7 }|  ||¡}z| d
¡ W n" tk
r   td| ƒ‚Y nX |d
kr\z| |¡ W n& tk
rZ   td||f ƒ‚Y nX |S )NTFZscriptszpython%sZEXEZBINDIRz
python%s%sZVERSIONr   úutf-8Zcliz	-X:Framesz-X:FullFramess
    -X:Framesz,The shebang (%r) is not decodable from utf-8z?The shebang (%r) is not decodable from the script encoding (%r))r   r   Zis_python_buildr   r   r!   r/   r1   Zget_pathZget_config_varr4   rG   rH   r   r@   Únormcaser   ÚencoderK   ÚdecodeÚUnicodeDecodeErrorÚ
ValueError)r)   ÚencodingrI   r2   Zenquoter   Úshebangr   r   r   Ú_get_shebang›   sZ    ÿ
ÿþ

ÿÿ

ÿÿ
zScriptMaker._get_shebangc                 C   s$   | j t|j|j d¡d |jd S )NÚ.r   )ÚmoduleZimport_nameÚfunc)Úscript_templateÚdictÚprefixÚsuffixr   )r)   Úentryr   r   r   Ú_get_script_textÓ   s    
þzScriptMaker._get_script_textc                 C   s   t j |¡}| j| S ©N)r!   r/   ÚbasenameÚmanifest)r)   ZexenameÚbaser   r   r   Úget_manifestÚ   s    zScriptMaker.get_manifestc                 C   sô  | j o
| j}tj d¡}| |¡s*||7 }|s8|| }nZ|dkrL|  d¡}n
|  d¡}tƒ }	t|	dƒ}
|
 	d|¡ W 5 Q R X |	 
¡ }|| | }|D ]V}tj | j|¡}|rxtj |¡\}}| d¡rÐ|}d| }z| j ||¡ W nŠ tk
rt   t d¡ d	| }tj |¡r&t |¡ t ||¡ | j ||¡ t d
¡ zt |¡ W n tk
rn   Y nX Y nX nl| jrœ| d| ¡sœd||f }tj |¡rÀ| jsÀt d|¡ q–| j ||¡ | jrä| j |g¡ | |¡ q–d S )NrM   ÚpyÚtÚwz__main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz%s.deletemez0Able to replace executable using .deleteme logicrV   z%s.%szSkipping existing file %s)r   r(   r!   ÚlineseprO   r?   Ú_get_launcherr   r   ZwritestrÚgetvaluer/   r1   r   Úsplitextr   r'   Zwrite_binary_fileÚ	Exceptionr:   r;   ÚexistsÚremoveÚrenameÚdebugr    r$   Úset_executable_modeÚappend)r)   ÚnamesrT   Zscript_bytesÚ	filenamesÚextZuse_launcherrg   ZlauncherÚstreamZzfZzip_datar"   ÚoutnameÚnÚeZdfnamer   r   r   Ú_write_scriptÞ   sX    







zScriptMaker._write_scriptc                 C   sè   d}|r0|  dg ¡}|r0dd |¡ }| d¡}| jd||d}|  |¡ d¡}|j}tƒ }	d| jkrp|	 |¡ d| jkr’|	 d	|t	j
d
 f ¡ d| jkr¸|	 d|t	j
d d… f ¡ |rÎ|  dd¡rÎd}
nd}
|  |	||||
¡ d S )NrL   Zinterpreter_argsz %sr   rM   ©r2   r   ÚXz%s%sr   r   z%s-%srA   r,   FÚpywrd   )r.   r1   rO   rU   r^   r"   r%   r&   ÚaddrG   Úversionry   )r)   r]   rs   r2   rI   ÚargsrT   Úscriptr"   Zscriptnamesrt   r   r   r   Ú_make_script  s(    




zScriptMaker._make_scriptc                 C   s˜  d}t j | jt|ƒ¡}t j | jt j |¡¡}| jsT| j 	||¡sTt
 d|¡ d S zt|dƒ}W n  tk
r‚   | jsz‚ d }Y nLX | ¡ }|s¦t
 d|  ¡ |¡ d S t | dd¡¡}|rÎd}| d¡pÌd	}|s|rà| ¡  | j ||¡ | jr| j |g¡ | |¡ n„t
 d
|| j¡ | jjs†t|jƒ\}	}
| d¡ |  |	|¡}d|kr^d}nd}t j |¡}|  |g||  ¡ ||¡ |r”| ¡  d S )NFznot copying %s (up-to-date)Úrbz"%s: %s is an empty file (skipping)s   
rE   Tr   rL   zcopying and adjusting %s -> %sr   s   pythonwr|   rd   )!r!   r/   r1   r   r
   r   r`   r   r'   Znewerr:   ro   r6   r9   r*   Úreadliner;   Zget_command_nameÚFIRST_LINE_REÚmatchr0   ÚgroupÚcloseZ	copy_filer$   rp   rq   Úinfor   ÚseekrU   ry   r7   )r)   r€   rs   Zadjustrv   ÚfZ
first_liner…   rI   rS   ÚlinesrT   rt   rw   r   r   r   Ú_copy_script)  sX    
 ÿÿ


zScriptMaker._copy_scriptc                 C   s   | j jS r_   ©r'   r*   )r)   r   r   r   r*   ]  s    zScriptMaker.dry_runc                 C   s   || j _d S r_   r   )r)   Úvaluer   r   r   r*   a  s    r   c                 C   sH   t  d¡dkrd}nd}d||f }t dd¡d }t|ƒ |¡j}|S )	NÚPé   Z64Z32z%s%s.exerV   r   r   )ÚstructÚcalcsizeÚ__name__Úrsplitr   ÚfindÚbytes)r)   ZkindÚbitsr"   Zdistlib_packagerJ   r   r   r   rh   i  s    zScriptMaker._get_launcherc                 C   s6   g }t |ƒ}|dkr"|  ||¡ n| j|||d |S )aÓ  
        Make a script.

        :param specification: The specification, which is either a valid export
                              entry specification (to make a script from a
                              callable) or a filename (to make a script by
                              copying from a source location).
        :param options: A dictionary of options controlling script generation.
        :return: A list of all absolute pathnames written to.
        Nrz   )r	   rŒ   r   )r)   Úspecificationr2   rs   r]   r   r   r   Úmakew  s    zScriptMaker.makec                 C   s$   g }|D ]}|  |  ||¡¡ q|S )zÂ
        Take a list of specifications and make scripts from them,
        :param specifications: A list of specifications.
        :return: A list of all absolute pathnames written to,
        )Úextendr™   )r)   Zspecificationsr2   rs   r˜   r   r   r   Úmake_multipleŠ  s    zScriptMaker.make_multiple)TFN)rL   N)N)N)N) r“   Ú
__module__Ú__qualname__Ú__doc__ÚSCRIPT_TEMPLATErY   r   r+   r4   rG   rH   r   r=   r@   rK   rU   r^   Ú_DEFAULT_MANIFESTra   rc   ry   r   rŒ   Úpropertyr*   Úsetterr!   r"   r#   rh   r™   r›   r   r   r   r   r   C   s6       ÿ

84
4


r   )Úior   Zloggingr!   Úrer‘   rG   Úcompatr   r   r   Z	resourcesr   Úutilr   r	   r
   r   r   Z	getLoggerr“   r:   Ústripr    Úcompiler„   rŸ   r   Úobjectr   r   r   r   r   Ú<module>   s   


