[Checkins] SVN: zc.buildout/trunk/ Improved the generated "py"
scripts. These let you start Python with
Jim Fulton
jim at zope.com
Mon Jun 26 17:22:34 EDT 2006
Log message for revision 68860:
Improved the generated "py" scripts. These let you start Python with
the path set to include a set of distributions and their
dependeoncies. Now, you can also pass a script and arguments. This
gives me a handy way of invoking setup.py scripts that require
setuptools without having to install setuptools into my system
python. :)
Changed:
U zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/selecting-python.txt
U zc.buildout/trunk/src/zc/buildout/easy_install.py
U zc.buildout/trunk/src/zc/buildout/easy_install.txt
U zc.buildout/trunk/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/selecting-python.txt
===================================================================
--- zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/selecting-python.txt 2006-06-26 21:22:32 UTC (rev 68859)
+++ zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/selecting-python.txt 2006-06-26 21:22:34 UTC (rev 68860)
@@ -88,15 +88,24 @@
eggrecipedemo.main()
>>> f = open(os.path.join(sample_buildout, 'bin', 'py_demo'))
- >>> f.readline().strip() == '#!' + python2_3_executable + ' -i'
+ >>> f.readline().strip() == '#!' + python2_3_executable
True
>>> print f.read(),
+ import sys
<BLANKLINE>
- import sys
+ if len(sys.argv) == 1:
+ import os
+ # Restart with -i
+ os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
+ <BLANKLINE>
sys.path[0:0] = [
- '/tmp/tmpOBTxDMsample-buildout/eggs/demo-0.2-py2.3.egg',
- '/tmp/tmpOBTxDMsample-buildout/eggs/demoneeded-1.1-py2.3.egg'
+ '/tmp/tmpiIJY3Ysample-buildout/eggs/demo-0.2-py2.3.egg',
+ '/tmp/tmpiIJY3Ysample-buildout/eggs/demoneeded-1.1-py2.3.egg'
]
+ <BLANKLINE>
+ if len(sys.argv) > 1 and sys.argv[1:] != ['']:
+ sys.argv[:] = sys.argv[1:]
+ execfile(sys.argv[0])
If we change the Python version to 2.4, we'll use Python 2.4 eggs:
@@ -139,14 +148,21 @@
eggrecipedemo.main()
>>> f = open(os.path.join(sample_buildout, 'bin', 'py_demo'))
- >>> f.readline().strip() == '#!' + python2_4_executable + ' -i'
+ >>> f.readline().strip() == '#!' + python2_4_executable
True
>>> print f.read(),
+ import sys
<BLANKLINE>
- import sys
+ if len(sys.argv) == 1:
+ import os
+ # Restart with -i
+ os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
+ <BLANKLINE>
sys.path[0:0] = [
- '/tmp/tmpOBTxDMsample-buildout/eggs/demo-0.2-py2.4.egg',
- '/tmp/tmpOBTxDMsample-buildout/eggs/demoneeded-1.1-py2.4.egg'
+ '/tmp/tmpiIJY3Ysample-buildout/eggs/demo-0.2-py2.4.egg',
+ '/tmp/tmpiIJY3Ysample-buildout/eggs/demoneeded-1.1-py2.4.egg'
]
-
-
+ <BLANKLINE>
+ if len(sys.argv) > 1 and sys.argv[1:] != ['']:
+ sys.argv[:] = sys.argv[1:]
+ execfile(sys.argv[0])
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py 2006-06-26 21:22:32 UTC (rev 68859)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py 2006-06-26 21:22:34 UTC (rev 68860)
@@ -309,10 +309,19 @@
pass
py_script_template = '''\
-#!%(python)s -i
+#!%(python)s
+import sys
-import sys
+if len(sys.argv) == 1:
+ import os
+ # Restart with -i
+ os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
+
sys.path[0:0] = [
'%(path)s'
]
+
+if len(sys.argv) > 1 and sys.argv[1:] != ['']:
+ sys.argv[:] = sys.argv[1:]
+ execfile(sys.argv[0])
'''
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.txt 2006-06-26 21:22:32 UTC (rev 68859)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.txt 2006-06-26 21:22:34 UTC (rev 68860)
@@ -238,14 +238,25 @@
the path set:
>>> cat(bin, 'py_demo')
- #!/usr/local/bin/python2.3 -i
+ #!/usr/local/bin/python2.4
+ import sys
<BLANKLINE>
- import sys
+ if len(sys.argv) == 1:
+ import os
+ # Restart with -i
+ os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
+ <BLANKLINE>
sys.path[0:0] = [
- '/tmp/xyzsample-install/demo-0.3-py2.3.egg',
- '/tmp/xyzsample-install/demoneeded-1.1-py2.3.egg'
+ '/tmp/tmp5zS2Afsample-install/demo-0.3-py2.4.egg',
+ '/tmp/tmp5zS2Afsample-install/demoneeded-1.1-py2.4.egg'
]
+ <BLANKLINE>
+ if len(sys.argv) > 1 and sys.argv[1:] != ['']:
+ sys.argv[:] = sys.argv[1:]
+ execfile(sys.argv[0])
+If invoked with a script name and arguments, it will run that script, instead.
+
An additional argumnet can be passed to define which scripts to install
and to provie script names. The argument is a dictionary mapping
original script names to new script names.
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2006-06-26 21:22:32 UTC (rev 68859)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2006-06-26 21:22:34 UTC (rev 68860)
@@ -150,6 +150,7 @@
(re.compile('\S+sample-(\w+)'), r'/sample-\1'),
(re.compile('executable = \S+python\S*'),
'executable = python'),
+ (re.compile('setuptools-\S+[.]egg'), 'setuptools.egg'),
])
),
More information about the Checkins
mailing list