ž
7’Re0 c @ 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
m Z d d l m
Z
d d l m Z m Z m Z m Z m Z e j e ƒ Z d j ƒ Z e j d ƒ Z d Z Gd
d „ d e ƒ Z d S( i ( u BytesIONi ( u sysconfigu fsencodeu detect_encodingu ZipFile( u finder( u FileOperatoru get_export_entryu convert_pathu get_executableu in_venvuñ
s ^#!.*pythonw?[0-9.]*([ ].*)?$u{ # -*- 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 B s | Ee Z d Z d Z e Z d Z d d d d d „ Z
d d „ Z d 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 rß d d „ Z n d d d „ Z d d d „ Z d S( u ScriptMakeru_
A class to copy or create scripts from source scripts or callable
specifications.
c C sg | | _ | | _ | | _ d | _ d | _ t j d k | _ t d ƒ | _
| p] t | ƒ | _ d S( Nu posixu u X.YF( u u X.Y(
u
source_diru
target_diru
add_launchersu Falseu forceu clobberu osu nameu set_modeu setu variantsu FileOperatoru _fileop( u selfu
source_diru
target_diru
add_launchersu dry_runu fileop( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu __init__K s u ScriptMaker.__init__c C sg | j d d ƒ rc t j d k rc t j j | ƒ \ } } | j d d ƒ } t j j | | ƒ } n | S( Nu guiu ntu pythonu pythonwF( u getu Falseu osu nameu pathu splitu replaceu join( u selfu
executableu optionsu dnu fn( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _get_alternate_executableW s
!u% ScriptMaker._get_alternate_executables c C s‡ d } | j r! | j } d } n‰ t j ƒ s9 t ƒ } nq t ƒ rp t j j t j
d ƒ d t j d ƒ ƒ } n: t j j t j d ƒ d t j d ƒ t j d ƒ f ƒ } | rÅ | j | | ƒ } n | rä d | k rä d | } n t
| ƒ } d | | d
} y | j d ƒ Wn" t k
r7t d | ƒ ‚ Yn X| d k rƒy | j | ƒ Wqƒt k
rt d
| | f ƒ ‚ YqƒXn | S( Nu scriptsu python%su EXEu BINDIRu
python%s%su VERSIONu u "%s"s #!s
u utf-8u, The shebang (%r) is not decodable from utf-8u? The shebang (%r) is not decodable from the script encoding (%r)TF( u Trueu
executableu Falseu sysconfigu is_python_buildu get_executableu in_venvu osu pathu joinu get_pathu get_config_varu _get_alternate_executableu fsencodeu decodeu UnicodeDecodeErroru
ValueError( u selfu encodingu post_interpu optionsu enquoteu
executableu shebang( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _get_shebang^ s@
u ScriptMaker._get_shebangc C s | j t d | j d | j ƒ S( Nu moduleu func( u script_templateu dictu prefixu suffix( u selfu entry( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _get_script_textŒ s u ScriptMaker._get_script_textc C s t j j | ƒ } | j | S( N( u osu pathu basenameu manifest( u selfu exenameu base( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu get_manifest’ s u ScriptMaker.get_manifestc C s | j o t j d k } t j j d ƒ } | sA | | | } n| | d k r_ | j d ƒ } n | j d ƒ } t ƒ } t | d ƒ }
|
j d | ƒ Wd QX| j ƒ } | | | | } xË| D]Ã} t j
j | j | ƒ }
| ràt j
j
|
ƒ \ } } | j d ƒ r| }
n d |
}
y | j j |
| ƒ Wqzt k
rÜt j d ƒ d
|
} t j
j | ƒ r‚t j | ƒ n t j |
| ƒ | j j |
| ƒ t j d ƒ y t j | ƒ Wn t k
r×Yn XYqzXnš t j d k r|
j d | ƒ rd
|
| f }
n t j
j |
ƒ rH| j rHt j d |
ƒ qÄ n | j j |
| ƒ | j rz| j j |
g ƒ n | j |
ƒ qÄ Wd S( Nu ntu utf-8u pyu tu wu __main__.pyu .pyu %s.exeu: Failed to write executable - trying to use .deleteme logicu %s.deletemeu0 Able to replace executable using .deleteme logicu .u %s.%su Skipping existing file %s( u
add_launchersu osu nameu linesepu encodeu
_get_launcheru BytesIOu ZipFileu writestru getvalueu pathu joinu
target_diru splitextu
startswithu _fileopu write_binary_fileu Exceptionu loggeru warningu existsu removeu renameu debugu endswithu clobberu set_modeu set_executable_modeu append( u selfu namesu shebangu script_bytesu filenamesu extu use_launcheru linesepu launcheru streamu zfu zip_datau nameu outnameu nu eu dfname( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu
_write_script– sT
# u ScriptMaker._write_scriptc C s | j d d | ƒ} | j | ƒ j d ƒ } | j } t ƒ } d | j k r^ | j | ƒ n d | j k rŽ | j d | t j d f ƒ n d | j k rÄ | j d | t j d d … f ƒ n | rå | j d
d
ƒ rå d } n d } | j | | | | | ƒ d S( Nu utf-8u optionsu u Xu %s%si u X.Yu %s-%si u guiu pywu pyF( u _get_shebangu _get_script_textu encodeu nameu setu variantsu addu sysu versionu getu Falseu
_write_script( u selfu entryu filenamesu optionsu shebangu scriptu nameu scriptnamesu ext( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _make_scriptÈ s !' u ScriptMaker._make_scriptc C sA d
} t j j | j t | ƒ ƒ } t j j | j t j j | ƒ ƒ } | j r| | j j
| | ƒ r| t j d | ƒ d Sy t
| d ƒ } Wn' t k
r¸ | j s® ‚ n d } Yn‘ Xt | j ƒ \ } } | j d ƒ | j ƒ } | s
t j d | j ƒ | ƒ d St j | j d d ƒ ƒ } | rId } | j d ƒ pCd }
n | s¤| rb| j ƒ n | j j | | ƒ | j r”| j j | g ƒ n | j | ƒ n™ t j d | | j ƒ | j j s*| j! | |
ƒ } d
| k ríd } n d } t j j | ƒ }
| j" |
g | | j# ƒ | | ƒ n | r=| j ƒ n d S( Nu not copying %s (up-to-date)u rbi u" %s: %s is an empty file (skipping)s
s
i s u copying and adjusting %s -> %ss pythonwu pywu pyFT($ u Falseu osu pathu joinu
source_diru convert_pathu
target_diru basenameu forceu _fileopu neweru loggeru debugu openu IOErroru dry_runu Noneu detect_encodingu readlineu seeku warningu get_command_nameu
FIRST_LINE_REu matchu replaceu Trueu groupu closeu copy_fileu set_modeu set_executable_modeu appendu infou _get_shebangu
_write_scriptu read( u selfu scriptu filenamesu adjustu outnameu fu encodingu linesu
first_lineu matchu post_interpu shebangu extu n( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _copy_scriptÙ sR $
%u ScriptMaker._copy_scriptc C s
| j j S( N( u _fileopu dry_run( u self( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu dry_run
s u ScriptMaker.dry_runc C s | | j _ d S( N( u _fileopu dry_run( u selfu value( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu dry_run s u ntc C sf t j d ƒ d k r d } n d } d | | f } t j d d ƒ d } t | ƒ j | ƒ j } | S( Nu Pi u 64u 32u %s%s.exeu .i i ( u structu calcsizeu __name__u rsplitu finderu findu bytes( u selfu kindu bitsu nameu distlib_packageu result( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu
_get_launcher s u ScriptMaker._get_launcherc C sK g } t | ƒ } | d k r1 | j | | ƒ n | j | | d | ƒ| S( uÓ
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.
u optionsN( u get_export_entryu Noneu _copy_scriptu _make_script( u selfu
specificationu optionsu filenamesu entry( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu make' s u ScriptMaker.makec C s4 g } x' | D] } | j | j | | ƒ ƒ q
W| S( uÂ
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,
( u extendu make( u selfu specificationsu optionsu filenamesu
specification( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu
make_multiple: s
u ScriptMaker.make_multipleNTF( u __name__u
__module__u __qualname__u __doc__u SCRIPT_TEMPLATEu script_templateu Noneu
executableu Trueu Falseu __init__u _get_alternate_executableu _get_shebangu _get_script_textu _DEFAULT_MANIFESTu manifestu get_manifestu
_write_scriptu _make_scriptu _copy_scriptu propertyu dry_runu setteru osu nameu
_get_launcheru makeu
make_multiple( u
__locals__( ( u4 /tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu ScriptMakerB s&