-
Notifications
You must be signed in to change notification settings - Fork 4
/
conf.py
84 lines (74 loc) · 2.32 KB
/
conf.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
# -*- coding: utf-8 -*-
import os
import glob
from os.path import join
from setuptools import Extension
from Cython.Build import cythonize
try:
import mpi4py
except (ModuleNotFoundError, ImportError):
mpi4py = None
def is_debug():
flag = os.environ.get("MGMETIS_DEBUG", None)
if flag is None:
return False
return flag.lower() not in ("0", "no", "off", "false")
debug = is_debug()
_metis_incs = [
"mgmetis",
join("mgmetis", "src", "metis", "GKlib"),
join("mgmetis", "src", "metis", "include"),
join("mgmetis", "src", "metis", "libmetis"),
]
_metis_src = []
_metis_src += glob.glob(join("mgmetis", "src", "metis", "libmetis", "*.c"))
_metis_src += glob.glob(join("mgmetis", "src", "metis", "GKlib", "*.c"))
exts = []
exts += [
Extension(
"mgmetis._cython.metis",
[join("mgmetis", "_cython", "metis.pyx")] + _metis_src,
include_dirs=_metis_incs,
),
Extension(
"mgmetis._cython.metis64",
[join("mgmetis", "_cython", "metis64.pyx")] + _metis_src,
include_dirs=_metis_incs,
define_macros=[("IDXTYPEWIDTH", "64")],
),
]
# check MPI support
if mpi4py is not None:
import sysconfig
# NOTE: get rid of libmetis
_parmetis_incs = _metis_incs[:-1] + [
join("mgmetis", "src", "include"),
join("mgmetis", "src", "libparmetis"),
mpi4py.get_include(),
]
_parmetis_src = glob.glob(join("mgmetis", "src", "libparmetis", "*.c"))
# NOTE: library linking is resolved in build_ext
exts += [
Extension(
"mgmetis._cython.parmetis",
[join("mgmetis", "_cython", "parmetis.pyx")] + _parmetis_src,
include_dirs=_parmetis_incs,
),
Extension(
"mgmetis._cython.parmetis64",
[join("mgmetis", "_cython", "parmetis64.pyx")] + _parmetis_src,
include_dirs=_parmetis_incs,
define_macros=[("IDXTYPEWIDTH", "64")],
),
]
# set compiler
os.environ["CC"] = mpi4py.get_config()["mpicc"]
# set linker to mpi
os.environ["LDSHARED"] = " ".join(
[mpi4py.get_config()["mpicc"]]
+ sysconfig.get_config_var("LDSHARED").split()[1:]
)
_opts = {"language_level": 3}
if not debug:
_opts.update({"wraparound": False, "boundscheck": False})
exts = cythonize(exts, compiler_directives=_opts)