-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
64 lines (57 loc) · 1.9 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
from setuptools import Extension, setup, find_packages
import os
import sys
import os.path
from Cython.Build import cythonize
import shutil
import subprocess
def get_env_or_exit(name):
try:
value = os.environ[name]
except KeyError:
sys.exit('Environment variable %s not set. Aborting' % name)
return value
# Removed [-1] from the end
PDC_DIR = os.path.join(*os.path.split(get_env_or_exit("PDC_DIR")))
MERCURY_DIR = get_env_or_exit("MERCURY_DIR")
path = shutil.which('mpicc')
if not path:
print("mpicc not found on PATH. Attempting to compile without MPI support.")
mpi_build_args = []
mpi_link_args = []
elif subprocess.run(['mpicc', '-compile_info']).returncode == 0:
print("Compiling with mpich")
mpi_build_args = os.popen('mpicc -compile_info').read().strip().split()[1:]
mpi_link_args = os.popen('mpicc -link_info').read().strip().split()[1:]
elif subprocess.run(['mpicc', '--showme:compile']).returncode == 0:
print("Compiling with openmpi")
mpi_build_args = os.popen('mpicc --showme:compile').read().strip().split()
mpi_link_args = os.popen('mpicc --showme:link').read().strip().split()
else:
print("mpicc is neither openmpi or mpich. Attempting to compile without MPI support.")
mpi_build_args = []
mpi_link_args = []
# Removed "install"
extension = Extension(
"*",
["pdc/*.pyx"],
libraries=["pdc"],
library_dirs=[os.path.join(PDC_DIR, "lib")],
include_dirs=[
os.path.join(PDC_DIR, "include"),
os.path.join(MERCURY_DIR, "include"),
],
extra_compile_args=mpi_build_args,
extra_link_args=mpi_link_args
)
#extension.cython_directives = {'language_level': "3"}
version_file = open('version.txt', 'r')
version = version_file.read().strip()
version_file.close()
setup(
name='PDCpy',
version=version,
include_package_data=True,
ext_modules=cythonize(extension, language_level=3),
zip_safe=False,
)