forked from firedrakeproject/firedrake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
102 lines (91 loc) · 3.99 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
95
96
97
98
99
100
101
102
from distutils.core import setup
from distutils.extension import Extension
from glob import glob
from os import environ as env, path
import sys
import numpy as np
import petsc4py
def get_petsc_dir():
try:
petsc_arch = env.get('PETSC_ARCH', '')
petsc_dir = env['PETSC_DIR']
if petsc_arch:
return (petsc_dir, path.join(petsc_dir, petsc_arch))
return (petsc_dir,)
except KeyError:
try:
import petsc
return (petsc.get_petsc_dir(), )
except ImportError:
sys.exit("""Error: Could not find PETSc library.
Set the environment variable PETSC_DIR to your local PETSc base
directory or install PETSc from PyPI as described in the manual:
http://firedrakeproject.org/obtaining_pyop2.html#petsc
""")
import versioneer
versioneer.versionfile_source = 'firedrake/_version.py'
versioneer.versionfile_build = 'firedrake/_version.py'
versioneer.tag_prefix = 'v'
versioneer.parentdir_prefix = 'firedrake-'
versioneer.VCS = "git"
cmdclass = versioneer.get_cmdclass()
try:
from Cython.Distutils import build_ext
cmdclass['build_ext'] = build_ext
dmplex_sources = ["firedrake/dmplex.pyx"]
spatialindex_sources = ["firedrake/spatialindex.pyx"]
h5iface_sources = ["firedrake/hdf5interface.pyx"]
mg_sources = ["firedrake/mg/impl.pyx"]
except ImportError:
# No cython, dmplex.c must be generated in distributions.
dmplex_sources = ["firedrake/dmplex.c"]
spatialindex_sources = ["firedrake/spatialindex.cpp"]
h5iface_sources = ["firedrake/hdf5interface.c"]
mg_sources = ["firedrake/mg/impl.c"]
if 'CC' not in env:
env['CC'] = "mpicc"
if 'CXX' not in env:
env['CXX'] = "mpic++"
petsc_dirs = get_petsc_dir()
include_dirs = [np.get_include(), petsc4py.get_include()]
include_dirs += ["%s/include" % d for d in petsc_dirs]
setup(name='firedrake',
version=versioneer.get_version(),
cmdclass=cmdclass,
description="""Firedrake is an automated system for the portable solution
of partial differential equations using the finite element method
(FEM)""",
author="Imperial College London and others",
author_email="[email protected]",
url="http://firedrakeproject.org",
packages=["firedrake", "firedrake.mg"],
package_data={"firedrake": ["firedrake_geometry.h",
"evaluate.h",
"locate.cpp"]},
scripts=glob('scripts/*'),
ext_modules=[Extension('firedrake.dmplex',
sources=dmplex_sources,
include_dirs=include_dirs,
libraries=["petsc"],
extra_link_args=["-L%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % sys.prefix]),
Extension('firedrake.hdf5interface',
sources=h5iface_sources,
include_dirs=include_dirs,
libraries=["petsc"],
extra_link_args=["-L%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % sys.prefix]),
Extension('firedrake.spatialindex',
sources=spatialindex_sources,
include_dirs=[np.get_include()],
libraries=["spatialindex"],
language="c++"),
Extension('firedrake.mg.impl',
sources=mg_sources,
include_dirs=include_dirs,
libraries=["petsc"],
extra_link_args=["-L%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % d for d in petsc_dirs] +
["-Wl,-rpath,%s/lib" % sys.prefix])])