[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command easy_install.py, 1.32, 1.33

pje@users.sourceforge.net pje at users.sourceforge.net
Sun Oct 16 22:45:34 CEST 2005


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

Modified Files:
	easy_install.py 
Log Message:
Fix problem with Windows console scripts conflicting with module names,
thereby confusing the import process.  Scripts are now generated with a
suffix of the form '-script.py' to avoid conflicts.  (The .exe's are still
generated without the '-script' part, so you don't have to type it.)
Thanks to Matthew R. Scott for reporting the problem.


Index: easy_install.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/easy_install.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- easy_install.py	16 Oct 2005 17:42:11 -0000	1.32
+++ easy_install.py	16 Oct 2005 20:45:30 -0000	1.33
@@ -102,13 +102,13 @@
 
     def delete_blockers(self, blockers):
         for filename in blockers:
-            log.info("Deleting %s", filename)
-            if not self.dry_run:
-                if os.path.isdir(filename) and not os.path.islink(filename):
-                    shutil.rmtree(filename)
-                else:
-                    os.unlink(filename)
-
+            if os.path.exists(filename) or os.path.islink(filename):
+                log.info("Deleting %s", filename)
+                if not self.dry_run:
+                    if os.path.isdir(filename) and not os.path.islink(filename):
+                        shutil.rmtree(filename)
+                    else:
+                        os.unlink(filename)
 
 
 
@@ -464,18 +464,21 @@
             "   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
             if group=='gui_scripts':
-                ext, launcher = '.pyw', 'gui.exe'
+                ext, launcher = '-script.pyw', 'gui.exe'
+                old = ['.pyw']
                 new_header = re.sub('(?i)python.exe','pythonw.exe',header)
             else:
-                ext, launcher = '.py',  'cli.exe'
+                ext, launcher = '-script.py', 'cli.exe'
+                old = ['.py','.pyc','.pyo']
                 new_header = re.sub('(?i)pythonw.exe','pythonw.exe',header)
-
             if os.path.exists(new_header[2:-1]):
                 header = new_header
+            
+            self.delete_blockers(   # clean up old .py/.pyw w/o a script
+                [os.path.join(self.script_dir,name+x) for x in old])
 
             self.write_script(name+ext, header+script_text)
             self.write_script(
@@ -487,9 +490,6 @@
             # write the stub with no extension.
             self.write_script(name, header+script_text)
 
-
-
-
     def install_script(self, dist, script_name, script_text, dev_path=None):
         """Generate a legacy script wrapper and install it"""
         spec = str(dist.as_requirement())



More information about the Python-checkins mailing list