Commits

Anonymous committed e0997a3

Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable``
contains non-ASCII characters, to prevent deprecation warnings about an
unspecified encoding when the script is run.
(backport from trunk)

  • Participants
  • Parent commits b07b05f
  • Branches setuptools-0.6

Comments (0)

Files changed (3)

File EasyInstall.txt

  * A writable installation directory on ``sys.path`` is no longer required to
    download and extract a source distribution using ``--editable``.
 
+ * Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable``
+   contains non-ASCII characters, to prevent deprecation warnings about an
+   unspecified encoding when the script is run.
+
 0.6c1
  * EasyInstall now includes setuptools version information in the
    ``User-Agent`` string sent to websites it visits.

File setuptools/command/develop.py

 from pkg_resources import Distribution, PathMetadata, normalize_path
 from distutils import log
 from distutils.errors import *
-import sys, os
+import sys, os, setuptools
 
 class develop(easy_install):
     """Set up package for development"""

File setuptools/command/easy_install.py

         options = match.group(1) or ''
         if options:
             options = ' '+options
-    return "#!%(executable)s%(options)s\n" % locals()
+    hdr = "#!%(executable)s%(options)s\n" % locals()
+    if unicode(hdr,'ascii','ignore').encode('ascii') != hdr:
+        # Non-ascii path to sys.executable, use -x to prevent warnings
+        if options:
+            if options.strip().startswith('-'):
+                options = ' -x'+options.strip()[1:]
+            # else: punt, we can't do it, let the warning happen anyway
+        else:
+            options = ' -x'
+        hdr = "#!%(executable)s%(options)s\n" % locals()
+    return hdr
 
 def auto_chmod(func, arg, exc):
     if func is os.remove and os.name=='nt':
     else:
         return True
 
-
 def is_python_script(script_text, filename):
     """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
     """
     return False    # Not any Python I can recognize
 
 
-
-
-
-
-
-
-
-
-
 def get_script_args(dist, executable=sys_executable):
     """Yield write_script() argument tuples for a distribution's entrypoints"""
     spec = str(dist.as_requirement())