summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-12-25 13:28:51 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-12-25 13:28:51 +0100
commit829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3 (patch)
tree00c0217ba5f0b9915c7a4a69d543bdc0e24c3a9b /setup.py
parentfb3ac78bf98a5ca3062d6127e295b601b9503027 (diff)
downloadslixmpp-829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3.tar.gz
slixmpp-829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3.tar.bz2
slixmpp-829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3.tar.xz
slixmpp-829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3.zip
Test more things before trying to build our stringprep module.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/setup.py b/setup.py
index 47bba942..c545b3df 100755
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@
import os
from pathlib import Path
-from subprocess import call, DEVNULL
+from subprocess import call, DEVNULL, check_output, CalledProcessError
from tempfile import TemporaryFile
try:
from setuptools import setup
@@ -35,18 +35,31 @@ CLASSIFIERS = [
packages = [str(mod.parent) for mod in Path('slixmpp').rglob('__init__.py')]
-def check_include(header):
- command = [os.environ.get('CC', 'cc'), '-E', '-']
+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
+HAS_PYTHON_HEADERS = check_include('python3', 'Python.h')
+HAS_STRINGPREP_HEADERS = check_include('libidn', 'stringprep.h')
+
ext_modules = None
-if check_include('stringprep.h'):
+if HAS_PYTHON_HEADERS and HAS_STRINGPREP_HEADERS:
try:
from Cython.Build import cythonize
except ImportError:
@@ -54,7 +67,7 @@ if check_include('stringprep.h'):
else:
ext_modules = cythonize('slixmpp/stringprep.pyx')
else:
- print('libidn-dev not found, falling back to the slow stringprep module.')
+ print('Falling back to the slow stringprep module.')
setup(
name="slixmpp",