forked from erfanoabdi/gbinder-python
-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
40 lines (33 loc) · 1.21 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys, subprocess
from distutils.core import setup, Extension
def pkgconfig(package, kw):
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
output = subprocess.getoutput(
'pkg-config --cflags --libs {}'.format(package))
for token in output.strip().split():
kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
return kw
USE_CYTHON = False
if "--cython" in sys.argv:
sys.argv.remove("--cython")
USE_CYTHON = True
file_ext = ".pyx" if USE_CYTHON else ".c"
extension_kwargs = { 'sources': ["gbinder" + file_ext] }
extension_kwargs = pkgconfig('libgbinder', extension_kwargs)
if None in extension_kwargs:
del extension_kwargs[None]
extensions = [Extension('gbinder', **extension_kwargs)]
if USE_CYTHON:
from Cython.Build import cythonize
extensions = cythonize(extensions, compiler_directives={
'language_level': "3"})
setup(
name="gbinder-python",
description="""Cython extension module for C++ gbinder functions""",
version="1.1.2",
author="Erfan Abdi",
author_email="[email protected]",
url="https://github.com/erfanoabdi/gbinder-python",
license="GPL3",
ext_modules=extensions
)