[Tutor] where to put configuration files

Paul Tremblay phthenry@earthlink.net
Sat Jun 7 19:41:02 2003


On Fri, Jun 06, 2003 at 06:04:00PM -0700, Sean 'Shaleh' Perry wrote:
> From: Sean 'Shaleh' Perry <shalehperry@attbi.com>
> To: tutor@python.org
> Subject: Re: [Tutor] where to put configuration files
> User-Agent: KMail/1.5.1
> Date: Fri, 6 Jun 2003 18:04:00 -0700
> 
> On Friday 06 June 2003 16:05, Paul Tremblay wrote:
> > I have written a script that requires a configuration file. I have
> > written an additional script that configures my setup.py, as well as the
> > origninal script, as to where the user decides to put the configuration
> > file.
> >
> > This configuration file is kind of a pain to have to maintain. Is it
> > okay to just dump configuration files in /etc, or is this considered bad
> > practice?
> >
> 
> If you *EVER* intend this to be real software used by real users, yes /etc is 
> the place to go.  It is probably a good idea to create a subdir and place the 
> config in there.  Something like /etc/mypackage/foo.conf.

R. Alan Monroe wrote me off this mailing list and pointed out that
Windows users have no /etc/ directory. Mac OS X users do. 

He pointed out that I should just lump the configuration file with the
"rest." I assume he means that I should put it wherever the modules are
installed. (For example,
/usr/lib/python/site-packages/my_special_module/configuration_dir/configure)
However, how do I tell the actual script to look there? 

After all, a user could decide to put the module in
/home/me/my_python_lib.

I suppose I could simply search the sys.path:

for path_dir in sys.path:
 if os.path.exits(path_dir + 'my_module/config'):
   config_file = path_dir + 'my_modulce/config'
   break



But then, that could cause problems.  The user installs version 1.0 in /home/my_python_lib/.

He then installs version 1.1 in /usr/lib/python/site-packages.

The script searches the sys.path list, and finds an *old* configuration
file first, and stops searching.

I have noticed that "real" software simply sticks the configuration in
/etc/whatever. I think the attitude is "You better have access to /etc,
and you better have a directory called /etc.

Thanks

Paul

-- 

************************
*Paul Tremblay         *
*phthenry@earthlink.net*
************************