[MERGE] Better warnings when pyrex is not available

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Jul 17 08:53:42 BST 2007


>>>>> "mbp" == Martin Pool <mbp at sourcefrog.net> writes:

    mbp> On 7/17/07, Vincent Ladeuil <v.ladeuil+lp at free.fr> wrote:
    john> Do you know a way to detect if python-dev is installed
    john> for your machine?
    >> 
    >> I encountered the problem on both edgy and feisty.
    >> 
    >> I didn't search too far though, the compilation failed on
    >> Python.h not found. So I tried python-dev and that worked on both.
    >> 
    >> What I thought may be possible was a simple
    >> 
    >> ,----
    >> | #include "Python.h"
    >> |
    >> | int main(int argc, char *argv[])
    >> | { return 0 ; }
    >> `----
    >> 
    >> If it can't compile, python-dev or its equivalent is missing.

    mbp> The thing is, Python.h is not guaranteed to be on your path, or at
    mbp> least that's not guaranteed to be one that matches your version of
    mbp> python or that will do anything useful.

    mbp> What I would try is:

    mbp> from distutils.sysconfig import get_python_inc
    mbp> if not isdir(get_python_inc()):
    mbp>  warn()

    mbp> which is what normally causes the trouble.

Wow ! A pure python solution is possible, great :) Silly me, of
course it has to allow extensions building (which is the point
vila, really :)

But doing:

if not isfile(get_python_inc() + '/Python.h'):
   warn()

gives better results after some quick testing under OSX
(python-2.5 installed from python.org), edgy, feisty (with both
python-dev installed or not), Centos4.5 (i.e. RHEL 4.5 default
install (python-2.3 arf)) and Solaris 10 (python-2.4 installed
from sources).

    >> Speaking of compiling, a compiler and a linker are required too...

    mbp> Well, thoroughly detecting this is pretty hard.

Now that you gave me distutils.sysconfig... 

get_config_vars seems to mention everything that was used to
build the installed python and everything that should be used to
build extensions.


    mbp> Since we know missing headers are a common and easily
    mbp> fixed problem maybe an explicit check for that is ok but
    mbp> beyond that I'd just try it and let it fail if it does.

Agreed.

    mbp> Could we catch the failure and give some suggestions?
    mbp> Or even just put some faqs in INSTALL?

I think so. HACKING comes to mind too.

  Vincent



More information about the bazaar mailing list