summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-10-05 20:28:11 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-10-05 20:28:11 +0100
commit3c7236fe73d5fc966a6493f560634c71480aab20 (patch)
tree623deebf3d6e8b9ec116d462194ee856faa5e043
parent36824379c3c504bb8fe6868c159d55a5aa9f3a28 (diff)
downloadslixmpp-3c7236fe73d5fc966a6493f560634c71480aab20.tar.gz
slixmpp-3c7236fe73d5fc966a6493f560634c71480aab20.tar.bz2
slixmpp-3c7236fe73d5fc966a6493f560634c71480aab20.tar.xz
slixmpp-3c7236fe73d5fc966a6493f560634c71480aab20.zip
setup.py: Check for libidn before trying to use Cython.
-rwxr-xr-xsetup.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/setup.py b/setup.py
index ff5bcfb1..47bba942 100755
--- a/setup.py
+++ b/setup.py
@@ -7,20 +7,15 @@
# This software is licensed as described in the README.rst and LICENSE
# file, which you should have received as part of this distribution.
+import os
from pathlib import Path
+from subprocess import call, DEVNULL
+from tempfile import TemporaryFile
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
-try:
- from Cython.Build import cythonize
-except ImportError:
- print('Cython not found, falling back to the slow stringprep module.')
- ext_modules = None
-else:
- ext_modules = cythonize('slixmpp/stringprep.pyx')
-
from run_tests import TestCommand
from slixmpp.version import __version__
@@ -40,6 +35,27 @@ CLASSIFIERS = [
packages = [str(mod.parent) for mod in Path('slixmpp').rglob('__init__.py')]
+def check_include(header):
+ command = [os.environ.get('CC', 'cc'), '-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:
+ return False
+
+ext_modules = None
+if check_include('stringprep.h'):
+ try:
+ from Cython.Build import cythonize
+ except ImportError:
+ print('Cython not found, falling back to the slow stringprep module.')
+ else:
+ ext_modules = cythonize('slixmpp/stringprep.pyx')
+else:
+ print('libidn-dev not found, falling back to the slow stringprep module.')
+
setup(
name="slixmpp",
version=VERSION,