From 849a997fd01b173fbc0eda32f9a6bdb8232c6f11 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 1 Feb 2007 20:03:39 +0000 Subject: Fix script language detection problem (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053615 --- setuptools/command/easy_install.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index ce716b0e..c8e0938b 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -373,7 +373,7 @@ Please make the appropriate changes for your system and try again. 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 @@ Please make the appropriate changes for your system and try again. "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 nt_quote_arg(arg): 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 @@ -1549,6 +1543,12 @@ def is_python_script(script_text, filename): + + + + + + -- cgit v1.2.1