forked from pycalphad/pycalphad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
56 lines (49 loc) · 2.13 KB
/
Copy pathsetup.py
File metadata and controls
56 lines (49 loc) · 2.13 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
import os
import numpy as np
from Cython.Build import cythonize
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
CYTHON_COMPILER_DIRECTIVES = {
"language_level": 3,
}
CYTHON_DEFINE_MACROS = []
if os.getenv('CYTHON_COVERAGE', False):
CYTHON_COMPILER_DIRECTIVES["linetrace"] = True
CYTHON_DEFINE_MACROS.append(('CYTHON_TRACE_NOGIL', '1'))
CYTHON_EXTENSION_INCLUDES = ['.', np.get_include()]
CYTHON_EXTENSION_MODULES = [
Extension('pycalphad.core.hyperplane', sources=['pycalphad/core/hyperplane.pyx'], define_macros=CYTHON_DEFINE_MACROS),
Extension('pycalphad.core.eqsolver', sources=['pycalphad/core/eqsolver.pyx'], define_macros=CYTHON_DEFINE_MACROS),
Extension('pycalphad.core.phase_rec', sources=['pycalphad/core/phase_rec.pyx'], define_macros=CYTHON_DEFINE_MACROS),
Extension('pycalphad.core.composition_set', sources=['pycalphad/core/composition_set.pyx'], define_macros=CYTHON_DEFINE_MACROS),
Extension('pycalphad.core.minimizer', sources=['pycalphad/core/minimizer.pyx'], define_macros=CYTHON_DEFINE_MACROS),
]
# https://cython.readthedocs.io/en/latest/src/tutorial/appendix.html
mingw32_link_args = [
"-static-libgcc",
"-static-libstdc++",
"-Wl,-Bstatic,--whole-archive",
"-lwinpthread",
"-Wl,--no-whole-archive",
]
class Build(build_ext):
def build_extensions(self):
if self.compiler.compiler_type == "mingw32":
for ext in self.extensions:
ext.extra_link_args = mingw32_link_args
return super().build_extensions()
setup(
ext_modules=cythonize(
CYTHON_EXTENSION_MODULES,
include_path=CYTHON_EXTENSION_INCLUDES,
compiler_directives=CYTHON_COMPILER_DIRECTIVES,
),
cmdclass={"build_ext": Build},
package_data={
'pycalphad.core': ['*.pxd'] + (['*.pyx', '*.c', '*.h', '*.cpp', '*.hpp'] if os.getenv('CYTHON_COVERAGE', False) else []),
'pycalphad.tests.databases': ['*'],
},
# This include is for the compiler to find the *.h files during the build_ext phase
# the include must contain a symengine directory with header files
include_dirs=[np.get_include()],
)