99from ..utils .fs import make_tree , copy_file , copy_tree , remove_file , remove_tree
1010from ..utils .log import debug , log
1111from ..utils .system import ldd , system
12- from ..utils .template import copy_template
12+ from ..utils .template import copy_template , load_template
1313
1414
1515__all__ = ["patch_binary" , "relocate_python" ]
@@ -122,6 +122,10 @@ def relocate_python(python=None, appdir=None):
122122 target = PYTHON_BIN + '/' + PYTHON_X_Y
123123 copy_file (source , target , update = True )
124124
125+ relpath = os .path .relpath (target , APPDIR_BIN )
126+ make_tree (APPDIR_BIN )
127+ os .symlink (relpath , APPDIR_BIN + '/' + PYTHON_X_Y )
128+
125129 copy_tree (HOST_PKG , PYTHON_PKG )
126130 copy_tree (HOST_INC , PYTHON_INC )
127131
@@ -146,7 +150,6 @@ def relocate_python(python=None, appdir=None):
146150 shutil .copymode (pip_source , target )
147151
148152 relpath = os .path .relpath (target , APPDIR_BIN )
149- make_tree (APPDIR_BIN )
150153 os .symlink (relpath , APPDIR_BIN + '/' + PIP_X_Y )
151154
152155
@@ -161,20 +164,6 @@ def relocate_python(python=None, appdir=None):
161164 remove_tree (path )
162165
163166
164- # Wrap the Python executable
165- log ('WRAP' , '%s executable' , PYTHON_X_Y )
166-
167- with open (PREFIX + '/data/python-wrapper.sh' ) as f :
168- text = f .read ()
169- text = text .replace ('{{PYTHON}}' , PYTHON_X_Y )
170-
171- make_tree (APPDIR_BIN )
172- target = APPDIR_BIN + '/' + PYTHON_X_Y
173- with open (target , 'w' ) as f :
174- f .write (text )
175- shutil .copymode (PYTHON_BIN + '/' + PYTHON_X_Y , target )
176-
177-
178167 # Set or update symlinks to python
179168 pythons = glob .glob (APPDIR_BIN + '/python?.*' )
180169 versions = [os .path .basename (python )[6 :] for python in pythons ]
@@ -285,7 +274,8 @@ def relocate_python(python=None, appdir=None):
285274 apprun = APPDIR + '/AppRun'
286275 if not os .path .exists (apprun ):
287276 log ('INSTALL' , 'AppRun' )
288- entrypoint = '"${{APPDIR}}/usr/bin/python{:}" "$@"' .format (VERSION )
277+ entrypoint_path = PREFIX + '/data/entrypoint.sh'
278+ entrypoint = load_template (entrypoint_path , python = PYTHON_X_Y )
289279 _copy_template ('apprun.sh' , apprun , entrypoint = entrypoint )
290280
291281
0 commit comments