forked from ikus060/cbcpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
108 lines (99 loc) · 4.14 KB
/
setup.py
File metadata and controls
108 lines (99 loc) · 4.14 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Coin-or CBC native interface for Python
# Copyright (C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser 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.
import os
import sys
try:
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
except ImportError:
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
# Configure the SWIG build
CBC_DIR = os.environ.get('CBC_DIR', os.path.join('.', 'Cbc'))
if not os.path.isdir(CBC_DIR):
print('CBC_DIR environment variable must be a directory: ' + CBC_DIR)
include_dirs = [os.path.join(CBC_DIR, 'include', 'coin')]
library_dirs = [os.path.join(CBC_DIR, 'lib')]
libraries = ['CbcSolver', 'Cbc', 'Cgl', 'OsiClp', 'OsiCbc', 'Osi', 'Clp', 'CoinUtils']
if os.name == 'nt':
extra_objects = []
libraries = ['lib' + name for name in libraries]
else:
extra_objects = ['%s/lib%s.a' % (library_dirs[0], l) for l in libraries]
libraries = []
swig_opts = ['-c++', '-doxygen']
swig_opts.extend(['-I%s' % i for i in include_dirs])
# Extend build_ext to patch the include files.
class cbc_build_ext(_build_ext):
def _patch_headers(self):
import patch
patches_dir = os.path.join(os.path.dirname(__file__), 'patches')
for f in os.listdir(patches_dir):
f = os.path.join(patches_dir, f)
pset = patch.fromfile(f)
if not pset.apply(strip=2, root=CBC_DIR):
print('fail to patch file: ' + f)
def run(self):
self._patch_headers()
_build_ext.run(self)
# Define project description from README.md
# With python 3.5 we are running into trouble, so let disable this.
long_description_content_type = long_description = None
PY35 = sys.version_info[0:2] == (3, 5)
if not (os.name == 'nt' and PY35):
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as f:
long_description = f.read()
long_description_content_type = 'text/markdown'
setup(
name='cbcpy',
use_scm_version=True,
description='Coin-or CBC native interface for Python',
long_description=long_description,
long_description_content_type=long_description_content_type,
author='Patrik Dufresne',
author_email='info@patrikdufresne.com',
url='https://git.patrikdufresne.com/pdsl/cbcpy',
license="LGPL",
cmdclass={'build_ext': cbc_build_ext},
ext_modules=[Extension(
'_cbcpy',
['cbcpy.i'],
swig_opts=swig_opts,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_objects=extra_objects)],
py_modules=['cbcpy'],
setup_requires=['patch', 'setuptools_scm'],
keywords='coin-or cbc',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
)