[Python-ideas] A common configuration file standard for the stdlib + configparser (or replacer) new API

Tarek Ziadé ziade.tarek at gmail.com
Sat Feb 6 18:54:41 CET 2010


I am working on a proposal that will add the need to have a new .cfg
file to read for a stdlib package.
This is an existing need already for distutils (with distutils.cfg).

I have a proposal: let's create a mechanism that allows a stdlib
package to store values in a central
configuration file that can be overriden by a per-user configuration file.

This file would be located in the "data" path returned by the install
scheme (see sysconfig.py for details)

so roughly : in sys.prefix for the global one, and in ~/.local/ for
the local per-user one.

Then each package would look in the local one and "update" the global
one with it if found

The files would be a configparser ini-like file, with one mandatory
section that is the name of the package or
module in the stdlib the filename

For example, if "multiprocessing" needs a configuration file, it will
be called "multiprocessing.cfg"
and have at least one section:

    foo = 1

Last, the configparser (or replacer) would provide a new API called
"get_config(package_name)" that would
read the configuration and return a config object packages can work with.

A nice add-on would be to make it possible to configure the paths, so
os packagers could
drive where the cfg file should be located on their systems

Does it sounds like a good idea ?


Tarek Ziadé | http://ziade.org

More information about the Python-ideas mailing list