Skip to content

Commit 0ad1527

Browse files
Updating and simplifying setup file | BROKEN
1 parent 39650f8 commit 0ad1527

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

setup.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,30 @@ class BuildError(Exception):
1919

2020

2121
# setup.py requires relative paths:
22-
# MODULE_DIR = os.path.dirname(os.path.relpath(__file__))
23-
INCLUDE_DIR = 'local/include'
24-
LIB_DIR = 'local/lib'
25-
LIB_DIR64 = 'local/lib64'
22+
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
23+
INCLUDE_DIR = os.path.join(MODULE_DIR, 'local', 'include')
24+
LIB_DIR = os.path.join(MODULE_DIR, 'local', 'lib')
25+
LIB_DIR64 = os.path.join(MODULE_DIR, 'local', 'lib64')
26+
# INCLUDE_DIR = 'local/include'
27+
# LIB_DIR = 'local/lib'
28+
# LIB_DIR64 = 'local/lib64'
2629

2730
# rpath is the path relative to the compiled shared object files (e.g. clib.so, etc)
2831
# which the dynamic linker looks for the linked libraries (e.g. libsundials_*.so) in.
2932
# We need to set it relatively in order for it to be preserved if the parent directory is moved
3033
# hence why it is a 'relative'(r) path. Here the relative path is with respect to
3134
# the fidimag/fidimag/extensions directory.
3235
RPATH = '../../local/lib'
33-
com_link = ['-Wl,-rpath,{},-rpath,{}'.format(str(LIB_DIR), str(LIB_DIR64))]
36+
com_link = ['-Wl,-rpath,{},-rpath,{}'.format(str(LIB_DIR), str(LIB_DIR64)), '-fopenmp']
3437

3538
lib_paths = [LIB_DIR, LIB_DIR64]
3639
# lib_paths = [LIB_DIR, os.path.join(MODULE_DIR, 'native')]
3740
# com_inc = [numpy.get_include(), INCLUDE_DIR, os.path.join(MODULE_DIR, 'native', 'include')]
3841
# com_libs = ['fidimag']
3942
com_libs = ['m', 'fftw3_omp', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial', 'sundials_nvecopenmp', 'blas', 'lapack']
4043
# com_args = []
41-
com_args = ['-O3', '-Wno-unused-function', '-Wall', '-std=c99']
42-
com_args_cpp = ['-O3', '-Wno-unused-function', '-Wall', '-std=c++14']
44+
com_args = ['-O3', '-Wno-cpp', '-Wno-unused-function', '-Wall', '-std=c99', '-fopenmp']
45+
com_args_cpp = ['-O3', '-Wno-unused-function', '-Wall', '-std=c++14', '-fopenmp']
4346

4447
if 'SUNDIALS_INC' in os.environ:
4548
com_inc.append(os.environ['SUNDIALS_INC'])
@@ -64,8 +67,22 @@ class BuildError(Exception):
6467
print(sYellow + f"Compiling module {module}" + sReset)
6568

6669
# src is a Path
67-
incFiles = [str(incF) for incF in src.parent.rglob('*[!pyx]') if incF != src.with_suffix('.c')]
68-
com_inc = [numpy.get_include(), INCLUDE_DIR] + incFiles
70+
srcFiles = [str(sF) for sF in src.parent.glob('*') if sF.is_file()
71+
and sF != src.with_suffix('.c')
72+
and str(sF).endswith(('.c', '.cpp'))
73+
]
74+
75+
com_inc = [numpy.get_include(), INCLUDE_DIR] + [str(src.parent)]
76+
77+
# print(module)
78+
# print(com_inc)
79+
# print(com_libs)
80+
# print(srcFiles)
81+
# print(lib_paths)
82+
# print(com_link)
83+
# print(com_args_compiler)
84+
for s in srcFiles:
85+
print(s)
6986

7087
if 'fmm' in module:
7188
print(sBlue + f'Using cpp for this module' + sReset)
@@ -76,7 +93,7 @@ class BuildError(Exception):
7693
lan = 'c'
7794

7895
ext_modules.append(Extension(module,
79-
sources=[src],
96+
sources=srcFiles,
8097
include_dirs=com_inc,
8198
libraries=com_libs,
8299
library_dirs=lib_paths,

0 commit comments

Comments
 (0)