[Distutils] extra files into the package dir

Berthold Höllmann bhoel@starship.python.net
Wed Oct 18 16:26:02 2000

>>>>> "Rene" == Rene Liebscher <R.Liebscher@gmx.de> writes:

    Rene> Pete Shinners wrote:
    >>  i have some extra files i'd like to have copied into the
    >> destination package directory when installing.
    >> it seems that distutils only installs the .PY(C) files when
    >> installing a package directory. how can i tell distutils to
    >> copy my other files too?
    >> does this involve 'extending' the install command? i could
    >> probably do that if there were docs or an example of something
    >> like that.
    Rene> I had a similar problem with PyOpenGL. (It needs some data
    Rene> files for its examples.) May be my solution is what you
    Rene> need. (At least it could serve as an example.)

    Rene> Look at the following address:
    Rene> http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/PyOpenGL/?cvsroot=PyOpenGL

    Rene> "my_install_data.py" extends distutils' install_data
    Rene> command. "setup.py" uses then this alternative command. (The
    Rene> important parts are at the end of this file. One is the
    Rene> specification of this alternative install command =
    Rene> "cmdclass" parameter of the setup function. The other is the
    Rene> "data_files" parameter to the setup function.)

There is support for installing data files, but they get to data
directories. When writing setup.py for biggles, I had the problem,
that a config file had to go to the package directory. All I did was adding

class my_install_data (install_data):
    def finalize_options (self):
                                   ('install_lib', 'install_dir'),
                                   ('root', 'root'),
                                   ('force', 'force'),


    cmdclass = {'install_data': my_install_data},
    data_files = [('biggles', ["src/config.ini"])]

to the setup command line. This got everything to the right place.

Hope this helps.


bhoel@starship.python.net / http://starship.python.net/crew/bhoel/
        It is unlawful to use this email address for unsolicited ads
        (USC Title 47 Sec.227). I will assess a US$500 charge for
        reviewing and deleting each unsolicited ad.