Always prune shebangs (because of upgrades)

This commit is contained in:
Valentin Niess
2020-04-15 17:33:56 +02:00
parent f291e8e3e9
commit 5cf28eef19

View File

@@ -43,9 +43,6 @@ def patch_pip_install():
args = sys.argv[1:]
if 'install' in args:
for exe in os.listdir(sys.prefix + '/bin'):
if exe in _bin_at_start:
continue
path = os.path.join(sys.prefix, 'bin', exe)
if (not os.path.isfile(path)) or (not os.access(path, os.X_OK)) or \
@@ -53,12 +50,6 @@ def patch_pip_install():
exe.endswith('.pyc') or exe.endswith('.pyo'):
continue
usr_dir = os.path.join(sys.prefix, '../../usr/bin')
usr_exe = os.path.join(usr_dir, exe)
if not os.path.exists(usr_exe):
relpath = os.path.relpath(path, usr_dir)
os.symlink(relpath, usr_exe)
try:
with open(path, 'r') as f:
header = f.read(2)
@@ -93,6 +84,15 @@ def patch_pip_install():
except IOError:
continue
if exe in _bin_at_start:
continue
usr_dir = os.path.join(sys.prefix, '../../usr/bin')
usr_exe = os.path.join(usr_dir, exe)
if not os.path.exists(usr_exe):
relpath = os.path.relpath(path, usr_dir)
os.symlink(relpath, usr_exe)
elif 'uninstall' in args:
usr_dir = os.path.join(sys.prefix, '../../usr/bin')
for exe in os.listdir(usr_dir):