Accessing files installed with distutils

Steve Holden steve at
Tue Mar 8 14:55:40 CET 2005

timothy.williams at wrote:
> I was wondering how to do this too. I'm trying to write a distutils
> script that has some data I'd like to include.  From the
> distutils docs I get
> data_files specifies a sequence of (directory, files) pairs in the
> following way:
> setup(...
>       data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
>                   ('config', ['cfg/data.cfg']),
>                   ('/etc/init.d', ['init-script'])]
>      )
> I can use sys.prefix to find the top level where python is installed,
> but this doesn't tell me specifically where site-packages is. On my
> Linux box it is in
> {sys.prefix}/lib/python2.3/site-packages
> but on Windows, it's in
> {sys.prefix}/Lib/site-packages.
> Do I need to use sys.platform (along with sys.version) to check what
> type of machine I'm on, or is there some better  method to get the
> location of site-packages?
This is one of the areas where distutils could probably do with some 
improvement. I don;t know whether it's on any developers priority list, 


More information about the Python-list mailing list