Commit 6a70b03d authored by jim's avatar jim

- Added a new init command for creating a new buildout. This creates

  an empty configuration file and then bootstraps.

- Except when using the new init command, it is now an error to run
  buildout without a configuration file.

- 75607: buildout should not run if it creates an empty buildout.cfg


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@75710 62d5b8a3-27da-0310-9561-8e5933582275
parent 391b4013
......@@ -20,6 +20,12 @@ Feature Changes
- buildout changes to the buildout directory before running recipe
install and update methods.
- Added a new init command for creating a new buildout. This creates
an empty configuration file and then bootstraps.
- Except when using the new init command, it is now an error to run
buildout without a configuration file.
Bugs Fixed
----------
......@@ -30,6 +36,8 @@ Bugs Fixed
setuptools requires that file urls that point to directories must
end in a "/". Added a workaround.
- 75607: buildout should not run if it creates an empty buildout.cfg
1.0.0b24 (2007-05-09)
=====================
......
......@@ -67,7 +67,7 @@ _buildout_default_options = {
class Buildout(UserDict.DictMixin):
def __init__(self, config_file, cloptions,
user_defaults=True, windows_restart=False):
user_defaults=True, windows_restart=False, command=None):
__doing__ = 'Initializing'
......@@ -80,8 +80,14 @@ class Buildout(UserDict.DictMixin):
config_file = os.path.abspath(config_file)
base = os.path.dirname(config_file)
if not os.path.exists(config_file):
print 'Warning: creating', config_file
if command == 'init':
print 'Creating', config_file
open(config_file, 'w').write('[buildout]\nparts = \n')
else:
raise zc.buildout.UserError(
"Couldn't open %s" % config_file)
if config_file:
data['buildout']['directory'] = os.path.dirname(config_file)
else:
base = None
......@@ -95,6 +101,7 @@ class Buildout(UserDict.DictMixin):
[]))
# load configuration files
if config_file:
_update(data, _open(os.path.dirname(config_file), config_file, []))
# apply command-line options
......@@ -209,6 +216,8 @@ class Buildout(UserDict.DictMixin):
['zc.buildout'], ws, sys.executable,
self['buildout']['bin-directory'])
init = bootstrap
def install(self, install_args):
__doing__ = 'Installing'
......@@ -1211,12 +1220,34 @@ Commands:
definition from the configuration file is used. Otherwise, the
arguments specify the parts to be installed.
Note that the semantics differ depending on whether any parts are
specified. If parts are specified, then only those parts will be
installed. If no parts are specified, then the parts specified by
the buildout parts option will be installed along with all of
their dependencies.
bootstrap
Create a new buildout in the current working directory, copying
the buildout and setuptools eggs and, creating a basic directory
structure and a buildout-local buildout script.
init
Initialize a buildout, creating a buildout.cfg file if it doesn't
exist and then performing the same actions as for the buildout
command.
setup script [setup command and options]
Run a given setup script arranging that setuptools is in the
script's path and and that it has been imported so that
setuptools-provided commands (like bdist_egg) can be used even if
the setup script doesn't import setuptools itself.
The script can be given either as a script path or a path to a
directory containing a setup.py script.
"""
def _help():
print _usage
......@@ -1288,7 +1319,9 @@ def main(args=None):
if args:
command = args.pop(0)
if command not in ('install', 'bootstrap', 'runsetup', 'setup'):
if command not in (
'install', 'bootstrap', 'runsetup', 'setup', 'init',
):
_error('invalid command:', command)
else:
command = 'install'
......@@ -1296,7 +1329,7 @@ def main(args=None):
try:
try:
buildout = Buildout(config_file, options,
user_defaults, windows_restart)
user_defaults, windows_restart, command)
getattr(buildout, command)(args)
except SystemExit:
pass
......
......@@ -1968,8 +1968,8 @@ verbosity
command-line options.
Bootstrapping
-------------
Creating new buildouts and bootstrapping
----------------------------------------
If zc.buildout is installed, you can use it to create a new buildout
with it's own local copies of zc.buildout and setuptools and with
......@@ -1979,8 +1979,8 @@ local buildout scripts.
>>> print system(buildout
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
... +' bootstrap'),
Warning: creating /sample-bootstrapped/setup.cfg
... +' init'),
Creating /sample-bootstrapped/setup.cfg
buildout: Creating directory /sample-bootstrapped/bin
buildout: Creating directory /sample-bootstrapped/parts
buildout: Creating directory /sample-bootstrapped/eggs
......@@ -2012,6 +2012,36 @@ buildout or setuptools.)
Note that the buildout script was installed but not run. To run
the buildout, we'd have to run the installed buildout script.
If we have an existing buildout that already has a buildout.cfg, we'll
normally use the bootstrap command instead of init. It will complain
if there isn't a configuration file:
>>> sample_bootstrapped2 = tmpdir('sample-bootstrapped2')
>>> print system(buildout
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' bootstrap'),
While:
Initializing
Error: Couldn't open /sample-bootstrapped2/setup.cfg
>>> write(sample_bootstrapped2, 'setup.cfg',
... """
... [buildout]
... parts =
... """)
>>> print system(buildout
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' bootstrap'),
buildout: Creating directory /sample-bootstrapped2/bin
buildout: Creating directory /sample-bootstrapped2/parts
buildout: Creating directory /sample-bootstrapped2/eggs
buildout: Creating directory /sample-bootstrapped2/develop-eggs
zc.buildout.easy_install: Generated script /sample-bootstrapped2/bin/buildout.
Newest and Offline Modes
------------------------
......
......@@ -606,170 +606,24 @@ if os.path.exists(bootstrap_py):
def test_help():
"""
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'),
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
Options:
<BLANKLINE>
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'),
... # doctest: +ELLIPSIS
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
Options:
<BLANKLINE>
-h, --help
<BLANKLINE>
Print this message and exit.
<BLANKLINE>
-v
<BLANKLINE>
Increase the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-q
<BLANKLINE>
Decrease the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-c config_file
<BLANKLINE>
Specify the path to the buildout configuration file to be used.
This defaults to the file named "buildout.cfg" in the current
working directory.
<BLANKLINE>
-U
<BLANKLINE>
Don't read user defaults.
<BLANKLINE>
-o
<BLANKLINE>
Run in off-line mode. This is equivalent to the assignment
buildout:offline=true.
<BLANKLINE>
-O
<BLANKLINE>
Run in non-off-line mode. This is equivalent to the assignment
buildout:offline=false. This is the default buildout mode. The
-O option would normally be used to override a true offline
setting in a configuration file.
<BLANKLINE>
-n
<BLANKLINE>
Run in newest mode. This is equivalent to the assignment
buildout:newest=true. With this setting, which is the default,
buildout will try to find the newest versions of distributions
available that satisfy its requirements.
<BLANKLINE>
-N
<BLANKLINE>
Run in non-newest mode. This is equivalent to the assignment
buildout:newest=false. With this setting, buildout will not seek
new distributions if installed distributions satisfy it's
requirements.
<BLANKLINE>
-D
<BLANKLINE>
Debug errors. If an error occurs, then the post-mortem debugger
will be started. This is especially useful for debuging recipe
problems.
<BLANKLINE>
Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
use buildout:offline=true.
<BLANKLINE>
Options and assignments can be interspersed.
<BLANKLINE>
Commands:
<BLANKLINE>
install [parts]
<BLANKLINE>
Install parts. If no command arguments are given, then the parts
definition from the configuration file is used. Otherwise, the
arguments specify the parts to be installed.
<BLANKLINE>
bootstrap
<BLANKLINE>
Create a new buildout in the current working directory, copying
the buildout and setuptools eggs and, creating a basic directory
structure and a buildout-local buildout script.
<BLANKLINE>
<BLANKLINE>
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')
... +' --help'),
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
Options:
<BLANKLINE>
...
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')
... +' --help'),
... # doctest: +ELLIPSIS
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
Options:
<BLANKLINE>
-h, --help
<BLANKLINE>
Print this message and exit.
<BLANKLINE>
-v
<BLANKLINE>
Increase the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-q
<BLANKLINE>
Decrease the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-c config_file
<BLANKLINE>
Specify the path to the buildout configuration file to be used.
This defaults to the file named "buildout.cfg" in the current
working directory.
<BLANKLINE>
-U
<BLANKLINE>
Don't read user defaults.
<BLANKLINE>
-o
<BLANKLINE>
Run in off-line mode. This is equivalent to the assignment
buildout:offline=true.
<BLANKLINE>
-O
<BLANKLINE>
Run in non-off-line mode. This is equivalent to the assignment
buildout:offline=false. This is the default buildout mode. The
-O option would normally be used to override a true offline
setting in a configuration file.
<BLANKLINE>
-n
<BLANKLINE>
Run in newest mode. This is equivalent to the assignment
buildout:newest=true. With this setting, which is the default,
buildout will try to find the newest versions of distributions
available that satisfy its requirements.
<BLANKLINE>
-N
<BLANKLINE>
Run in non-newest mode. This is equivalent to the assignment
buildout:newest=false. With this setting, buildout will not seek
new distributions if installed distributions satisfy it's
requirements.
<BLANKLINE>
-D
<BLANKLINE>
Debug errors. If an error occurs, then the post-mortem debugger
will be started. This is especially useful for debuging recipe
problems.
<BLANKLINE>
Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
use buildout:offline=true.
<BLANKLINE>
Options and assignments can be interspersed.
<BLANKLINE>
Commands:
<BLANKLINE>
install [parts]
<BLANKLINE>
Install parts. If no command arguments are given, then the parts
definition from the configuration file is used. Otherwise, the
arguments specify the parts to be installed.
<BLANKLINE>
bootstrap
<BLANKLINE>
Create a new buildout in the current working directory, copying
the buildout and setuptools eggs and, creating a basic directory
structure and a buildout-local buildout script.
<BLANKLINE>
<BLANKLINE>
...
"""
def test_bootstrap_with_extension():
......@@ -2059,6 +1913,18 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
- demo-0.2-py2.4.egg
- demoneeded-1.1-py2.4.egg
"""
def bug_75607_buildout_should_not_run_if_it_creates_an_empty_buildout_cfg():
"""
>>> remove('buildout.cfg')
>>> print system(buildout),
While:
Initializing
Error: Couldn't open /sample-buildout/buildout.cfg
"""
######################################################################
......
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