Commit 34fd0458 authored by Reinout van Rees's avatar Reinout van Rees

Pulled in lelit's pull request #172 to add some fixes and to merge with master

parents c8c34766 46a34688
......@@ -40,6 +40,14 @@ Change History
configuration so that tests run much quicker so that buildout is easier and
quicker to develop.
- Treat ``download-cache`` and ``eggs-directory`` in a special manner:
a) they can be relative paths, relative to the location of the configuration
file that defines them
b) the can be in the form ``~/subdir``, with the usual convention that the
``~`` char means the home directory of the user executing the buildout
2.3.1 (2014-12-16)
==================
......
......@@ -7,6 +7,10 @@ When you're developing buildout itself, you need to know two things:
will find your already-installed setuptools, leading to test differences
when setuptools' presence is explicitly tested.
- Also the presence of ``~/.buildout/default.cfg`` may interfere with the
tests so you may want to temporarily rename it so that it does not get in
the way.
- Don't bootstrap with ``python bootstrap/bootstrap.py`` but with ``python
dev.py``.
......
......@@ -253,6 +253,36 @@ class Buildout(DictMixin):
if k not in versions
))
# Absolutize some particular directory, handling also the ~/foo form,
# and considering the location of the configuration file that generated
# the setting as the base path, falling back to the main configuration
# file location
for name in ('download-cache', 'eggs-directory', 'extends-cache'):
if name in data['buildout']:
origdir, src = data['buildout'][name]
if '${' in origdir:
continue
if not os.path.isabs(origdir):
if src in ('DEFAULT_VALUE',
'COMPUTED_VALUE',
'COMMAND_LINE_VALUE'):
if 'directory' in data['buildout']:
basedir = data['buildout']['directory'][0]
else:
basedir = self._buildout_dir
else:
if _isurl(src):
raise zc.buildout.UserError(
'Setting "%s" to a non absolute location ("%s") '
'within a\n'
'remote configuration file ("%s") is ambiguous.' % (
name, origdir, src))
basedir = os.path.dirname(src)
absdir = os.path.expanduser(origdir)
if not os.path.isabs(absdir):
absdir = os.path.join(basedir, absdir)
data['buildout'][name] = (absdir, src)
self._annotated = copy.deepcopy(data)
self._raw = _unannotate(data)
self._data = {}
......@@ -351,12 +381,8 @@ class Buildout(DictMixin):
download_cache = options.get('download-cache')
if download_cache:
download_cache = os.path.join(options['directory'], download_cache)
if not os.path.isdir(download_cache):
raise zc.buildout.UserError(
'The specified download cache:\n'
'%r\n'
"Doesn't exist.\n"
% download_cache)
if not os.path.exists(download_cache):
os.mkdir(download_cache)
download_cache = os.path.join(download_cache, 'dist')
if not os.path.isdir(download_cache):
os.mkdir(download_cache)
......
......@@ -810,7 +810,7 @@ COMMAND_LINE_VALUE).
DEFAULT_VALUE
directory= /sample-buildout
COMPUTED_VALUE
eggs-directory= eggs
eggs-directory= /sample-buildout/eggs
DEFAULT_VALUE
executable= ...
DEFAULT_VALUE
......
......@@ -139,3 +139,78 @@ install-from-cache option set to true:
Getting distribution for 'demoneeded'.
Got demoneeded 1.1.
Generated script '/sample-buildout/bin/demo'.
Auto-creation of download cache directory
-----------------------------------------
With zc.buildout version 2.2.2 or higher the cache directory is automatically
created, provided it is within an already existing directory::
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... download-cache = %(cache)s/newdir
... ''' % globals())
>>> print_(system(buildout), end='')
Uninstalling eggs.
>>> ls(cache)
d dist
d newdir
Using relative paths
--------------------
You can use a relative path for ``download-cache`` (the same logic is applied to
``eggs-directory`` and to ``extends-cache`` too) and in such case it is considered
relative to the location of the configuration file that sets its value.
As an example, we create a ``base.cfg`` configuration in a different directory::
>>> basedir = tmpdir('basecfg')
>>> write(basedir, 'base.cfg',
... '''
... [buildout]
... download-cache = cache
... ''')
and a ``buildout.cfg`` that extends from there::
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = %(basedir)s/base.cfg
... parts =
... ''' % globals())
>>> dummy = system(buildout)
>>> ls(basedir)
- base.cfg
d cache
Of course this cannot be used when the base configuration is not on the local
filesystem because it wouldn't make any sense having a remote cache::
>>> server_data = tmpdir('server_data')
>>> server_url = start_server(server_data)
>>> cd(sample_buildout)
>>> write(server_data, 'base.cfg', """\
... [buildout]
... download-cache = cache
... """)
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = %(server_url)s/base.cfg
... parts =
... ''' % globals())
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
While:
Initializing.
Error: Setting "download-cache" to a non absolute location ("cache") within a
remote configuration file...
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