distutils, extensions, and missing headers

G

Gary Jefferson

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
 
R

Robert Kern

Gary said:
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
 
G

Gary Jefferson

Robert, thanks for the help!


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
 
R

Robert Kern

Gary said:
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
 
G

Gary Jefferson

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top