distutils, extensions, and missing headers

Discussion in 'Python' started by Gary Jefferson, Sep 20, 2007.

  1. My setup.py (with extension) seems to work great for build and
    install, but for bdist_rpm, compilation of the extension fails because
    some of the headers needed to build the extension aren't in the bdist
    tarball.

    I've tried adding a 'depends=[]' to the Extension definition with
    these header files present, but they still don't get put in the
    tarball.

    What's the key to getting headers or other [non-python] files included
    in a bdist?

    Thanks,
    Gary
     
    Gary Jefferson, Sep 20, 2007
    #1
    1. Advertising

  2. Gary Jefferson

    Robert Kern Guest

    Gary Jefferson wrote:
    > My setup.py (with extension) seems to work great for build and
    > install, but for bdist_rpm, compilation of the extension fails because
    > some of the headers needed to build the extension aren't in the bdist
    > tarball.
    >
    > I've tried adding a 'depends=[]' to the Extension definition with
    > these header files present, but they still don't get put in the
    > tarball.
    >
    > What's the key to getting headers or other [non-python] files included
    > in a bdist?


    Use the "headers" keyword to setup() to list the header files you want installed.

    For other files, it depends on where you need them to go. If you want the data
    files to be inside the package, you should use the "package_data" keyword. It
    was introduced in Python 2.4, so if you need to support pre-2.4 Pythons, there
    are recipes floating around to do so more nicely.

    http://docs.python.org/dist/node12.html

    For other things (and hopefully, you can live with package data), use "data_files":

    http://docs.python.org/dist/node13.html

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Sep 20, 2007
    #2
    1. Advertising

  3. Robert, thanks for the help!


    On Sep 20, 1:22 am, Robert Kern <> wrote:
    >
    > Use the "headers" keyword to setup() to list the header files you want installed.


    I've tried "headers=['header1.h', 'header2.h']" in setup() as well
    as in Extension(), and neither seem to get the files into the bdist or
    bdist_rpm tarball. Am I doing it wrong? I can't seem to find any
    examples that use this via google.


    > For other files, it depends on where you need them to go. If you want the data
    > files to be inside the package, you should use the "package_data" keyword. It
    > was introduced in Python 2.4, so if you need to support pre-2.4 Pythons, there
    > are recipes floating around to do so more nicely.
    >
    > http://docs.python.org/dist/node12.html
    >
    > For other things (and hopefully, you can live with package data), use "data_files":
    >
    > http://docs.python.org/dist/node13.html


    I also tried using data_files to get the headers included, but can't
    seem to get that to work either. No errors are reported for either
    method.

    Thanks,
    Gary
     
    Gary Jefferson, Sep 20, 2007
    #3
  4. Gary Jefferson

    Robert Kern Guest

    Gary Jefferson wrote:
    > On Sep 20, 1:22 am, Robert Kern <> wrote:
    >> Use the "headers" keyword to setup() to list the header files you want installed.

    >
    > I've tried "headers=['header1.h', 'header2.h']" in setup() as well
    > as in Extension(), and neither seem to get the files into the bdist or
    > bdist_rpm tarball. Am I doing it wrong? I can't seem to find any
    > examples that use this via google.


    You might need an accurate relative path. I'm assuming that you don't actually
    keep header1.h and header2.h in the top-level directory next to the setup.py.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Sep 20, 2007
    #4
  5. On Sep 20, 12:08 pm, Robert Kern <> wrote:
    > Gary Jefferson wrote:
    > > On Sep 20, 1:22 am, Robert Kern <> wrote:
    > >> Use the "headers" keyword to setup() to list theheaderfiles you want installed.

    >
    > > I've tried "headers=['header1.h', 'header2.h']" in setup() as well
    > > as in Extension(), and neither seem to get the files into the bdist or
    > > bdist_rpm tarball. Am I doing it wrong? I can't seem to find any
    > > examples that use this via google.

    >
    > You might need an accurate relative path. I'm assuming that you don't actually
    > keep header1.h and header2.h in the top-level directory next to the setup.py.


    I think I've got it, just needed to do a MANIFEST.in file as in
    http://groups.google.com/group/comp...st&q=distutils header&rnum=1#e329ad06c50cff46
    .. Apparently, the headers arg doesn't affect sdist or bdist.

    With that, the headers get included in the tarballs, and bdist_rpm no
    longer complains about them. Unfortunately, it now complains about
    missing .o files. These .o's are built automatically via 'setup.py
    build', but not via 'setup.py bdist_rpm', for reasons I can't fathom
    at the moment. But if I figure it out, I'll post here.

    Gary
     
    Gary Jefferson, Sep 21, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Sakkis
    Replies:
    2
    Views:
    450
    George Sakkis
    Jun 22, 2005
  2. Replies:
    6
    Views:
    448
    B Mahoney
    Dec 7, 2005
  3. timw.google
    Replies:
    1
    Views:
    552
    Serge Orlov
    May 11, 2006
  4. Replies:
    0
    Views:
    236
  5. Luis Alberto Zarrabeitia Gomez

    distutils, No module named numpy.distutils.fcompiler.conv_template

    Luis Alberto Zarrabeitia Gomez, Mar 30, 2009, in forum: Python
    Replies:
    0
    Views:
    1,344
    Luis Alberto Zarrabeitia Gomez
    Mar 30, 2009
Loading...

Share This Page