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: --- snip --- # -*- coding: UTF-8 -*- #!/usr/bin/env python from __future__ import with_statement import distutils.core as core from distutils.command.install import install as _install import sys import getopt import os.path class install(_install): """install command This specific install command will create a file 'build_config.py' which contains information on """ def run(self): with open('lib/foo/build_config.py', 'w') as build_fp: build_fp.write('# -*- coding: UTF-8 -*-\n\n') build_fp.write("DATA_DIR = '%s'\n"%( os.path.join(self.install_data, 'share'))) build_fp.write("LIB_DIR = '%s'\n"%(self.install_lib)) build_fp.write("SCRIPT_DIR = '%s'\n"%(self.install_scripts)) _install.run(self) core.setup(name='foo', version='0.1', description='Foo is Bar and Baz', author='Wolodja Wentland', ... ) --- snip --- Is this a good approach? Is there anything i can do better? with kind regards Wolodja Wentland