[Tutor] Re: where to put data files

Lee Harr missive@hotmail.com
Fri Feb 14 09:13:38 2003


>I have a script that needs to read from a data file, and I want to know
>the best location for the data file.
>
>Right now, I have this line in my setup.py:
>
>             data_files=[('data', ['char_set'])],
>


I asked basically this same question on comp.lang.python a few weeks
back and never received any response. Best I can tell, the best way
to do this is still up in the air in the Python community.

What I do (and what at least some others do) is put the data in the
directory with your library modules.


I got this code from Pygame:

class smart_install_data(install_data):
    def run(self):
        #need to change self.install_dir to the actual library dir
        install_cmd = self.get_finalized_command('install')
        self.install_dir = getattr(install_cmd, 'install_lib')
        return install_data.run(self)



Then in the setup() function, I use:

          ...
           cmdclass={'install_data': smart_install_data},
           data_files=[['pygsear/libdata/images',
               ['pygsear/libdata/images/None.png',
                 'pygsear/libdata/images/turtle.png']]]
          ...



You can see how this works in Pygame or pygsear:
http://pygame.org/
http://savannah.nongnu.org/files/?group=pygsear


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail