Commit b84faf54 authored by jim's avatar jim

Separated the eggs and develop-eggs directories to allow eggs to be

shared across projects or working directories.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@68707 62d5b8a3-27da-0310-9561-8e5933582275
parent d9481ed7
...@@ -39,6 +39,7 @@ class Egg: ...@@ -39,6 +39,7 @@ class Egg:
options['_b'] = buildout['buildout']['bin-directory'] options['_b'] = buildout['buildout']['bin-directory']
options['_e'] = buildout['buildout']['eggs-directory'] options['_e'] = buildout['buildout']['eggs-directory']
options['_d'] = buildout['buildout']['develop-eggs-directory']
def install(self): def install(self):
options = self.options options = self.options
...@@ -56,5 +57,5 @@ class Egg: ...@@ -56,5 +57,5 @@ class Egg:
]) ])
return zc.buildout.egglinker.scripts( return zc.buildout.egglinker.scripts(
[distribution], [distribution],
options['_b'], [options['_e']], scripts=scripts) options['_b'], [options['_d'], options['_e']], scripts=scripts)
...@@ -68,6 +68,7 @@ class Buildout(dict): ...@@ -68,6 +68,7 @@ class Buildout(dict):
data = dict(buildout={ data = dict(buildout={
'directory': os.path.dirname(config_file), 'directory': os.path.dirname(config_file),
'eggs-directory': 'eggs', 'eggs-directory': 'eggs',
'develop-eggs-directory': 'develop-eggs',
'bin-directory': 'bin', 'bin-directory': 'bin',
'parts-directory': 'parts', 'parts-directory': 'parts',
'installed': '.installed.cfg', 'installed': '.installed.cfg',
...@@ -116,7 +117,7 @@ class Buildout(dict): ...@@ -116,7 +117,7 @@ class Buildout(dict):
self._links = links and links.split() or () self._links = links and links.split() or ()
self._buildout_dir = options['directory'] self._buildout_dir = options['directory']
for name in ('bin', 'parts', 'eggs'): for name in ('bin', 'parts', 'eggs', 'develop-eggs'):
d = self._buildout_path(options[name+'-directory']) d = self._buildout_path(options[name+'-directory'])
options[name+'-directory'] = d options[name+'-directory'] = d
...@@ -166,12 +167,16 @@ class Buildout(dict): ...@@ -166,12 +167,16 @@ class Buildout(dict):
def install(self, install_parts): def install(self, install_parts):
# Create buildout directories # Create buildout directories
for name in ('bin', 'parts', 'eggs'): for name in ('bin', 'parts', 'eggs', 'develop-eggs'):
d = self['buildout'][name+'-directory'] d = self['buildout'][name+'-directory']
if not os.path.exists(d): if not os.path.exists(d):
self._logger.info('Creating directory %s', d) self._logger.info('Creating directory %s', d)
os.mkdir(d) os.mkdir(d)
# Add develop-eggs directory to path so that it gets searched
# for eggs:
sys.path.insert(0, self['buildout']['develop-eggs-directory'])
# Build develop eggs # Build develop eggs
self._develop() self._develop()
...@@ -259,7 +264,7 @@ class Buildout(dict): ...@@ -259,7 +264,7 @@ class Buildout(dict):
os.P_WAIT, sys.executable, sys.executable, os.P_WAIT, sys.executable, sys.executable,
setup, '-q', 'develop', '-m', '-x', setup, '-q', 'develop', '-m', '-x',
'-f', ' '.join(self._links), '-f', ' '.join(self._links),
'-d', self['buildout']['eggs-directory'], '-d', self['buildout']['develop-eggs-directory'],
{'PYTHONPATH': {'PYTHONPATH':
os.path.dirname(pkg_resources.__file__)}, os.path.dirname(pkg_resources.__file__)},
) )
...@@ -269,6 +274,8 @@ class Buildout(dict): ...@@ -269,6 +274,8 @@ class Buildout(dict):
def _load_recipes(self, parts): def _load_recipes(self, parts):
recipes = {} recipes = {}
recipes_requirements = [] recipes_requirements = []
pkg_resources.working_set.add_entry(
self['buildout']['develop-eggs-directory'])
pkg_resources.working_set.add_entry(self['buildout']['eggs-directory']) pkg_resources.working_set.add_entry(self['buildout']['eggs-directory'])
# Install the recipe distros # Install the recipe distros
......
...@@ -32,14 +32,15 @@ installs setuptools and zc.buildout into the checkout as well as any ...@@ -32,14 +32,15 @@ installs setuptools and zc.buildout into the checkout as well as any
parts defined. parts defined.
We have a sample buildout that has already been created for us. It We have a sample buildout that has already been created for us. It
has the absolute minimum information. We have bin, eggs and parts has the absolute minimum information. We have bin, develop-eggs, eggs
directories, a configuration file, and an .installed,cfg that contains and parts directories, a configuration file, and an .installed,cfg
informatiion about previously-installed parts: that contains informatiion about previously-installed parts:
>>> ls(sample_buildout) >>> ls(sample_buildout)
- .installed.cfg - .installed.cfg
d bin d bin
- buildout.cfg - buildout.cfg
d develop-eggs
d eggs d eggs
d parts d parts
...@@ -53,11 +54,20 @@ but the zc.buildout and setuptools eggs actually live elsewhere. ...@@ -53,11 +54,20 @@ but the zc.buildout and setuptools eggs actually live elsewhere.
>>> ls(sample_buildout, 'eggs') >>> ls(sample_buildout, 'eggs')
The parts directory is initially empty: The develop-eggs and parts directories are initially empty:
>>> ls(sample_buildout, 'develop-eggs')
>>> ls(sample_buildout, 'parts') >>> ls(sample_buildout, 'parts')
The parts directory provides an area where recipies can install The develop-eggs directory holds egg links for software being
developed in the buildout. We separate develop-eggs and other eggs to
allow eggs directories to be shared accross multiple buildouts. For
example, a common developer technique is to define a common eggs
directory in their home that all non-develop eggs are stored in. This
allows larger buildouts to be set up much more quickly and saves disk
space.
The parts directory provides an area where recipes can install
part data. For example, if we built a custom Python, we would part data. For example, if we built a custom Python, we would
install it in the part directory. Part data is stored in a install it in the part directory. Part data is stored in a
subdirectory of the parts directory with the same name as the part. subdirectory of the parts directory with the same name as the part.
...@@ -266,6 +276,7 @@ We see that the recipe created the directory, as expected: ...@@ -266,6 +276,7 @@ We see that the recipe created the directory, as expected:
- .installed.cfg - .installed.cfg
d bin d bin
- buildout.cfg - buildout.cfg
d develop-eggs
d eggs d eggs
d mystuff d mystuff
d parts d parts
...@@ -313,6 +324,7 @@ we'll see that the directory gets removed and recreated: ...@@ -313,6 +324,7 @@ we'll see that the directory gets removed and recreated:
- .installed.cfg - .installed.cfg
d bin d bin
- buildout.cfg - buildout.cfg
d develop-eggs
d eggs d eggs
d mydata d mydata
d parts d parts
...@@ -757,6 +769,7 @@ the buildout in the usual way: ...@@ -757,6 +769,7 @@ the buildout in the usual way:
d d1 d d1
d d2 d d2
d d3 d d3
d develop-eggs
- e1.cfg - e1.cfg
d eggs d eggs
d parts d parts
...@@ -838,6 +851,7 @@ and run the buildout specifying just d2 and d3: ...@@ -838,6 +851,7 @@ and run the buildout specifying just d2 and d3:
d d2 d d2
d data3 d data3
d data4 d data4
d develop-eggs
- e1.cfg - e1.cfg
d eggs d eggs
d parts d parts
...@@ -917,6 +931,7 @@ also see that d1 and d2 have gone away: ...@@ -917,6 +931,7 @@ also see that d1 and d2 have gone away:
d data2 d data2
d data3 d data3
d data4 d data4
d develop-eggs
- e1.cfg - e1.cfg
d eggs d eggs
d parts d parts
...@@ -936,10 +951,12 @@ provide alternate locations, and even names for these directories. ...@@ -936,10 +951,12 @@ provide alternate locations, and even names for these directories.
... [buildout] ... [buildout]
... develop = recipes ... develop = recipes
... parts = ... parts =
... develop-eggs-directory = %(developbasket)s
... eggs-directory = %(basket)s ... eggs-directory = %(basket)s
... bin-directory = %(scripts)s ... bin-directory = %(scripts)s
... parts-directory = %(work)s ... parts-directory = %(work)s
... """ % dict( ... """ % dict(
... developbasket = os.path.join(alt, 'developbasket'),
... basket = os.path.join(alt, 'basket'), ... basket = os.path.join(alt, 'basket'),
... scripts = os.path.join(alt, 'scripts'), ... scripts = os.path.join(alt, 'scripts'),
... work = os.path.join(alt, 'work'), ... work = os.path.join(alt, 'work'),
...@@ -949,6 +966,7 @@ provide alternate locations, and even names for these directories. ...@@ -949,6 +966,7 @@ provide alternate locations, and even names for these directories.
buildout: Creating directory /tmp/sample-alt/scripts buildout: Creating directory /tmp/sample-alt/scripts
buildout: Creating directory /tmp/sample-alt/work buildout: Creating directory /tmp/sample-alt/work
buildout: Creating directory /tmp/sample-alt/basket buildout: Creating directory /tmp/sample-alt/basket
buildout: Creating directory /sample-alt/developbasket
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ... buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
buildout: Uninstalling d4 buildout: Uninstalling d4
buildout: Uninstalling d3 buildout: Uninstalling d3
...@@ -957,10 +975,11 @@ provide alternate locations, and even names for these directories. ...@@ -957,10 +975,11 @@ provide alternate locations, and even names for these directories.
>>> ls(alt) >>> ls(alt)
d basket d basket
d developbasket
d scripts d scripts
d work d work
>>> ls(alt, 'basket') >>> ls(alt, 'developbasket')
- recipes.egg-link - recipes.egg-link
>>> import shutil >>> import shutil
...@@ -985,15 +1004,17 @@ You can also specify an alternate buildout directory: ...@@ -985,15 +1004,17 @@ You can also specify an alternate buildout directory:
buildout: Creating directory /tmp/sample-alt/bin buildout: Creating directory /tmp/sample-alt/bin
buildout: Creating directory /tmp/sample-alt/parts buildout: Creating directory /tmp/sample-alt/parts
buildout: Creating directory /tmp/sample-alt/eggs buildout: Creating directory /tmp/sample-alt/eggs
buildout: Creating directory /tmp/sample-alt/develop-eggs
buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ... buildout: Running /tmp/sample-buildout/recipes/setup.py -q develop ...
>>> ls(alt) >>> ls(alt)
- .installed.cfg - .installed.cfg
d bin d bin
d develop-eggs
d eggs d eggs
d parts d parts
>>> ls(alt, 'eggs') >>> ls(alt, 'develop-eggs')
- recipes.egg-link - recipes.egg-link
>>> import shutil >>> import shutil
......
...@@ -54,7 +54,7 @@ def system(command, input=''): ...@@ -54,7 +54,7 @@ def system(command, input=''):
def buildoutSetUp(test): def buildoutSetUp(test):
sample = tempfile.mkdtemp('sample-buildout') sample = tempfile.mkdtemp('sample-buildout')
for name in ('bin', 'eggs', 'parts'): for name in ('bin', 'eggs', 'develop-eggs', 'parts'):
os.mkdir(os.path.join(sample, name)) os.mkdir(os.path.join(sample, name))
# make sure we can import zc.buildout and setuptools # make sure we can import zc.buildout and setuptools
......
...@@ -29,6 +29,7 @@ class TestRunner: ...@@ -29,6 +29,7 @@ class TestRunner:
options.get('script', self.name), options.get('script', self.name),
) )
options['_e'] = buildout['buildout']['eggs-directory'] options['_e'] = buildout['buildout']['eggs-directory']
options['_d'] = buildout['buildout']['develop-eggs-directory']
def install(self): def install(self):
...@@ -39,10 +40,11 @@ class TestRunner: ...@@ -39,10 +40,11 @@ class TestRunner:
] ]
path = zc.buildout.egglinker.path( path = zc.buildout.egglinker.path(
distributions+['zope.testing'], distributions+['zope.testing'],
[self.options['_e']], [self.options['_d'], self.options['_e']],
) )
locations = [zc.buildout.egglinker.location(distribution, locations = [zc.buildout.egglinker.location(
[self.options['_e']]) distribution,
[self.options['_d'], self.options['_e']])
for distribution in distributions] for distribution in distributions]
script = self.options['script'] script = self.options['script']
open(script, 'w').write(tests_template % dict( open(script, 'w').write(tests_template % dict(
......
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