Viewing File: /usr/lib/python3.6/site-packages/pip/_vendor/distlib/__pycache__/scripts.cpython-36.opt-1.pyc
3
ajx; @ s d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm Z m
Z
ddlmZ ddl
mZmZmZmZmZ ejeZdj ZejdZd Zd
d ZG dd
d
eZdS ) )BytesION ) sysconfigdetect_encodingZipFile)finder)FileOperatorget_export_entryconvert_pathget_executablein_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.]*([ ].*)?$a| # -*- coding: utf-8 -*-
if __name__ == '__main__':
import sys, re
def _resolve(module, func):
__import__(module)
mod = sys.modules[module]
parts = func.split('.')
result = getattr(mod, parts.pop(0))
for p in parts:
result = getattr(result, p)
return result
try:
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
func = _resolve('%(module)s', '%(func)s')
rc = func() # None interpreted as 0
except Exception as e: # only supporting Python >= 2.6
sys.stderr.write('%%s\n' %% e)
rc = 1
sys.exit(rc)
c C sZ d| krV| j drD| jdd\}}d|krV|j d rVd||f } n| j dsVd| } | S )N z
/usr/bin/env r "z%s "%s"z"%s")
startswithsplit)
executableenvZ_executable r /usr/lib/python3.6/scripts.py_enquote_executableB s
r c @ s e Zd ZdZeZdZd%ddZdd Ze j
jd rBd
d Zdd
Z
d&ddZdd ZeZdd Zdd Zd'ddZdd Zedd Zejdd Zejdksejd krejdkrdd Zd(d!d"Zd)d#d$ZdS )*ScriptMakerz_
A class to copy or create scripts from source scripts or callable
specifications.
NTFc C sz || _ || _|| _d| _d| _tjdkp:tjdko:tjdk| _t d| _
|pRt|| _tjdkprtjdkortjdk| _
d S )NFposixjava X.Ynt)r r )
source_dir
target_dir
add_launchersforceclobberosname_nameset_modesetvariantsr _fileop_is_nt)selfr r r dry_runZfileopr r r __init__[ s
zScriptMaker.__init__c C s@ |j ddr<| jr<tjj|\}}|jdd}tjj||}|S )NguiFpythonZpythonw)getr( r! pathr replacejoin)r) r optionsZdnfnr r r _get_alternate_executablek s
z%ScriptMaker._get_alternate_executabler c C sL y"t |}|jddkS Q R X W n$ ttfk
rF tjd| dS X dS )zl
Determine if the specified executable is a script
(contains a #! line)
z#!NzFailed to open %sF)openreadOSErrorIOErrorloggerwarning)r) r fpr r r _is_shells s
zScriptMaker._is_shellc C sD | j |r*dd l}|jjjddkr<|S n|j jdr<|S d| S )Nr zos.nameZLinuxz
jython.exez/usr/bin/env %s)r= r ZlangZSystemZgetPropertylowerendswith)r) r r r r r _fix_jython_executable s
z"ScriptMaker._fix_jython_executable c C sd d}| j r| j }d}n^tj s&t }nNt rLtjjtjddtj d }n(tjjtj ddtj dtj df }|r| j
||}tjj
d r| j|}tjj|}|rt|}|jd
}tjdkrd|krd
|kr|d7 }d| | d }y|jd
W n" tk
r td| Y nX |d
kr`y|j| W n& tk
r^ td||f Y nX |S )NTFscriptszpython%sEXEBINDIRz
python%s%sVERSIONr zutf-8Zcliz -X:Framesz
-X:FullFramess
-X:Framess #!
z,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! r/ r1 get_pathget_config_varr4 sysplatformr r@ normcaser encodedecodeUnicodeDecodeError
ValueError)r) encodingpost_interpr2 Zenquoter shebangr r r _get_shebang sL
zScriptMaker._get_shebangc C s | j t|j|jd S )N)modulefunc)script_templatedictprefixsuffix)r) entryr r r _get_script_text s
zScriptMaker._get_script_textc C s t jj|}| j| S )N)r! r/ basenamemanifest)r) Zexenamebaser r r get_manifest s zScriptMaker.get_manifestc C s | j o
| j}tjjd}|s*|| | }n^|dkr>| jd}n
| jd}t } t| d}
|
jd| W d Q R X | j }|| | | }xd|D ]Z}tj
j| j|}
|rrtj
j
|
\}}|jdr|}
d|
}
y| jj|
| W n tk
rn tjd d |
}tj
j|r tj| tj|
| | jj|
| tjd
ytj| W n tk
rh Y nX Y nX np| jr|
jd| rd|
|f }
tj
j|
r| j rtjd
|
q| jj|
| | jr| jj|
g |j|
qW d S )Nzutf-8pytwz__main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz%s.deletemez0Able to replace executable using .deleteme logic.z%s.%szSkipping existing file %s)r r( r! lineseprM
_get_launcherr r Zwritestrgetvaluer/ r1 r splitextr r' Zwrite_binary_file Exceptionr: r; existsremoverenamedebugr? r r$ set_executable_modeappend)r) namesrS Zscript_bytes filenamesextZuse_launcherre ZlauncherstreamZzfZzip_datar"