-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
executable file
·78 lines (63 loc) · 2.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import sys, os
import warnings
from setuptools import setup, Extension
try:
from Cython.Build import cythonize
HAVE_CYTHON = True
except ImportError as e:
HAVE_CYTHON = False
warnings.warn('{}'.format(e))
# Determine usage of Cython
USE_CYTHON = HAVE_CYTHON
if 'USE_CYTHON' in os.environ:
USE_CYTHON = os.environ['USE_CYTHON'].lower() in ('1', 'yes')
if USE_CYTHON and not HAVE_CYTHON:
sys.stderr.write('Cython was not found!\n')
sys.exit(-1)
# Add include dirs specified by environment variables
include_dirs = []
if 'GMP_INCLUDE_DIR' in os.environ:
include_dirs.append(os.environ['GMP_INCLUDE_DIR'])
if 'QSOPTEX_INCLUDE_DIR' in os.environ:
include_dirs.append(os.environ['QSOPTEX_INCLUDE_DIR'])
# Add library dirs specified by environment variables
library_dirs = []
if 'GMP_LIBRARY_DIR' in os.environ:
library_dirs.append(os.environ['GMP_LIBRARY_DIR'])
if 'QSOPTEX_LIBRARY_DIR' in os.environ:
library_dirs.append(os.environ['QSOPTEX_LIBRARY_DIR'])
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [Extension('qsoptex', ['qsoptex'+ext],
include_dirs=include_dirs,
libraries=['gmp', 'qsopt_ex'],
library_dirs=library_dirs)]
if USE_CYTHON:
extensions = cythonize(extensions, include_path=include_dirs)
# Read long description
with open('README.rst') as f:
long_description = f.read()
setup(
name='python-qsoptex',
version='0.5',
license='GPLv3+',
url='https://github.com/jonls/python-qsoptex',
author='Jon Lund Steffensen',
author_email='[email protected]',
description='Python bindings for QSopt_ex, an exact linear programming solver',
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Programming Language :: Cython',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Topic :: Scientific/Engineering :: Mathematics'
],
install_requires=[
'six'
],
test_suite='test_qsoptex',
ext_modules = extensions
)