[Distutils] using bdist_wininst --install-script
Stefan Seefeld
seefeld at sympatico.ca
Thu Jan 26 04:25:30 CET 2006
Hi Phillip,
Phillip J. Eby wrote:
> At 09:41 PM 1/25/2006 -0500, Stefan Seefeld wrote:
>
>> Hi there,
>>
>> I'm working on a python application which uses a number of data files.
>> In order to figure out the path to the data files I used to use some
>> hacks, such as letting the application file inject a 'prefix' variable
>> into the root module (package) for other modules to use.
>
>
> The simplest way to do this is to use the package_data option, see:
>
> http://docs.python.org/dist/node11.html
>
> And then use the __file__ variable of the containing package module to
> determine the data file locations at runtime. So, if a data file
> 'bar.dat' is inside your 'foo' package, you can use:
>
> import foo
> pkg_dir = os.path.dirname(foo.__file__)
> filename = os.path.join(pkg_dir, 'bar.dat')
>
> This will work on any platform, with any installation method,
> bdist_wininst or otherwise.
IIUC, this works if and because 'bar.dat' is located somewhere
under pkg_dir, right ? The traditional way of installing 'data files'
on unix-like systems, however, is to keep them in <prefix>/share,
and the python modules in <prefix>/lib/python-<version>/site-packages,
and there doesn't appear to be a platform-independent path from
python module to data dir. Right ?
Unfortunately I don't think I can change the directory layout to
relocate the data files into a subdirectory of my toplevel python
package.
Thanks anyways,
Stefan
More information about the Distutils-SIG
mailing list