setup: user-friendly error message if Python headers are missing
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Fri, 08 Oct 2010 21:43:21 +0200
changeset 12649 6c0e1aee1b19
parent 12648 8be2d78460ef
child 12650 fed4bb2c8def
setup: user-friendly error message if Python headers are missing
setup.py
--- a/setup.py	Sat Oct 09 07:13:51 2010 -0500
+++ b/setup.py	Fri Oct 08 21:43:21 2010 +0200
@@ -55,6 +55,7 @@
 from distutils.spawn import spawn, find_executable
 from distutils.ccompiler import new_compiler
 from distutils.errors import CCompilerError
+from distutils.sysconfig import get_python_inc
 
 scripts = ['hg']
 if os.name == 'nt':
@@ -246,6 +247,9 @@
                 if ext.name.startswith("mercurial."):
                     self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
             self.distribution.ext_modules = []
+        else:
+            if not os.path.exists(os.path.join(get_python_inc(), 'Python.h')):
+                raise SystemExit("Python headers are required to build Mercurial")
 
     def find_modules(self):
         modules = build_py.find_modules(self)