[Checkins] SVN: zc.buildout/trunk/ adding the --version option into bootstrap.py
Tarek Ziade
ziade.tarek at gmail.com
Wed Apr 29 09:37:44 EDT 2009
Log message for revision 99574:
adding the --version option into bootstrap.py
Changed:
U zc.buildout/trunk/CHANGES.txt
U zc.buildout/trunk/README.txt
U zc.buildout/trunk/bootstrap/bootstrap.py
A zc.buildout/trunk/src/zc/buildout/bootstrap.txt
U zc.buildout/trunk/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt 2009-04-29 12:59:53 UTC (rev 99573)
+++ zc.buildout/trunk/CHANGES.txt 2009-04-29 13:37:44 UTC (rev 99574)
@@ -5,8 +5,9 @@
==================
- Better Windows compatibility in test infrastructure.
+- Now the bootstrap.py has an optional --version argument,
+ that can be used to force zc.buildout version to use.
-
1.2.1 (2009-03-18)
==================
Modified: zc.buildout/trunk/README.txt
===================================================================
--- zc.buildout/trunk/README.txt 2009-04-29 12:59:53 UTC (rev 99573)
+++ zc.buildout/trunk/README.txt 2009-04-29 13:37:44 UTC (rev 99574)
@@ -119,6 +119,11 @@
This is probably the most common type of buildout.
+If I need to run a previous version of zc.buildout, I use the
+`--version` option of the buildout.py script::
+
+ $ python bootstrap.py --version 1.1.3
+
The `zc.buildout project <http://svn.zope.org/zc.buildout/trunk>`_
is a slightly more complex example of this type of buildout.
Modified: zc.buildout/trunk/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/trunk/bootstrap/bootstrap.py 2009-04-29 12:59:53 UTC (rev 99573)
+++ zc.buildout/trunk/bootstrap/bootstrap.py 2009-04-29 13:37:44 UTC (rev 99574)
@@ -49,11 +49,18 @@
cmd = 'from setuptools.command.easy_install import main; main()'
ws = pkg_resources.working_set
+if len(sys.argv) > 2 and sys.argv[1] == '--version':
+ VERSION = ' == %s' % sys.argv[2]
+ args = sys.argv[3:] + ['bootstrap']
+else:
+ VERSION = ''
+ args = sys.argv[1:] + ['bootstrap']
+
if is_jython:
import subprocess
-
- assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
- quote(tmpeggs), 'zc.buildout'],
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout' + VERSION],
env=dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location
@@ -63,7 +70,7 @@
else:
assert os.spawnle(
os.P_WAIT, sys.executable, quote (sys.executable),
- '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+ '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location
@@ -71,7 +78,7 @@
) == 0
ws.add_entry(tmpeggs)
-ws.require('zc.buildout')
+ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
-zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
Added: zc.buildout/trunk/src/zc/buildout/bootstrap.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/bootstrap.txt (rev 0)
+++ zc.buildout/trunk/src/zc/buildout/bootstrap.txt 2009-04-29 13:37:44 UTC (rev 99574)
@@ -0,0 +1,126 @@
+Make sure the bootstrap script actually works::
+
+ >>> import os, sys
+ >>> from os.path import dirname, join
+ >>> import zc.buildout
+ >>> bootstrap_py = join(
+ ... dirname(
+ ... dirname(
+ ... dirname(
+ ... dirname(zc.buildout.__file__)
+ ... )
+ ... )
+ ... ),
+ ... 'bootstrap', 'bootstrap.py')
+ >>> sample_buildout = tmpdir('sample')
+ >>> os.chdir(sample_buildout)
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... parts =
+ ... ''')
+ >>> write('bootstrap.py', open(bootstrap_py).read())
+ >>> print 'X'; print system(
+ ... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
+ ... 'bootstrap.py'); print 'X' # doctest: +ELLIPSIS
+ X...
+ Creating directory '/sample/bin'.
+ Creating directory '/sample/parts'.
+ Creating directory '/sample/eggs'.
+ Creating directory '/sample/develop-eggs'.
+ Generated script '/sample/bin/buildout'.
+ ...
+
+ >>> ls(sample_buildout)
+ d bin
+ - bootstrap.py
+ - buildout.cfg
+ d develop-eggs
+ d eggs
+ d parts
+
+
+ >>> ls(sample_buildout, 'bin')
+ - buildout
+
+ >>> print 'X'; ls(sample_buildout, 'eggs') # doctest: +ELLIPSIS
+ X...
+ d zc.buildout-...egg
+
+Now trying the `--version` option, that let you define a version for
+`zc.buildout`. If not provided, bootstrap will look for the latest one.
+
+Let's try with an unknown version::
+
+ >>> print 'X'; print system(
+ ... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
+ ... 'bootstrap.py --version UNKNOWN'); print 'X' # doctest: +ELLIPSIS
+ ...
+ X
+ No local packages or download links found for zc.buildout==UNKNOWN
+ error: Could not find suitable distribution for Requirement.parse('zc.buildout==UNKNOWN')
+ Traceback (most recent call last):
+ File "bootstrap.py", line 78, in <module>
+ ) == 0
+ AssertionError
+ <BLANKLINE>
+ X
+
+Now let's try with `1.1.1`, which happens to exist::
+
+ >>> print 'X'; print system(
+ ... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
+ ... 'bootstrap.py --version 1.1.1'); print 'X'
+ ...
+ X
+ Generated script '/sample/bin/buildout'.
+ <BLANKLINE>
+ X
+
+Let's make sure the generated `buildout` script uses it::
+
+ >>> buildout_script = join(sample_buildout, 'bin', 'buildout')
+ >>> print open(buildout_script).read() # doctest: +ELLIPSIS
+ #...
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample/eggs/setuptools-...egg',
+ '/sample/eggs/zc.buildout-1.1.1...egg',
+ ]
+ <BLANKLINE>
+ import zc.buildout.buildout
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zc.buildout.buildout.main()
+ <BLANKLINE>
+
+Let's try with `1.2.1`::
+
+ >>> print 'X'; print system(
+ ... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
+ ... 'bootstrap.py --version 1.2.1'); print 'X' # doctest: +ELLIPSIS
+ ...
+ X
+ Generated script '/sample/bin/buildout'.
+ <BLANKLINE>
+ X
+
+Let's make sure the generated `buildout` script uses it::
+
+ >>> print open(buildout_script).read() # doctest: +ELLIPSIS
+ #...
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample/eggs/setuptools-...egg',
+ '/sample/eggs/zc.buildout-1.2.1...egg',
+ ]
+ <BLANKLINE>
+ import zc.buildout.buildout
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zc.buildout.buildout.main()
+ <BLANKLINE>
+
+
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2009-04-29 12:59:53 UTC (rev 99573)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2009-04-29 13:37:44 UTC (rev 99574)
@@ -565,57 +565,6 @@
"""
-bootstrap_py = os.path.join(
- os.path.dirname(
- os.path.dirname(
- os.path.dirname(
- os.path.dirname(zc.buildout.__file__)
- )
- )
- ),
- 'bootstrap', 'bootstrap.py')
-
-if os.path.exists(bootstrap_py):
- def test_bootstrap_py():
- """Make sure the bootstrap script actually works
-
- >>> sample_buildout = tmpdir('sample')
- >>> os.chdir(sample_buildout)
- >>> write('buildout.cfg',
- ... '''
- ... [buildout]
- ... parts =
- ... ''')
- >>> write('bootstrap.py', open(bootstrap_py).read())
- >>> print 'X'; print system(
- ... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
- ... 'bootstrap.py'); print 'X' # doctest: +ELLIPSIS
- X...
- Creating directory '/sample/bin'.
- Creating directory '/sample/parts'.
- Creating directory '/sample/eggs'.
- Creating directory '/sample/develop-eggs'.
- Generated script '/sample/bin/buildout'.
- ...
-
- >>> ls(sample_buildout)
- d bin
- - bootstrap.py
- - buildout.cfg
- d develop-eggs
- d eggs
- d parts
-
-
- >>> ls(sample_buildout, 'bin')
- - buildout
-
- >>> print 'X'; ls(sample_buildout, 'eggs') # doctest: +ELLIPSIS
- X...
- d zc.buildout-1.0-py2.4.egg
-
- """
-
def test_help():
"""
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'),
@@ -2782,7 +2731,7 @@
)
def test_suite():
- return unittest.TestSuite((
+ test_suite = [
doctest.DocFileSuite(
'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt',
setUp=zc.buildout.testing.buildoutSetUp,
@@ -2913,4 +2862,33 @@
),
])
),
- ))
+ ]
+
+ # adding bootstrap.txt doctest to the suite
+ # only if bootstrap.py is present
+ bootstrap_py = os.path.join(
+ os.path.dirname(
+ os.path.dirname(
+ os.path.dirname(
+ os.path.dirname(zc.buildout.__file__)
+ )
+ )
+ ),
+ 'bootstrap', 'bootstrap.py')
+
+ if os.path.exists(bootstrap_py):
+ test_suite.append(doctest.DocFileSuite(
+ 'bootstrap.txt',
+ setUp=easy_install_SetUp,
+ tearDown=zc.buildout.testing.buildoutTearDown,
+ checker=renormalizing.RENormalizing([
+ zc.buildout.testing.normalize_path,
+ zc.buildout.testing.normalize_script,
+ normalize_bang,
+ ]),
+ ))
+
+ return unittest.TestSuite(test_suite)
+
+
+
More information about the Checkins
mailing list