[Python-checkins] r53614 - sandbox/trunk/setuptools/setuptools/command/easy_install.py
phillip.eby
python-checkins at python.org
Thu Feb 1 20:59:49 CET 2007
Author: phillip.eby
Date: Thu Feb 1 20:59:49 2007
New Revision: 53614
Modified:
sandbox/trunk/setuptools/setuptools/command/easy_install.py
Log:
Fix script language detection so that scripts built on Windows are
correctly identified as still being Python code!
Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original)
+++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Thu Feb 1 20:59:49 2007
@@ -373,7 +373,7 @@
for script_name in dist.metadata_listdir('scripts'):
self.install_script(
dist, script_name,
- '\n'.join(dist.get_metadata('scripts/'+script_name).splitlines())
+ dist.get_metadata('scripts/'+script_name)
)
self.install_wrapper_scripts(dist)
@@ -593,7 +593,7 @@
"import pkg_resources\n"
"pkg_resources.run_script(%(spec)r, %(script_name)r)\n"
) % locals()
- self.write_script(script_name, script_text)
+ self.write_script(script_name, script_text, 'b')
def write_script(self, script_name, contents, mode="t", blockers=()):
"""Write an executable file to the scripts directory"""
@@ -1518,22 +1518,16 @@
def is_python_script(script_text, filename):
"""Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
"""
- if script_text.startswith('#!'):
- # It begins with a '#!' line, so check if 'python' is in it somewhere
- from distutils.command.build_scripts import first_line_re
- lines = script_text.splitlines()
-
- if first_line_re.match(lines[0]):
- return True # It's got a python "#!" line, consider it Python
- else:
- return False # It's some other scripting language
-
if filename.endswith('.py') or filename.endswith('.pyw'):
return True # extension says it's Python
if is_python(script_text, filename):
return True # it's syntactically valid Python
+ if script_text.startswith('#!'):
+ # It begins with a '#!' line, so check if 'python' is in it somewhere
+ return 'python' in script_text.splitlines()[0].lower()
+
return False # Not any Python I can recognize
@@ -1556,6 +1550,12 @@
+
+
+
+
+
+
def get_script_args(dist, executable=sys_executable, wininst=False):
"""Yield write_script() argument tuples for a distribution's entrypoints"""
spec = str(dist.as_requirement())
More information about the Python-checkins
mailing list