[Distutils] setup.cfg - to interpolate or not to interpolate

Nick Coghlan ncoghlan at gmail.com
Fri Jul 28 03:01:42 EDT 2017


On 28 July 2017 at 15:39, Robert Collins <robertc at robertcollins.net> wrote:
> On 28 July 2017 at 15:34, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> Clarifying to add: I think this is a worthwhile change, as it helps to
>> ensure that the static config files actually *are* static, and hence
>> less dependent on being read specifically with Python's configparser
>> library. That's a boon for interoperability, even if it means that
>> folks that genuinely want interpolation will need to switch to a
>> "setup.cfg.in" style approach where they use the templating tool of
>> their choice to read in the input file, substitute values, and then
>> write out a completely static setup.cfg file.
>
> Yeah, I'm going to disagree here. While its true that using
> interpolation binds the config file semantic interpretation to Python,
> its *already* bound that way due to the idiosyncratic continuations
> style and nested sections.
>
> Doing a .in -> actual-foo is a great pattern for build systems
> building expensive artifacts with complex dependency chains. Not
> problems have, and copying their solutions without the problem is just
> unnecessary, and unhelpful, complexity.
>
> +1 from me for retaining interpolation.

Fair point, and reading the original bug report in
https://bugs.python.org/issue20754, it seems the main problems were
that:

- it wasn't documented that interpolation is enabled when parsing setup.cfg
- the Python 2.7 implementation currently uses ConfigParser rather
than SafeConfigParser, so escaping with `%%` didn't work in 2.x

That would make the following the lowest impact resolution that still
fixes the original reported problem:

- update the ConfigParser (3.x) and SafeConfigParser (2.x) docs to
explicitly say that "%%" works as an escape
- update setuptools and distutils to use SafeConfigParser in 2.7
- update the setuptools and distutils docs to say that interpolation
is enabled when reading setup.cfg and "%%" works as an escape (except
on older versions of Python 2.x with either distutils or an older
version of setuptools).

So I'll retract my initial response as being ill-informed (since I
didn't click through and read the original bug report).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list