On Thu, Sep 17, 2009 at 12:55 PM, Tarek Ziadé <[email protected]> wrote: > On Wed, Sep 16, 2009 at 5:40 PM, Wolodja Wentland > <[email protected]> wrote: >> On Tue, Sep 15, 2009 at 17:38 +0200, Wolodja Wentland wrote: >>> My question is: "How to reliably access data files from a module in >>> foo?" >> >>> Approach 2 - writing a build.py file at installation time >>> --------------------------------------------------------- >>> >>> The last question made me think, that Approach 1 works for the three >>> standard installation schemes, but fails miserably if the user decides >>> to do anything fancy. >> >> I implemented this approach like this: > > Sorry for the late reply, > >> >> Is this a good approach? Is there anything i can do better? > > The idea of providing your own install command seems good, except that I find > writing all informations in a .py overkill. > > In the same way the option --record works, you can memorize > all installation locations into a simple ConfigParser-like file you > add to the files that > are installed in Python in your package. > > Your code can then read the .cfg file it at execution time using > __file__ to get your > paths. > > Although with this approach you have to be careful if your package is > distributed in some environments (py2exe, setuptools eggs) where you might be > located in a zipped file.
On a second thaught, if the file already exists in you package with default values it's simpler : you might be able to alter it on-the-fly by overriding the build_py command instead of the install command and AFAIR, you won't be bothered by setuptools' monkey patches. _______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
