How to create conditional configuration sections in zc.buildout?

192 Views Asked by At

I am trying to create a section in version.cfg file defining different versions of Jinja2 egg-package (1.8.1 and 2.9.6) to be installed for different OS versions (Fedora 25/Fedora 26). Unfortunately, official documentation lacks examples and contains only the following explanation how to create conditional configuration sections:

You can define environment-specific options by providing conditional sections:

[ctl]
suffix =

[ctl:windows]
suffix = .bat

In this tiny example, we’ve defined a ctl:suffix option that’s .bat on Windows and an empty string elsewhere.

A conditional section has a colon and then a Python expression after the name. If the Python expression result is true, the section options from the section are included. If the value is false, the section is ignored.

Accordingly, I expected the version.cfg with

[versions]
Jinja2 = 1.8.1

[versions:platform.release().split('-')[1].split('.')[1]=='fc26']
Jinja2 = 2.9.6

would solve my problem but it doesn't. How to fix my versions.cfg?

UPDATE

Actually, it works. More concise way is

[versions:platform.linux_distribution()[:2] == ('Fedora', '26')]
Jinja2 = 2.9.6
0

There are 0 best solutions below