From dbfcba5a2a9acc0f29177862d167e5d0907da329 Mon Sep 17 00:00:00 2001 From: stonebig Date: Sat, 20 Feb 2016 12:23:37 +0100 Subject: [PATCH] revert shebang failed improvement --- winpython/utils.py | 2 +- winpython/wppm.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/winpython/utils.py b/winpython/utils.py index f1bb7faf..11f7c30f 100644 --- a/winpython/utils.py +++ b/winpython/utils.py @@ -290,7 +290,7 @@ def get_python_long_version(path): # ============================================================================= # Patch chebang line (courtesy of Christoph Gohlke) # ============================================================================= -def patch_shebang_line(fname, pad=b' ', to_movable=True, targetdir="..\\"): +def patch_shebang_line(fname, pad=b' ', to_movable=True, targetdir=""): """Remove absolute path to python.exe in shebang lines, or re-add it""" import re diff --git a/winpython/wppm.py b/winpython/wppm.py index 71048984..f3fd84c6 100644 --- a/winpython/wppm.py +++ b/winpython/wppm.py @@ -381,14 +381,15 @@ def uninstall_existing(self, package): if pack is not None: self.uninstall(pack) - def patch_all_shebang(self, to_movable=True, max_exe_size=999999): + def patch_all_shebang(self, to_movable=True, max_exe_size=999999, targetdir=""): """make all python launchers relatives""" import glob import os for ffname in glob.glob(r'%s\Scripts\*.exe' % self.target): size = os.path.getsize(ffname) if size <= max_exe_size: - utils.patch_shebang_line(ffname, to_movable=to_movable) + utils.patch_shebang_line(ffname, to_movable=to_movable, + targetdir=targetdir) def install(self, package, install_options=None): @@ -459,17 +460,18 @@ def patch_standard_packages(self, package_name='', to_movable=True): # rational: https://github.com/pypa/pip/issues/2328 if package_name.lower() == "pip" or package_name == '': # ensure pip will create movable launchers - # sheb_mov1 = old way up to WinPython 2016-01, sheb_mov2 = new way + # sheb_mov1 = classic way up to WinPython 2016-01 + # sheb_mov2 = tried way, but doesn't work for pip (at least) sheb_fix = " executable = get_executable()" sheb_mov1 = " executable = os.path.join(os.path.basename(get_executable()))" sheb_mov2 = " executable = os.path.join('..',os.path.basename(get_executable()))" if to_movable: utils.patch_sourcefile(self.target + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py", - sheb_fix, sheb_mov2) + sheb_fix, sheb_mov1) utils.patch_sourcefile(self.target + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py", - sheb_mov1, sheb_mov2) + sheb_mov2, sheb_mov1) else: utils.patch_sourcefile(self.target + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py", @@ -479,6 +481,7 @@ def patch_standard_packages(self, package_name='', to_movable=True): sheb_mov2, sheb_fix) # ensure pip wheel will register relative PATH in 'RECORD' files + # will be in standard pip 8.0.3 utils.patch_sourcefile( self.target + ( r"\Lib\site-packages\pip\wheel.py"),