[Python-checkins] r53186 - in sandbox/branches/setuptools-0.6: README.txt setuptools/command/bdist_wininst.py setuptools/command/easy_install.py setuptools/command/install_scripts.py

phillip.eby python-checkins at python.org
Fri Dec 29 02:32:48 CET 2006


Author: phillip.eby
Date: Fri Dec 29 02:32:46 2006
New Revision: 53186

Modified:
   sandbox/branches/setuptools-0.6/README.txt
   sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py
   sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py
   sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py
Log:
Partial support for cross-platform generation of bdist_wininst .exe's.
Unfortunately, bdist_wininst doesn't fix up #! lines, so python.exe or
pythonw.exe have to be on PATH for generated scripts to work.  This
could probably be fixed up with a post-install script, but that's a
job for another day.  (backport from trunk)


Modified: sandbox/branches/setuptools-0.6/README.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/README.txt	(original)
+++ sandbox/branches/setuptools-0.6/README.txt	Fri Dec 29 02:32:46 2006
@@ -23,7 +23,9 @@
 
 Once installation is complete, you will find an ``easy_install.exe`` program in
 your Python ``Scripts`` subdirectory.  Be sure to add this directory to your
-``PATH`` environment variable, if you haven't already done so.
+``PATH`` environment variable, if you haven't already done so.  You must also
+have your Python installation directory (e.g. ``C:\\Python23``) on the
+``PATH``.
 
 
 RPM-Based Systems

Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py	Fri Dec 29 02:32:46 2006
@@ -28,3 +28,10 @@
             cmd.install_lib = None  # work around distutils bug
         return cmd
 
+    def run(self):
+        self._is_running = True
+        try:
+            _bdist_wininst.run(self)
+        finally:
+            self._is_running = False
+

Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py	Fri Dec 29 02:32:46 2006
@@ -1408,7 +1408,7 @@
             return path
 
 
-def get_script_header(script_text, executable=sys_executable):
+def get_script_header(script_text, executable=sys_executable, wininst=False):
     """Create a #! line, getting options (if any) from script_text"""
     from distutils.command.build_scripts import first_line_re
     first = (script_text+'\n').splitlines()[0]
@@ -1418,6 +1418,8 @@
         options = match.group(1) or ''
         if options:
             options = ' '+options
+    if wininst and sys.platform!='win32':
+        executable = "python.exe"
     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
@@ -1431,8 +1433,6 @@
     return hdr
 
 
-
-
 def auto_chmod(func, arg, exc):
     if func is os.remove and os.name=='nt':
         os.chmod(arg, stat.S_IWRITE)
@@ -1515,10 +1515,10 @@
 
 
 
-def get_script_args(dist, executable=sys_executable):
+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())
-    header = get_script_header("", executable)
+    header = get_script_header("", executable, wininst)
     for group in 'console_scripts', 'gui_scripts':
         for name,ep in dist.get_entry_map(group).items():
             script_text = (
@@ -1531,7 +1531,7 @@
                 "   load_entry_point(%(spec)r, %(group)r, %(name)r)()\n"
                 ")\n"
             ) % locals()
-            if sys.platform=='win32':
+            if sys.platform=='win32' or wininst:
                 # On Windows, add a .py extension and an .exe launcher
                 if group=='gui_scripts':
                     ext, launcher = '-script.pyw', 'gui.exe'

Modified: sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py	Fri Dec 29 02:32:46 2006
@@ -29,16 +29,16 @@
         )
         bs_cmd = self.get_finalized_command('build_scripts')
         executable = getattr(bs_cmd,'executable',sys_executable)
-
-        for args in get_script_args(dist, executable):
+        is_wininst = getattr(
+            self.get_finalized_command("bdist_wininst"), '_is_running', False
+        )
+        for args in get_script_args(dist, executable, is_wininst):
             self.write_script(*args)
 
 
 
 
 
-
-
     def write_script(self, script_name, contents, mode="t", *ignored):
         """Write an executable file to the scripts directory"""
         log.info("Installing %s script to %s", script_name, self.install_dir)


More information about the Python-checkins mailing list