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 ...@@ -40,6 +40,14 @@ Change History
configuration so that tests run much quicker so that buildout is easier and configuration so that tests run much quicker so that buildout is easier and
quicker to develop. 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) 2.3.1 (2014-12-16)
================== ==================
......
...@@ -7,6 +7,10 @@ When you're developing buildout itself, you need to know two things: ...@@ -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 will find your already-installed setuptools, leading to test differences
when setuptools' presence is explicitly tested. 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 - Don't bootstrap with ``python bootstrap/bootstrap.py`` but with ``python
dev.py``. dev.py``.
......
...@@ -253,6 +253,36 @@ class Buildout(DictMixin): ...@@ -253,6 +253,36 @@ class Buildout(DictMixin):
if k not in versions 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._annotated = copy.deepcopy(data)
self._raw = _unannotate(data) self._raw = _unannotate(data)
self._data = {} self._data = {}
...@@ -351,12 +381,8 @@ class Buildout(DictMixin): ...@@ -351,12 +381,8 @@ class Buildout(DictMixin):
download_cache = options.get('download-cache') download_cache = options.get('download-cache')
if download_cache: if download_cache:
download_cache = os.path.join(options['directory'], download_cache) download_cache = os.path.join(options['directory'], download_cache)
if not os.path.isdir(download_cache): if not os.path.exists(download_cache):
raise zc.buildout.UserError( os.mkdir(download_cache)
'The specified download cache:\n'
'%r\n'
"Doesn't exist.\n"
% download_cache)
download_cache = os.path.join(download_cache, 'dist') download_cache = os.path.join(download_cache, 'dist')
if not os.path.isdir(download_cache): if not os.path.isdir(download_cache):
os.mkdir(download_cache) os.mkdir(download_cache)
......
...@@ -810,7 +810,7 @@ COMMAND_LINE_VALUE). ...@@ -810,7 +810,7 @@ COMMAND_LINE_VALUE).
DEFAULT_VALUE DEFAULT_VALUE
directory= /sample-buildout directory= /sample-buildout
COMPUTED_VALUE COMPUTED_VALUE
eggs-directory= eggs eggs-directory= /sample-buildout/eggs
DEFAULT_VALUE DEFAULT_VALUE
executable= ... executable= ...
DEFAULT_VALUE DEFAULT_VALUE
......
...@@ -46,7 +46,7 @@ download: ...@@ -46,7 +46,7 @@ download:
<a href="index/">index/</a><br> <a href="index/">index/</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br> <a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html> </body></html>
We'll enable logging on the link server so we can see what's going on: We'll enable logging on the link server so we can see what's going on:
...@@ -87,7 +87,7 @@ If we remove the installed eggs from eggs directory and re-run the buildout: ...@@ -87,7 +87,7 @@ If we remove the installed eggs from eggs directory and re-run the buildout:
>>> for f in os.listdir('eggs'): >>> for f in os.listdir('eggs'):
... if f.startswith('demo'): ... if f.startswith('demo'):
... remove('eggs', f) ... remove('eggs', f)
>>> print_(system(buildout), end='') >>> print_(system(buildout), end='')
GET 200 / GET 200 /
Updating eggs. Updating eggs.
...@@ -139,3 +139,78 @@ install-from-cache option set to true: ...@@ -139,3 +139,78 @@ install-from-cache option set to true:
Getting distribution for 'demoneeded'. Getting distribution for 'demoneeded'.
Got demoneeded 1.1. Got demoneeded 1.1.
Generated script '/sample-buildout/bin/demo'. 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