[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/buildout. Added a
bootstrapping command.
Jim Fulton
jim at zope.com
Mon Jun 26 17:22:30 EDT 2006
Log message for revision 68858:
Added a bootstrapping command.
Reformated the tests to simplify the examples of calling the buildout
script.
Changed:
U zc.buildout/trunk/src/zc/buildout/buildout.py
U zc.buildout/trunk/src/zc/buildout/buildout.txt
-=-
Modified: zc.buildout/trunk/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.py 2006-06-26 21:16:14 UTC (rev 68857)
+++ zc.buildout/trunk/src/zc/buildout/buildout.py 2006-06-26 21:22:29 UTC (rev 68858)
@@ -94,6 +94,7 @@
if options is None:
options = self[section] = {}
options[option] = value
+ # The egg dire
# do substitutions
converted = {}
@@ -163,6 +164,35 @@
def _buildout_path(self, *names):
return os.path.join(self._buildout_dir, *names)
+ def bootstrap(self, args):
+ # Set up the actual buildout
+ self.install(args)
+
+ # Now copy buildout and setuptools eggs, amd record destination eggs:
+ entries = []
+ for name in 'setuptools', 'zc.buildout':
+ r = pkg_resources.Requirement.parse(name)
+ dist = pkg_resources.working_set.find(r)
+ if dist.precedence == pkg_resources.DEVELOP_DIST:
+ dest = os.path.join(self['buildout']['develop-eggs-directory'],
+ name+'.egg-link')
+ open(dest, 'w').write(dist.location)
+ entries.append(dist.location)
+ else:
+ dest = os.path.join(self['buildout']['eggs-directory'],
+ os.path.basename(dist.location))
+ entries.append(dest)
+ if not os.path.exists(dest):
+ shutil.copy2(dist.location, dest)
+
+ # Create buildout script
+ ws = pkg_resources.WorkingSet(entries)
+ ws.require('zc.buildout')
+ zc.buildout.easy_install.scripts(
+ ['zc.buildout'], ws, sys.executable,
+ self['buildout']['bin-directory'])
+
+
def install(self, install_parts):
# Create buildout directories
@@ -554,7 +584,7 @@
if args:
command = args.pop(0)
- if command != 'install':
+ if command not in ('install', 'bootstrap'):
_error('invalid command:', command)
else:
command = 'install'
Modified: zc.buildout/trunk/src/zc/buildout/buildout.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.txt 2006-06-26 21:16:14 UTC (rev 68857)
+++ zc.buildout/trunk/src/zc/buildout/buildout.txt 2006-06-26 21:22:29 UTC (rev 68858)
@@ -265,7 +265,8 @@
>>> import os
>>> os.chdir(sample_buildout)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
+ >>> print system(buildout),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Installing data_dir
data_dir: Creating directory mystuff
@@ -314,7 +315,7 @@
... path = mydata
... """)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling data_dir
buildout: Installing data_dir
@@ -414,7 +415,7 @@
Now, if we run the buildout, we'll see the options with the values
substituted.
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling data_dir
buildout: Installing data_dir
@@ -432,7 +433,7 @@
recipe, so it assumed it could and reinstalled mydata. If we rerun
the buildout:
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Installing data_dir
buildout: Installing debug
@@ -488,7 +489,7 @@
... op = base
... """)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
op buldout
recipe recipes:debug
@@ -588,7 +589,7 @@
... name = ee
... """)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
name ee
op buildout
op1 e1 1
@@ -635,7 +636,7 @@
... """)
>>> os.environ['HOME'] = home
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
name ee
op buildout
op1 e1 1
@@ -688,8 +689,7 @@
Note that we used the installed buildout option to specify an
alternate file to store information about installed parts.
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')
- ... + ' -c other.cfg debug:op1=foo -v'),
+ >>> print system(buildout+' -c other.cfg debug:op1=foo -v'),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Installing debug
name other
@@ -702,8 +702,7 @@
Options can also be combined in the usual Unix way, as in:
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')
- ... + ' -vcother.cfg debug:op1=foo'),
+ >>> print system(buildout+' -vcother.cfg debug:op1=foo'),
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Installing debug
name other
@@ -717,7 +716,7 @@
>>> os.remove(os.path.join(sample_buildout, 'other.cfg'))
>>> os.remove(os.path.join(sample_buildout, '.other.cfg'))
-Currently, the default and only command is 'install' and it takes a
+The most commonly used command is 'install' and it takes a
list of parts to install. if any parts are specified, then they must
be listed in the buildout parts option and only those parts are
installed. To illustrate this, we'll update our configuration and run
@@ -745,7 +744,7 @@
... recipe = recipes:debug
... """)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -v'),
+ >>> print system(buildout+' -v'),
buildout: Running /sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling debug
buildout: Installing debug
@@ -827,8 +826,7 @@
and run the buildout specifying just d2 and d3:
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout' + ' -v')
- ... + ' install d3 d4'),
+ >>> print system(buildout+' -v install d3 d4'),
buildout: Running /sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling d3
buildout: Installing d3
@@ -897,7 +895,7 @@
Now, if we run the buildout without the install command:
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -v'),
+ >>> print system(buildout+' -v'),
buildout: Running /sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling d1
buildout: Uninstalling d2
@@ -954,7 +952,7 @@
... work = os.path.join(alt, 'work'),
... ))
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -v'),
+ >>> print system(buildout+' -v'),
buildout: Creating directory /tmp/sample-alt/scripts
buildout: Creating directory /tmp/sample-alt/work
buildout: Creating directory /tmp/sample-alt/basket
@@ -992,7 +990,7 @@
... recipes=os.path.join(sample_buildout, 'recipes'),
... ))
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -v'),
+ >>> print system(buildout+' -v'),
buildout: Creating directory /tmp/sample-alt/bin
buildout: Creating directory /tmp/sample-alt/parts
buildout: Creating directory /tmp/sample-alt/eggs
@@ -1048,7 +1046,7 @@
configuration file. Because the verbosoty is subtracted from the log
level, we get a final log level of 20, which is the INFO level.
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
+ >>> print system(buildout),
INFO Running /tmp/sample-buildout/recipes/setup.py -q develop ...
Predefined buildout options
@@ -1066,8 +1064,7 @@
... parts =
... """)
- >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')
- ... + ' -vv'),
+ >>> print system(buildout+' -vv'),
Configuration data:
[buildout]
bin-directory = /tmp/sample-buildout/bin
@@ -1146,3 +1143,41 @@
command-line options.
+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
+local buildout scripts. There must be an existing setup.cfg:
+
+ >>> sample_bootstrapped = tempfile.mkdtemp('sample-bootstrapped')
+ >>> write(sample_bootstrapped, 'setup.cfg',
+ ... '''
+ ... [buildout]
+ ... parts =
+ ... ''')
+
+ >>> print system(buildout
+ ... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
+ ... +' bootstrap'),
+
+ >>> ls(sample_bootstrapped)
+ - .installed.cfg
+ d bin
+ d develop-eggs
+ d eggs
+ d parts
+ - setup.cfg
+
+ >>> ls(sample_bootstrapped, 'bin')
+ - buildout
+ - py_zc.buildout
+
+ >>> ls(sample_bootstrapped, 'eggs')
+ - setuptools-0.6b3-py2.3.egg
+
+ >>> ls(sample_bootstrapped, 'develop-eggs')
+ - zc.buildout.egg-link
+
+Note that, in this example, we were using a development egg for the
+buildout, and the ac.buildout egg ended up as an egg link.
More information about the Checkins
mailing list