Does Buildout support value substitution in the extends option?
Asked Answered
M

1

8

Does Buildout support value substitution in the extends option of the buildout section?

For example, this example.cfg doesn't extend with base.cfg:

[config]
base = base.cfg

[buildout]
extends =
    ${config:base}
parts =

buildout -c example.cfg annotate

My goal is to send the file-to-extend as a parameter from the outside like this:

buildout config:base=base.cfg -c example.cfg annotate

I tried to merge the buildout:extends from the outside; but that doesn't work either:

buildout buildout:extends+=base.cfg -c example.cfg annotate
Mennonite answered 6/3, 2019 at 11:50 Comment(1)
Since I am writing everything in a bash script, I did template substitution using envsubst to get the same effect. Probably, I need to switch to Python though.Mennonite
P
6

No, extends doesn't support value substitutions, unfortunately. The current implementation processes buildout.extends before variable substitution can take place.

There is an existing feature request open for this: #39 No variable substitutions in extends.

I generally create a local.cfg file first, perhaps from a template, and run buildout -c local.cfg. That'd be the kind of place I'd put custom extends configuration.

Perineum answered 9/3, 2019 at 13:7 Comment(7)
Thanks, I had a feeling that order matters for extends. Need to dig deeper into the code though.Mennonite
@Nishant: extends is handled inside _open(). _open() is called to load the configuration file for the Buildout() instance, which eventually sets self._raw from the merged results.Perineum
@Nishant: self._raw is used in __getitem__ to create Options() instances per section, and only then, in Options._initialize(), are value substitutions processed.Perineum
I did check this meta.stackexchange.com/questions/77226/…, but I can't figure out how to offer extra points.Mennonite
How do I offer extra bounties for this answer? This was like a tip of iceberg for me and I was given a proper answer including GitHub PR for an existing question. Is there some way to offer some bounties like 100 points for this answer?Mennonite
@Mennonite I’m glad you found this to be helpful! See Can't we award bounty to a helpful answer directly? for the details on how you can award a bounty to an existing answer.Perineum
Thanks, @Martijn! I have added a bounty.Mennonite

© 2022 - 2024 — McMap. All rights reserved.