Commit 35f114f9 authored by tarek's avatar tarek

adding the --version option into bootstrap.py

git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@99574 62d5b8a3-27da-0310-9561-8e5933582275
parent b2940707
...@@ -5,7 +5,8 @@ Change History ...@@ -5,7 +5,8 @@ Change History
================== ==================
- Better Windows compatibility in test infrastructure. - 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) 1.2.1 (2009-03-18)
================== ==================
......
...@@ -119,6 +119,11 @@ then use to run the tests. ...@@ -119,6 +119,11 @@ then use to run the tests.
This is probably the most common type of buildout. 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>`_ The `zc.buildout project <http://svn.zope.org/zc.buildout/trunk>`_
is a slightly more complex example of this type of buildout. is a slightly more complex example of this type of buildout.
......
...@@ -49,11 +49,18 @@ else: ...@@ -49,11 +49,18 @@ else:
cmd = 'from setuptools.command.easy_install import main; main()' cmd = 'from setuptools.command.easy_install import main; main()'
ws = pkg_resources.working_set 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: if is_jython:
import subprocess import subprocess
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
quote(tmpeggs), 'zc.buildout'], quote(tmpeggs), 'zc.buildout' + VERSION],
env=dict(os.environ, env=dict(os.environ,
PYTHONPATH= PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location ws.find(pkg_resources.Requirement.parse('setuptools')).location
...@@ -63,7 +70,7 @@ if is_jython: ...@@ -63,7 +70,7 @@ if is_jython:
else: else:
assert os.spawnle( assert os.spawnle(
os.P_WAIT, sys.executable, quote (sys.executable), 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, dict(os.environ,
PYTHONPATH= PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location ws.find(pkg_resources.Requirement.parse('setuptools')).location
...@@ -71,7 +78,7 @@ else: ...@@ -71,7 +78,7 @@ else:
) == 0 ) == 0
ws.add_entry(tmpeggs) ws.add_entry(tmpeggs)
ws.require('zc.buildout') ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs) shutil.rmtree(tmpeggs)
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>
...@@ -565,57 +565,6 @@ def create_sections_on_command_line(): ...@@ -565,57 +565,6 @@ def create_sections_on_command_line():
""" """
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(): def test_help():
""" """
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'), >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'),
...@@ -2782,7 +2731,7 @@ normalize_bang = ( ...@@ -2782,7 +2731,7 @@ normalize_bang = (
) )
def test_suite(): def test_suite():
return unittest.TestSuite(( test_suite = [
doctest.DocFileSuite( doctest.DocFileSuite(
'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt', 'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt',
setUp=zc.buildout.testing.buildoutSetUp, setUp=zc.buildout.testing.buildoutSetUp,
...@@ -2913,4 +2862,33 @@ def test_suite(): ...@@ -2913,4 +2862,33 @@ def test_suite():
), ),
]) ])
), ),
)) ]
# 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment