Possible Duplicate:
setuptools: package data folder location
I have implemented an application in Python, which I now want to package.
Here is a simplified version of my tree
.
├── ivolution
│ ├── data
│ │ └── ui
│ │ ├── AboutIvolutionDialog.glade
│ │ └── IvolutionWindow.glade
│ ├── Face.py
│ ├── gui
│ │ ├── AboutDialog.py
│ │ ├── IvolutionWindow.py
| |
│ ├── Guy.py
│ ├── training_types.py
|
├── Ivolution.py
├── setup.py
The main script to be run is Ivolution.py
My gui (in ivolution/gui) imports glade files.
Inside of my GUI code (IvolutionWindow.py), I have to import my glade file, which I do with a
self.builder.add_from_file("ivolution/data/ui/IvolutionWindow.glade")
This works perfectly if I work from the package. But if I install the package with
python setup.py install
When I run Ivolution.py, the working directory is when the script is run, and not the location of IvolutionWindow.py any more.
So I end up with import errors :
Traceback (most recent call last):
File "/usr/local/bin/Ivolution.py", line 10, in <module>
my_app = IvolutionWindow.IvolutionWindow("Ivolution")
File "/usr/local/lib/python2.7/dist-packages/ivolution/gui/IvolutionWindow.py", line 34, in __init__
self.builder.add_from_file("ivolution/data/ui/IvolutionWindow.glade")
File "/usr/lib/python2.7/dist-packages/gi/types.py", line 43, in function
return info.invoke(*args, **kwargs)
gi._glib.GError: Failed to open file 'ivolution/data/ui/IvolutionWindow.glade': No such file or directory
My question is, how can I handle my imports correctly ?
I need a variable with my install directory and my local data directory (~/.Ivolution) I guess, but I can't find how to do that efficiently.
Thanks for the help, I couldn't find good resources on the web explaining that. Feel free to ask questions, you can learn more about the project here.
EDIT :
hum, seems like this question answers half my questions. I still have to find how to efficiently create a personal folder to save my logs.