Commits

Anonymous committed 753036a

[svn r3225] Make the python version in generated scripts configurable

  • Participants
  • Parent commits f07e326

Comments (0)

Files changed (1)

             "Unexpected parent dir: %r" % lib_parent)
         copyfile(lib_parent, os.path.join(os.path.dirname(lib_parent), 'lib64'))
 
-def create_bootstrap_script(extra_text):
+def create_bootstrap_script(extra_text, python_version=''):
     """
     Creates a bootstrap script, which is like this script but with
     extend_parser, adjust_options, and after_install hooks.
 
         This example immediately installs a package, and runs a setup
         script from that package.
+
+    If you provide something like ``python_version='2.4'`` then the
+    script will start with ``#!/usr/bin/env python2.4`` instead of
+    ``#!/usr/bin/env python``.  You can use this when the script must
+    be run with a particular Python version.
     """
     filename = __file__
     if filename.endswith('.pyc'):
     f = open(filename, 'rb')
     content = f.read()
     f.close()
-    content = (('#!/usr/bin/env %s\n' % os.path.basename(sys.executable))
+    py_exe = 'python%s' % python_version
+    content = (('#!/usr/bin/env %s\n' % py_exe)
                + '## WARNING: This file is generated\n'
                + content)
     return content.replace('##EXT' 'END##', extra_text)