Library and real path name
michele.petrazzo at TOGLIunipex.it
Tue Aug 23 11:56:33 CEST 2005
I want to redistribute the library that I create.
I create a project, its setup.py that when launched copy all files into
the "site-packages/library" directory. And here it's all ok.
When I call my library with:
I want that my library know where are its real path
(site-packages/library/), because it has to load a data file present
into a subpackage directory (like site-package/library/data/file.dat),
but if, inside the library code, I try to load the file with:
f = open("./data/file.dat")
python raise me an exception because it not found the file. I see that
the current path are the path where I execute python.
I think that I can solve this problem with something like:
if sys.platform == 'win32': prefix = os.path.join(sys.prefix,
else: prefix = os.path.join(sys.prefix, "site-packages/library/data/")
it work, but I think that is not a good solution (a real pythonic
Can someone help me?
More information about the Python-list