forked from NGSolve/ngsolve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
94 lines (78 loc) · 2.79 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
import glob
import os
import sys
import netgen.version
import site
from skbuild import setup
import skbuild.cmaker
from subprocess import check_output
from distutils.sysconfig import get_python_lib
import pkg_resources
setup_requires = []
def install_filter(cmake_manifest):
return cmake_manifest
def _patched_parse_manifests(self):
paths = \
glob.glob(os.path.join(skbuild.cmaker.CMAKE_BUILD_DIR(), "ngsolve", "install_manifest*.txt"))
try:
return [self._parse_manifest(path) for path in paths][0]
except IndexError:
return []
# we are using the ngsolve superbuild (to download and build some dependencies)
# patch the parse_manifests function to point to the actual ngsolve cmake project within the superbuild
skbuild.cmaker.CMaker._parse_manifests = _patched_parse_manifests
version = check_output([sys.executable,'tests/get_python_version_string_from_git.py'], cwd='.').decode('utf-8').strip()
py_install_dir = get_python_lib(1,0,'').replace('\\','/')
netgen_name = netgen.config.NETGEN_PYTHON_PACKAGE_NAME
name = netgen_name.replace("netgen-mesher", "ngsolve") # keep -avx2 suffix
netgen_version = netgen.config.NETGEN_VERSION_PYTHON
netgen_dir = os.path.abspath(os.path.join(netgen.__file__, '../'*(len(py_install_dir.split('/'))+2)))
install_requires = [
f'{netgen_name} == {netgen_version}',
]
_cmake_args = [
f'-DNETGEN_DIR={netgen_dir}',
'-DUSE_SUPERBUILD:BOOL=ON',
'-DCMAKE_BUILD_TYPE=Release',
'-DBUILD_FOR_CONDA=ON',
'-DUSE_UMFPACK=OFF',
f'-DNGSOLVE_VERSION_PYTHON={version}',
]
if 'NETGEN_CCACHE' in os.environ:
_cmake_args += ['-DUSE_CCACHE=ON']
if 'darwin' in sys.platform:
pass
elif 'linux' in sys.platform:
_cmake_args += [
'-DUSE_MKL:BOOL=ON',
f'-DMKL_ROOT:PATH={netgen_dir}',
f'-DMKL_LIBRARY:PATH={netgen_dir}/lib/libmkl_rt.so.1',
f'-DMKL_INCLUDE_DIR:PATH={netgen_dir}/include',
]
install_requires.append('mkl == 2021.*')
elif 'win' in sys.platform:
_cmake_args += [
'-DUSE_MKL:BOOL=ON',
f'-DMKL_ROOT:PATH={netgen_dir}',
f'-DMKL_LIBRARY:PATH={netgen_dir}/Library/lib/mkl_rt.lib',
f'-DMKL_INCLUDE_DIR:PATH={netgen_dir}/Library/include',
f'-DNGSOLVE_INSTALL_DIR_TCL:PATH=Scripts',
]
install_requires.append('mkl == 2021.*')
if 'PYDIR' in os.environ:
_cmake_args += [f'-DCMAKE_PREFIX_PATH={os.environ["PYDIR"]}']
setup(
name=name,
version=version,
description="NGSolve",
author='The NGSolve team',
license="LGPL2.1",
packages=['ngsolve'],
package_dir={'ngsolve': 'python'},
install_requires=install_requires,
tests_require=['pytest','scipy','numpy'],
include_package_data=True,
cmake_process_manifest_hook=install_filter,
cmake_args=_cmake_args,
setup_requires=setup_requires
)