summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-03-31 02:01:03 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-03-31 02:01:03 +0200
commit5c45252a2bdea99ff0d802edde84eb35339bcbd7 (patch)
tree3313fa0140cdbc4223aa16120de96036385ce080
parent4e5a1c6581953ab9b510704f6bf8c7ecbc983fe8 (diff)
downloadpoezio-5c45252a2bdea99ff0d802edde84eb35339bcbd7.tar.gz
poezio-5c45252a2bdea99ff0d802edde84eb35339bcbd7.tar.bz2
poezio-5c45252a2bdea99ff0d802edde84eb35339bcbd7.tar.xz
poezio-5c45252a2bdea99ff0d802edde84eb35339bcbd7.zip
Abort if Python.h isn’t found.
Fixes #3254.
-rwxr-xr-xsetup.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 08e26164..c47fbf8d 100755
--- a/setup.py
+++ b/setup.py
@@ -36,6 +36,30 @@ def find_doc(before, path):
_files.append((join(before, relative_root), files_path))
return _files
+def check_include(library_name, header):
+ command = [os.environ.get('PKG_CONFIG', 'pkg-config'), '--cflags', library_name]
+ try:
+ cflags = check_output(command).decode('utf-8').split()
+ except FileNotFoundError:
+ print('pkg-config not found.')
+ return False
+ except CalledProcessError:
+ # pkg-config already prints the missing libraries on stderr.
+ return False
+ command = [os.environ.get('CC', 'cc')] + cflags + ['-E', '-']
+ with TemporaryFile('w+') as c_file:
+ c_file.write('#include <%s>' % header)
+ c_file.seek(0)
+ try:
+ return call(command, stdin=c_file, stdout=DEVNULL, stderr=DEVNULL) == 0
+ except FileNotFoundError:
+ print('%s headers not found.' % library_name)
+ return False
+
+if not check_include('python3', 'Python.h'):
+ import sys
+ sys.exit(0)
+
module_poopt = Extension('poezio.poopt',
extra_compile_args=['-Wno-declaration-after-statement'],
sources=['poezio/pooptmodule.c'])