[Checkins] SVN: zc.buildout/trunk/ Bug fixed:

Jim Fulton jim at zope.com
Fri Aug 28 15:46:08 EDT 2009


Log message for revision 103353:
  Bug fixed:
    Scripts run using generated interpreters didn't have __file__ set correctly.
  

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/src/zc/buildout/easy_install.py
  U   zc.buildout/trunk/src/zc/buildout/easy_install.txt

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2009-08-28 19:15:10 UTC (rev 103352)
+++ zc.buildout/trunk/CHANGES.txt	2009-08-28 19:46:07 UTC (rev 103353)
@@ -20,6 +20,8 @@
 - Scripts generated with relative-paths eanbled couldn't be
   symbolocally linked to other locations and still work.
 
+- Scripts run using generated interpreters didn't have __file__ set correctly.
+
 1.4.0 (2009-08-26)
 ==================
 

Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py	2009-08-28 19:15:10 UTC (rev 103352)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py	2009-08-28 19:46:07 UTC (rev 103353)
@@ -16,8 +16,6 @@
 This module provides a high-level Python API for installing packages.
 It doesn't install scripts.  It uses setuptools and requires it to be
 installed.
-
-$Id$
 """
 
 import distutils.errors
@@ -1140,7 +1138,8 @@
 
     if _args:
         sys.argv[:] = _args
-        execfile(sys.argv[0])
+        __file__ = _args[0]
+        execfile(__file__)
 
 if _interactive:
     import code

Modified: zc.buildout/trunk/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.txt	2009-08-28 19:15:10 UTC (rev 103352)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.txt	2009-08-28 19:46:07 UTC (rev 103353)
@@ -683,7 +683,8 @@
     <BLANKLINE>
         if _args:
             sys.argv[:] = _args
-            execfile(sys.argv[0])
+            __file__ = _args[0]
+            execfile(__file__)
     <BLANKLINE>
     if _interactive:
         import code
@@ -691,6 +692,15 @@
 
 If invoked with a script name and arguments, it will run that script, instead.
 
+    >>> write('ascript', '''
+    ... "demo doc"
+    ... print sys.argv
+    ... print (__name__, __file__, __doc__)
+    ... ''')
+    >>> print system(join(bin, 'py')+' ascript a b c'),
+    ['ascript', 'a', 'b', 'c']
+    ('__main__', 'ascript', 'demo doc')
+
 An additional argument can be passed to define which scripts to install
 and to provide script names. The argument is a dictionary mapping
 original script names to new script names.
@@ -874,7 +884,8 @@
     <BLANKLINE>
         if _args:
             sys.argv[:] = _args
-            execfile(sys.argv[0])
+            __file__ = _args[0]
+            execfile(__file__)
     <BLANKLINE>
     if _interactive:
         import code



More information about the checkins mailing list