U ��.e�?�@s�ddlmZddlZddlZddlZddlZddlZddlmZm Z m Z ddl m Z ddl mZmZmZmZmZe�e�Zd��Ze�d�Zd Zd d �ZGd d �d e�ZdS)�)�BytesION�)� sysconfig�detect_encoding�ZipFile)�finder)� FileOperator�get_export_entry� convert_path�get_executable�in_venva� 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()) cCsXd|krT|�d�rB|�dd�\}}d|krT|�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_executable3s  rc@s�eZdZdZeZdZd'dd�Zdd�Ze j � d �rBd d �Z d d �Z dd�Zd(dd�Zdd�ZeZdd�Zdd�Zd)dd�Zdd�Zedd��Zejdd��Zejd ks�ejd kr�ejd kr�d!d"�Zd*d#d$�Zd+d%d&�ZdS),� ScriptMakerz_ A class to copy or create scripts from source scripts or callable specifications. NTFcCsz||_||_||_d|_d|_tjdkp:tjdko:tjdk|_t d�|_ |pRt |�|_ tjdkprtjdkortjdk|_ dS)NF�posix�java)��X.Y�nt)� source_dir� target_dir� add_launchers�force�clobber�os�name�_name�set_mode�set�variantsr�_fileop�_is_nt)�selfrrr�dry_runZfileoprrr�__init__Ls�  �zScriptMaker.__init__cCs@|�dd�r<|jr %srspythonwr|rd)!r!r/r1rr rr`rr'Znewerr:ror6r9r*�readliner;Zget_command_name� FIRST_LINE_RE�matchr0�group�closeZ copy_filer$rprq�infor�seekrUryr7)r)r�rsZadjustrv�fZ first_liner�rIrS�linesrTrtrwrrr� _copy_script)sX  � �     zScriptMaker._copy_scriptcCs|jjSr_�r'r*)r)rrrr*]szScriptMaker.dry_runcCs ||j_dSr_r�)r)�valuerrrr*asrcCsHt�d�dkrd}nd}d||f}t�dd�d}t|��|�j}|S) N�P�Z64Z32z%s%s.exerVrr)�struct�calcsize�__name__�rsplitr�find�bytes)r)Zkind�bitsr"Zdistlib_packagerJrrrrhis zScriptMaker._get_launchercCs6g}t|�}|dkr"|�||�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)� specificationr2rsr]rrr�makews zScriptMaker.makecCs$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)Zspecificationsr2rsr�rrr� make_multiple�szScriptMaker.make_multiple)TFN)rLN)N)N)N) r�� __module__� __qualname__�__doc__�SCRIPT_TEMPLATErYrr+r4rGrHrr=r@rKrUr^�_DEFAULT_MANIFESTrarcryr�r��propertyr*�setterr!r"r#rhr�r�rrrrrCs6�     84 4   r)�iorZloggingr!�rer�rG�compatrrrZ resourcesr�utilrr r r r Z getLoggerr�r:�stripr��compiler�r�r�objectrrrrr�s