Skip to content

Commit

Permalink
Problem: CLI buildout:extends not honored
Browse files Browse the repository at this point in the history
Solution: check value explicitely and open corresponding files
  • Loading branch information
gotcha committed Nov 29, 2021
1 parent 2bf8ee0 commit 806e670
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/592.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Honor command-line buildout:extends
13 changes: 13 additions & 0 deletions src/zc/buildout/buildout.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ def __init__(self, config_file, cloptions,
)
data = _update(data, cfg_data)

# extends from command-line
if 'buildout' in cloptions:
cl_extends = cloptions['buildout'].pop('extends', None)
if cl_extends:
for extends in cl_extends.value.split():
download_options = for_download_options['buildout']
cfg_data, _ = _open(
os.path.dirname(extends),
extends, [], download_options,
override, set(), user_defaults
)
data = _update(data, cfg_data)

# apply command-line options
data = _update(data, cloptions)

Expand Down
43 changes: 43 additions & 0 deletions src/zc/buildout/tests/buildout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,49 @@ There are several things to note about this example:
- Relative file names in extended options are interpreted relative to
the directory containing the referencing configuration file.

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... extends = b1.cfg
...
... [debug]
... op = buildout
... """)

>>> print_(system(buildout + ' buildout:extends="b2.cfg"'), end='')
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Installing debug.
name base
op buildout
op1 b1 1
op2 b2 2
op3 b2 3
recipe recipes:debug

>>> print_(system(buildout + ' buildout:extends="b2.cfg %(b3)s"'
... % dict(b3=os.path.join(other, 'b3.cfg'))), end='')
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Installing debug.
name base
op buildout
op1 b1 1
op2 b2 2
op3 b2 3
op4 b3 4
op5 b3base 5
recipe recipes:debug

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... extends = b1.cfg b2.cfg %(b3)s
...
... [debug]
... op = buildout
... """ % dict(b3=os.path.join(other, 'b3.cfg')))

Loading Configuration from URLs
-------------------------------

Expand Down

0 comments on commit 806e670

Please sign in to comment.