[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command develop.py, 1.6, 1.7 easy_install.py, 1.30, 1.31

pje@users.sourceforge.net pje at users.sourceforge.net
Sat Sep 24 22:30:00 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30448/setuptools/command

Modified Files:
	develop.py easy_install.py 
Log Message:
Support generating .pyw/.exe wrappers for Windows GUI scripts, and 
"normal" #! wrappers for GUI scripts on other platforms.


Index: develop.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/develop.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- develop.py	17 Sep 2005 01:13:02 -0000	1.6
+++ develop.py	24 Sep 2005 20:29:57 -0000	1.7
@@ -103,7 +103,7 @@
         # create wrapper scripts in the script dir, pointing to dist.scripts
 
         # new-style...
-        self.install_console_scripts(dist)  
+        self.install_wrapper_scripts(dist)  
 
         # ...and old-style
         for script_name in self.distribution.scripts or []:

Index: easy_install.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/easy_install.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- easy_install.py	24 Sep 2005 17:58:22 -0000	1.30
+++ easy_install.py	24 Sep 2005 20:29:57 -0000	1.31
@@ -10,7 +10,7 @@
 __ http://peak.telecommunity.com/DevCenter/EasyInstall
 """
 
-import sys, os.path, zipimport, shutil, tempfile, zipfile
+import sys, os.path, zipimport, shutil, tempfile, zipfile, re
 from glob import glob
 from setuptools import Command
 from setuptools.sandbox import run_setup
@@ -247,7 +247,7 @@
     def install_egg_scripts(self, dist):
         """Write all the scripts for `dist`, unless scripts are excluded"""
 
-        self.install_console_scripts(dist)
+        self.install_wrapper_scripts(dist)
         if self.exclude_scripts or not dist.metadata_isdir('scripts'):
             return
 
@@ -440,52 +440,52 @@
         return dst
 
 
+    def install_wrapper_scripts(self, dist):
+        if self.exclude_scripts:
+            return
+        for group in 'console_scripts', 'gui_scripts':
+            for name,ep in dist.get_entry_map(group).items():
+                self._install_wrapper_script(dist, group, name, ep)
 
 
 
-
-
-
-
-
-
-    def install_console_scripts(self, dist):
+    def _install_wrapper_script(self, dist, group, name, entry_point):
         """Write new-style console scripts, unless excluded"""
-        
-        if self.exclude_scripts:
-            return
 
         spec = str(dist.as_requirement())
-        group = 'console_scripts'
-
-        for name,ep in dist.get_entry_map(group).items():
-
-            script_text = get_script_header("") + (
-                "# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r\n"
-                "__requires__ = %(spec)r\n"
-                "import sys\n"
-                "from pkg_resources import load_entry_point\n"
-                "\n"
-                "sys.exit(\n"
-                "   load_entry_point(%(spec)r, %(group)r, %(name)r)()\n"
-                ")\n"
-            ) % locals()
+        header = get_script_header("")
+        script_text = (
+            "# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r\n"
+            "__requires__ = %(spec)r\n"
+            "import sys\n"
+            "from pkg_resources import load_entry_point\n"
+            "\n"
+            "sys.exit(\n"
+            "   load_entry_point(%(spec)r, %(group)r, %(name)r)()\n"
+            ")\n"
+        ) % locals()
 
-            if sys.platform=='win32':
-                # On Windows, add a .py extension and an .exe launcher
-                self.write_script(name+'.py', script_text)
-                self.write_script(
-                    name+'.exe', resource_string('setuptools','launcher.exe'),
-                    'b' # write in binary mode
-                )
+        if sys.platform=='win32':
+            # On Windows, add a .py extension and an .exe launcher
+            if group=='gui_scripts':
+                ext, launcher = '.pyw', 'gui.exe'
+                new_header = re.sub('(?i)python.exe','pythonw.exe',header)
             else:
-                # On other platforms, we assume the right thing to do is to
-                # write the stub with no extension.
-                self.write_script(name, script_text)
-
-
+                ext, launcher = '.py',  'cli.exe'
+                new_header = re.sub('(?i)pythonw.exe','pythonw.exe',header)
 
+            if os.path.exists(new_header[2:-1]):
+                header = new_header
 
+            self.write_script(name+ext, header+script_text)
+            self.write_script(
+                name+'.exe', resource_string('setuptools', launcher),
+                'b' # write in binary mode
+            )
+        else:
+            # On other platforms, we assume the right thing to do is to just
+            # write the stub with no extension.
+            self.write_script(name, header+script_text)
 
 
 
@@ -495,7 +495,7 @@
         spec = str(dist.as_requirement())
 
         if dev_path:
-            script_text = get_script_header(script_text) + (                
+            script_text = get_script_header(script_text) + (
                 "# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r\n"
                 "__requires__ = %(spec)r\n"
                 "from pkg_resources import require; require(%(spec)r)\n"
@@ -504,7 +504,7 @@
                 "execfile(__file__)\n"
             ) % locals()
         else:
-            script_text = get_script_header(script_text) + (                
+            script_text = get_script_header(script_text) + (
                 "# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n"
                 "__requires__ = %(spec)r\n"
                 "import pkg_resources\n"



More information about the Python-checkins mailing list