Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.buildout
Commits
04efb577
Commit
04efb577
authored
Mar 09, 2014
by
Lele Gaifax
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow download-cache and eggs-directory to be relative paths
This implements additional suggestions on issue #171.
parent
3f85f61e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
3 deletions
+96
-3
CHANGES.rst
CHANGES.rst
+8
-0
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+30
-0
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+1
-1
src/zc/buildout/downloadcache.txt
src/zc/buildout/downloadcache.txt
+57
-2
No files found.
CHANGES.rst
View file @
04efb577
...
@@ -10,6 +10,14 @@ Unreleased
...
@@ -10,6 +10,14 @@ Unreleased
- Add ``BUILDOUT_HOME`` as an alternate way to control how the user default
- Add ``BUILDOUT_HOME`` as an alternate way to control how the user default
configuration is found.
configuration is found.
- 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.2.1 (2013-09-05)
2.2.1 (2013-09-05)
==================
==================
...
...
src/zc/buildout/buildout.py
View file @
04efb577
...
@@ -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'
):
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
=
{}
...
...
src/zc/buildout/buildout.txt
View file @
04efb577
...
@@ -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
...
...
src/zc/buildout/downloadcache.txt
View file @
04efb577
...
@@ -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.
...
@@ -159,3 +159,58 @@ created, provided it is within an already existing directory::
...
@@ -159,3 +159,58 @@ created, provided it is within an already existing directory::
>>> ls(cache)
>>> ls(cache)
d dist
d dist
d newdir
d newdir
Using relative paths
--------------------
You can use a relative path for ``download-cache`` (the same logic is applied
to ``eggs-directory`` 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...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment