관리-도구
편집 파일: scripts.cpython-310.pyc
o ƚRe8E � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm Z m Z ddlmZ ddl mZmZmZmZmZmZ e�e�Zd�� Ze�d�Zd Zd d� ZeZG dd � d e�ZdS )� )�BytesION� )� sysconfig�detect_encoding�ZipFile)�finder)�FileOperator�get_export_entry�convert_path�get_executable�get_platform�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 sZ d| v r+| � d�r"| �dd�\}}d|v r |� d�s d||f } | S | � d�s+d| } | S )N� z /usr/bin/env r �"z%s "%s"z"%s")� startswith�split)� executable�env�_executable� r ��/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/scripts.py�enquote_executable3 s �r c @ s� e Zd ZdZeZdZ d*dd�Zdd� Ze j �d �r#d d� Zdd � Z dd� Zd+dd�Zdd� ZeZdd� Zdd� ZdZdd� Zd,dd�Zdd� Zed d!� �Zejd"d!� �Zejd#kseejd kriejd#krid$d%� Zd,d&d'�Z d,d(d)�Z!dS )-�ScriptMakerz_ A class to copy or create scripts from source scripts or callable specifications. NTFc C s� || _ || _|| _d| _d| _tjdkptjdkotjdk| _t d�| _ |p)t|�| _tjdkp9tjdko9tjdk| _ tj| _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�sys�version_info)�selfr r r �dry_run�fileopr r r �__init__N s � �zScriptMaker.__init__c C s@ |� dd�r| jrtj�|�\}}|�dd�}tj�||�}|S )N�guiF�python�pythonw)�getr* r# �pathr �replace�join)r- r �options�dn�fnr r r �_get_alternate_executable_ s z%ScriptMaker._get_alternate_executabler c C sd zt |��}|�d�dkW d � W S 1 sw Y W dS ttfy1 t�d|� Y dS w )zl Determine if the specified executable is a script (contains a #! line) � z#!NzFailed to open %sF)�open�read�OSError�IOError�logger�warning)r- r �fpr r r � _is_shellg s (��zScriptMaker._is_shellc C sJ | � |�rdd l}|jj�d�dkr|S d| S |�� �d�r!|S d| S )Nr zos.name�Linuxz jython.exez/usr/bin/env %s)rD r �lang�System�getProperty�lower�endswith)r- r r r r r �_fix_jython_executables s �z"ScriptMaker._fix_jython_executablec C s� t jdkrd}nt|�t|� d }tjdkrd}nd}d|vo#||k}|r0d| | d }|S 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$ �lenr+ �platform)r- r �post_interp�simple_shebang�shebang_length�max_shebang_length�resultr r r �_build_shebang s ��zScriptMaker._build_shebang� c C sn d}| j r| j }d}nDt�� st� }n<t� r&tj�t�d�dt� d� �}n)tj�t� d�dt� d�t� d�f �}tj� |�sOtj�t� d�dt� d� �}|rW| �||�}tj �d �rb| �|�}|rht|�}|�d �}tj dkr~d|vr~d |vr~|d7 }| �||�}z|�d � W n ty� td| ��w |d kr�z|�|� W |S ty� td||f ��w |S )NTF�scriptszpython%s�EXE�BINDIRz python%s%s�VERSIONr �utf-8�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 �is_python_buildr r r# r5 r7 �get_path�get_config_var�isfiler; r+ rR r rK r �encoderX �decode�UnicodeDecodeError� ValueError)r- �encodingrS r8 �enquoter �shebangr r r �_get_shebang� sd � ��� ������zScriptMaker._get_shebangc C s$ | j t|j|j�d�d |jd� S )N�.r )�module�import_name�func)�script_template�dict�prefix�suffixr )r- �entryr r r �_get_script_text� s �zScriptMaker._get_script_textc C s t j�|�}| j| S �N)r# r5 �basename�manifest)r- �exename�baser r r �get_manifest� s zScriptMaker.get_manifestc C s� | j o| j}tj�d�}|�|�s||7 }|s|| }n7|dkr&| �d�}n| �d�}t� } t| d��} | � d|� W d � n1 sDw Y | � � }|| | }|D ]�}tj�| j |�} |r�tj�| �\}}|�d�rp|} d| } z | j�| |� W nq ty� t�d� d | }tj�|�r�t�|� t�| |� | j�| |� t�d � zt�|� W n ty� Y nw Y n2w | jr�| �d| �s�d| |f } tj�| �r�| js�t�d | � qU| j�| |� | jr�| j�| g� |�| � qUd S )Nr^ �py�t�wz__main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz%s.deletemez0Able to replace executable using .deleteme logicrl z%s.%szSkipping existing file %s)r r* r# �lineseprd rJ � _get_launcherr r �writestr�getvaluer5 r7 r �splitextr r) �write_binary_file� ExceptionrA rB �exists�remove�rename�debugr"