-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
64 lines (51 loc) · 1.86 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
from itertools import chain
from setuptools import setup, find_packages
import fnmatch, os, sys
have_cython = False
try:
from Cython.Distutils import build_ext, Extension
have_cython = True
except ImportError:
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
packages = [pkg for pkg in find_packages('.')]
inc_dirs = ['.']
lib_dirs = []
libs = ['linphone']
try:
sys.argv.remove('debug')
except ValueError:
global_compile_args = ['-O3']
debug_build = False
else:
global_compile_args = ['-O0', '-g', '-ggdb', '-DDEBUG']
debug_build = True
def make_cy_ext(filename, inc_dirs=inc_dirs, lib_dirs=lib_dirs, libs=libs, global_compile_args=global_compile_args, debug_build=debug_build):
modname = filename.replace('.pyx', '').replace('/', '.')
if not have_cython:
filename = '%s.c' % filename[:-4]
return Extension(name=modname, sources=[filename],
include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs,
extra_compile_args=global_compile_args + ['-fPIC'],
extra_link_args=global_compile_args + ['-fPIC'],
pyrex_gdb=debug_build,
cython_directives={'embedsignature': True})
cython_ext = []
for root, dirname, filenames in os.walk('pylinphone'):
for filename in fnmatch.filter(filenames, '*.pyx'):
cython_ext.append(make_cy_ext(os.path.join(root, filename)))
version = file('VERSION').read().strip()
print 'creating "config.pxi"...'
with open(os.path.join(os.path.dirname(__file__), 'pylinphone', 'config.pxi'), 'w') as f:
f.write('DEF ANDROID = %s\n' % (not have_cython))
setup(name='pylinphone',
version=version,
description='Python bindings for liblinphone',
author='Ryan Pessa',
author_email='[email protected]',
url='https://github.com/kived/pylinphone',
packages=packages,
cmdclass={'build_ext': build_ext},
ext_modules=cython_ext,
)