[Biopython-dev] Accessing built-in data files

Peter biopython at maubp.freeserve.co.uk
Mon Nov 19 15:25:48 UTC 2007


Tiago Antão wrote:
> 1. Including the data with the distribution
> Biopython uses distutils, a standard Python package mechanism. To
> include data files, setup.py needs to be changed. ...
> Go to DATA_FILES and include your files. For SimCoal I did
> this:
> DATA_FILES=[
>     #.... More stuff will be here for other packages
>     "Bio/PopGen/SimCoal/data/*par" #my data files are *par
>     ]
> Thats it! Of course, as usual, the package should have been added (but
> that is true to all packages)

Good.

> 2. Accessing the data that was packaged
> This one is trickier. The first problem is that the data files might
> be installed in either the platform dependent install directory or in
> the platform independent one. ...

I may be naive here, but I would expect the datafiles to be installed in 
the same relative path as the python files.  Is this not always the case?

As I pointed out in bug 2375, there is some code in setup.py (pre-dating 
the support in distutils) which takes care of installing data files for 
EUtils - if that actually works for the special cases you are concerned 
about, maybe we should just use that for your data files too.  See 
http://bugzilla.open-bio.org/show_bug.cgi?id=2375

> My work around? Go through all the directories on sys.path (PYTHONPATH) and search for
> a data file that I know is there ...

That doesn't seem very elegant :(

Peter




More information about the Biopython-dev mailing list