[Distutils] Finding my data_files

Paul Moore p.f.moore at gmail.com
Mon Jan 14 12:24:37 CET 2008


If I have a module which installs some files using the
data_files=[...] argument to setup.py, how do I then (reliably) find
those files from my code?

The first question is, is there a way of obtaining the distutils
data_files parameter value at runtime? If not, I guess I have to code
the same information in my code as is in the setup.py script. Not
ideal, but OK...

The second question is, if my files are installed using a relative
path, then the documentation says (section 2.7) "If directory is a
relative path, it is interpreted relative to the installation prefix
(Python's sys.prefix for pure-Python packages, sys.exec_prefix for
packages that contain extension modules)." That's OK, but again it
sounds like I need to code knowledge of whether the setup includes
extension modules or not, into my code. OK, if I must, then I must,
but I'd rather not do so and find out I missed something obvious...

One final question, is it possible (barring obvious hacks like
checking if sys.prefix or sys.exec_prefix is a prefix of
module.__file__) to determine if I'm running from an installed or a
development copy of my module?

I have a horrible feeling that the answer to most of this will be "use
setuptools", but I don't have that option, as this is not my code
(it's MoinMoin, for what it's worth).

Thanks,
Paul.


More information about the Distutils-SIG mailing list