[MERGE] Better warnings when pyrex is not available

Martin Pool mbp at sourcefrog.net
Mon Jul 16 23:31:31 BST 2007


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.

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

What I would try is:

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

which is what normally causes the trouble.

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

Well, thoroughly detecting this is pretty hard.  Since we know missing
headers are a common and easily fixed problem maybe an explicit check
for that is ok but beyond that I'd just try it and let it fail if it
does.  Could we catch the failure and give some suggestions?  Or even
just put some faqs in INSTALL?


-- 
Martin



More information about the bazaar mailing list