[Tutor] where to put configuration files

Paul Tremblay phthenry@earthlink.net
Tue Jun 10 02:39:02 2003


On Mon, Jun 09, 2003 at 09:17:20PM -0700, Sean 'Shaleh' Perry wrote:
> ['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'fnmatch', 
> 'glob', 'glob1', 'has_magic', 'magic_check', 'os', 're']
> >>> type(glob)
> <type 'module'>
> >>> type(glob.__file__)
> <type 'str'>
> >>> glob.__file__
> '/usr/lib/python2.2/glob.pyc'
> >>> glob.glob("*.cc") # I was in a dir with some of my C++ code
> ['Workspace.cc', 'Clientmenu.cc', 'Configmenu.cc', 'Iconmenu.cc', 
> 'Rootmenu.cc', 'Screen.cc', 'Slit.cc', 'Toolbar.cc', 'Window.cc', 
> 'Windowmenu.cc', 'Workspacemenu.cc', 'blackbox.cc', 'main.cc', 
> 'BlackboxResource.cc']
> 
> 
ailman/listinfo/tutor

Okay, so my setup.py file looks like:


from distutils.core import setup



setup(name="foo1",
    version=".1",
    description="foo test",
    author="Paul Tremblay",
    author_email="phthenry@earthlink.net",
    packages=['foo'],
data_files = [("foo", ["data.txt"])],
    )

I install everyting with the command 

python setup.py install --home /home/paul

My configuration files (data.txt) gets put in /home/paul/foo

Now the user executes the script, which has this line

import foo

path = foo.__file__

print path

/home/paul/lib/python/foo.py

Second scenario:

I run

python setup.py install

And the data gets put in /usr/foo

I run the script:


import foo

path = foo.__file__

print path

/usr/lib/python2.2/site-packages/foo.py

How can I make a universal rule to parse __file__ in order to get the
location of data.txt? The actual data.txt can exist many levels up from
the actual module.

Or do I actually put the data.txt *in* foo to begin with? But if I do
that, wont' the install utility try to see it as a python file?

thanks

Paul






-- 

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