diff options
author | phillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771> | 2007-02-01 19:59:49 +0000 |
---|---|---|
committer | phillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771> | 2007-02-01 19:59:49 +0000 |
commit | c46263cefdb444ff4a72d956b99d5bfa601bedfe (patch) | |
tree | 904c2fdd8634b1dc9877d59eef1f8b7aa879f67c /setuptools/command | |
parent | 7dd4ee57de49712f35027fc4e078cc87a1c6c824 (diff) | |
download | python-setuptools-c46263cefdb444ff4a72d956b99d5bfa601bedfe.tar.gz |
Fix script language detection so that scripts built on Windows are
correctly identified as still being Python code!
git-svn-id: http://svn.python.org/projects/sandbox/trunk/setuptools@53614 6015fed2-1504-0410-9fe1-9d1591cc4771
Diffstat (limited to 'setuptools/command')
-rwxr-xr-x | setuptools/command/easy_install.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 901df98..4609810 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 @@ -1556,6 +1550,12 @@ def is_python_script(script_text, filename): + + + + + + 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()) |