-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
60 lines (51 loc) · 1.84 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
import os
from ctypes import util
from Cython.Build import cythonize
from setuptools import setup
from setuptools.extension import Extension
# enable test coverage tracing if CYTHON_TRACE is set to a non-zero value
CYTHON_TRACE = int(os.getenv("CYTHON_TRACE") in ("1", "True"))
libraries = ["libscip"] if os.name == "nt" else ["scip"]
include_dirs = ["ilpy/impl"]
library_dirs = []
compile_args = ["-O3", "-DHAVE_SCIP"]
if os.name == "nt":
compile_args.append("/std:c++17")
else:
compile_args.append("-std=c++17")
# include conda environment windows include/lib if it exists
# this will be done automatically by conda build, but is useful if someone
# tries to build this directly with pip install in a conda environment
if os.name == "nt" and "CONDA_PREFIX" in os.environ:
include_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "include"))
library_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "lib"))
# look for various gurobi versions, which are annoyingly
# suffixed with the version number, and wildcards don't work
for v in range(80, 200):
GUROBI_LIB = f"libgurobi{v}" if os.name == "nt" else f"gurobi{v}"
if (gurolib := util.find_library(GUROBI_LIB)) is not None:
print("FOUND GUROBI library: ", gurolib)
libraries.append(GUROBI_LIB)
compile_args.append("-DHAVE_GUROBI")
break
else:
print("WARNING: GUROBI library not found")
wrapper = Extension(
"ilpy.wrapper",
sources=["ilpy/wrapper.pyx"],
extra_compile_args=compile_args,
include_dirs=include_dirs,
libraries=libraries,
library_dirs=library_dirs,
language="c++",
define_macros=[("CYTHON_TRACE", CYTHON_TRACE)],
)
setup(
ext_modules=cythonize(
[wrapper],
compiler_directives={
"linetrace": CYTHON_TRACE,
"language_level": "3",
},
)
)