Skip to content

revert shebang failed improvement #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion winpython/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions winpython/wppm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
Expand All @@ -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"),
Expand Down