o
ƚRe8E @ s d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm Z m
Z
ddlmZ ddl
mZmZmZmZmZmZ eeZd ZedZd Zd
d ZeZG dd
d
eZdS ) )BytesION ) sysconfigdetect_encodingZipFile)finder)FileOperatorget_export_entryconvert_pathget_executableget_platformin_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())
c C sZ d| v r+| dr"| dd\}}d|v r | ds d||f } | S | ds+d| } | S )N z
/usr/bin/env r "z%s "%s"z"%s")
startswithsplit)
executableenv_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.pyenquote_executable3 s
r c @ s e Zd ZdZeZdZ d*ddZdd Ze j
d r#d
d Zdd
Z
dd Zd+ddZdd ZeZdd Zdd ZdZdd Zd,ddZdd 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 )NFposixjava) X.Ynt)
source_dir
target_dir
add_launchersforceclobberosname_nameset_modesetvariantsr _fileop_is_ntsysversion_info)selfr r r dry_runfileopr r r __init__N s
zScriptMaker.__init__c C s@ | ddr| jrtj|\}}|dd}tj||}|S )NguiFpythonpythonw)getr* r# pathr replacejoin)r- r optionsdnfnr r r _get_alternate_executable_ s
z%ScriptMaker._get_alternate_executabler c C sd zt |}|ddkW d W S 1 sw Y W dS ttfy1 td| Y dS w )zl
Determine if the specified executable is a script
(contains a #! line)
z#!NzFailed to open %sF)openreadOSErrorIOErrorloggerwarning)r- r fpr r r _is_shellg s
(zScriptMaker._is_shellc C sJ | |rdd l}|jjddkr|S d| S | dr!|S d| S )Nr zos.nameLinuxz
jython.exez/usr/bin/env %s)rD r langSystemgetPropertylowerendswith)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_interpsimple_shebangshebang_lengthmax_shebang_lengthresultr r r _build_shebang s
zScriptMaker._build_shebang c C sn d}| j r| j }d}nDt st }n