-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
--relocatable fails on Windows #49
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
Comments
Same problem here. In functions related to the env relocation
|
Here is a patch that fix the WindowsError(s). But there's still some messages
a normal script that starts with
relative (it's not a normal script that starts with
(it's not a normal script that starts with
relative (it's not a normal script that starts with
(it's not a normal script that starts with
not a normal script that starts with
(it's not a normal script that starts with
normal script that starts with
normal script that starts with
not a normal script that starts with
normal script that starts with
normal script that starts with It seems related to path case sensitivity and forward/backward slashes, but
|
|
I was having numerous issues with this under Python 2.7 (32-bit).
def fixup_scripts(home_dir):
if sys.platform == 'win32':
bin_suffix = 'Scripts'
# This is what we'll put:
new_shebang = '#!%s /c python' % os.path.normcase(os.environ['COMSPEC'])
else:
bin_suffix = 'bin'
# This is what we'll put:
new_shebang = '#!/usr/bin/env python%s' % sys.version[:3]
# This is what we expect at the top of scripts:
shebang = '#!%s' % os.path.normcase(os.path.abspath(os.path.join(home_dir, bin_suffix, 'python')))
activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); execfile(activate_this, dict(__file__=activate_this)); del os, activate_this"
bin_dir = os.path.join(home_dir, bin_suffix)
home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir)
for filename in os.listdir(bin_dir):
filename = os.path.join(bin_dir, filename)
if not os.path.isfile(filename):
# ignore subdirs, e.g. .svn ones.
continue
f = open(filename, 'rb')
try:
try:
lines = f.read().decode('utf-8').splitlines()
except UnicodeDecodeError:
# This is probably a binary program instead
# of a script, so just ignore it.
continue
finally:
f.close()
if not lines:
logger.warn('Script %s is an empty file' % filename)
continue
old_shebang = lines[0].strip()
old_shebang = old_shebang[0:2] + os.path.normcase(old_shebang[2:])
if not old_shebang.startswith(shebang):
if os.path.basename(filename) in OK_ABS_SCRIPTS:
logger.debug('Cannot make script %s relative' % filename)
elif lines[0].strip() == new_shebang:
logger.info('Script %s has already been made relative' % filename)
else:
logger.warn('Script %s cannot be made relative (it\'s not a normal script that starts with %s)'
% (filename, shebang))
continue
logger.notify('Making script %s relative' % filename)
lines = [new_shebang+'\n', activate+'\n'] + lines[1:]
f = open(filename, 'wb')
f.write(os.linesep.join(lines).encode('utf-8'))
f.close() |
Why was it closed? |
What's the PR for the fix? |
Since this never seemed of interest I never filed one. I'll update to the latest code and get one together. |
@jpenney thanks |
I didn't forget about this, but it did not merge cleanly with the latest, so I need to rework it and retest it. |
Do you still feel like getting this patch ready? :) |
I apologize! This slipped my mind completely over the holidays. I'll take a look at it later today. |
Fixed with pull request #401 |
The text was updated successfully, but these errors were encountered: