/
setup.py
133 lines (122 loc) · 3.91 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""Setup script for pycddlib."""
# pycddlib is a Python wrapper for Komei Fukuda's cddlib
# Copyright (c) 2008, Matthias Troffaes
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
classifiers = """\
Development Status :: 4 - Beta
License :: OSI Approved :: GNU General Public License (GPL)
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Mathematics
Programming Language :: C
Programming Language :: Cython
Programming Language :: Python
Programming Language :: Python :: 3
Operating System :: OS Independent"""
import sys
import os.path
from setuptools import setup
from setuptools.extension import Extension
define_macros = [('GMPRATIONAL', None)]
libraries = ['mpir' if (sys.platform == 'win32') else 'gmp']
# get version from Cython file (without requiring extensions to be compiled!)
for line in open('cdd.pyx'):
if line.startswith("__version__"):
version = line[line.find('"')+1:line.rfind('"')]
break
else:
raise RuntimeError("failed to extract version from cdd.pyx")
# get documentation from README.rst file
doclines = open('README.rst').read().split('\n')
cdd_dir = 'cddlib/lib-src'
cdd_sources = [
'{0}/{1}'.format(cdd_dir, srcfile) for srcfile in [
'cddcore.c',
'cddio.c',
'cddlib.c',
'cddlp.c',
'cddmp.c',
'cddproj.c',
'setoper.c',
]
]
cdd_headers = [
'{0}/{1}'.format(cdd_dir, hdrfile) for hdrfile in [
'cdd.h',
'cddmp.h',
'cddtypes.h',
'setoper.h',
]
]
cddgmp_sources = cdd_sources + [
'{0}/{1}'.format(cdd_dir, srcfile) for srcfile in [
'cddcore_f.c',
'cddio_f.c',
'cddlib_f.c',
'cddlp_f.c',
'cddmp_f.c',
'cddproj_f.c',
]
]
cddgmp_headers = cdd_headers + [
'{0}/{1}'.format(cdd_dir, hdrfile) for hdrfile in [
'cdd_f.h',
'cddmp_f.h',
'cddtypes_f.h',
]
]
# generate include files from template
cddlib_pxi_in = open("cddlib.pxi.in", "r").read()
cddlib_pxi = open("cddlib.pxi", "w")
cddlib_pxi.write(
cddlib_pxi_in
.replace("@cddhdr@", "cdd.h")
.replace("@dd@", "dd")
.replace("@mytype@", "mytype"))
cddlib_pxi.close()
cddlib_f_pxi = open("cddlib_f.pxi", "w")
cddlib_f_pxi.write(
cddlib_pxi_in
.replace("@cddhdr@", "cdd_f.h")
.replace("@dd@", "ddf")
.replace("@mytype@", "myfloat"))
cddlib_f_pxi.close()
setup(
name="pycddlib",
version=version,
ext_modules=[
Extension("cdd",
["cdd.pyx"] + cddgmp_sources,
include_dirs=[cdd_dir],
depends=cddgmp_headers,
define_macros=define_macros,
libraries=libraries,
),
],
author="Matthias Troffaes",
author_email="matthias.troffaes@gmail.com",
license="GPL",
keywords="convex, polyhedron, linear programming, double description method",
platforms="any",
description=doclines[0],
long_description="\n".join(doclines[2:]),
long_description_content_type="text/x-rst",
url="http://pypi.python.org/pypi/pycddlib",
classifiers=classifiers.split('\n'),
setup_requires=[
# setuptools 18.0 properly handles Cython extensions.
'setuptools>=18.0', 'Cython>=3.0.0'],
python_requires='>=3.7',
)