]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
setup.py: support compilation with Cython 327/head
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 30 Jul 2018 14:25:40 +0000 (16:25 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Mon, 30 Jul 2018 14:25:40 +0000 (16:25 +0200)
To provide a slight perfomrance boost, the Python code can be
compiled with Cython. Provide --cython-compile to setup.py, or
when usng pip:

pip install dnspython --install-option="--cython-compile"

setup.py

index b4511fa37253e374fa14e9593ab043ba30767c63..5f8427db3f66abdd83c4c6811bf91a8acfd33302 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,15 @@ from setuptools import setup
 
 version = '1.16.0'
 
+try:
+    sys.argv.remove("--cython-compile")
+except ValueError:
+    compile_cython = False
+else:
+    compile_cython = True
+    from Cython.Build import cythonize
+    ext_modules = cythonize(['dns/*.py', 'dns/rdtypes/*.py', 'dns/rdtypes/*/*.py'])
+
 kwargs = {
     'name' : 'dnspython',
     'version' : version,
@@ -64,6 +73,8 @@ direct manipulation of DNS zones, messages, names, and records.""",
         'IDNA': ['idna>=2.1'],
         'DNSSEC': ['pycrypto>=2.6.1', 'ecdsa>=0.13'],
         },
+    'ext_modules': ext_modules if compile_cython else None,
+    'zip_safe': False if compile_cython else None,
     }
 
 setup(**kwargs)