-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
87 lines (80 loc) · 3.19 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
# Description: Setup file
#
# Installation of package: python -m pip install .
#
# Copyright (c) 2022 ETH Zurich, Christian R. Steger
# MIT License
# Load modules
import os
import sys
from distutils.core import setup
from Cython.Distutils import build_ext
from distutils.extension import Extension
import numpy as np
# -----------------------------------------------------------------------------
# Operating system dependent settings
# -----------------------------------------------------------------------------
path_lib_conda = os.environ["CONDA_PREFIX"] + "/lib/"
if sys.platform in ["linux", "linux2"]:
print("Operating system: Linux")
lib_end = ".so"
compiler = "gcc"
extra_compile_args_cython = ["-O3", "-ffast-math", "-fopenmp"]
extra_compile_args_cpp = ["-O3"]
elif sys.platform in ["darwin"]:
print("Operating system: Mac OS X")
lib_end = ".dylib"
compiler = "clang"
extra_compile_args_cython = ["-O3", "-ffast-math",
"-Wl,-rpath," + path_lib_conda,
"-L" + path_lib_conda, "-fopenmp"]
extra_compile_args_cpp = ["-O3", "-std=c++11"]
elif sys.platform in ["win32"]:
print("Operating system: Windows")
print("Warning: Package not yet tested for Windows")
else:
raise ValueError("Unsupported operating system")
libraries_cython = ["m", "pthread"]
include_dirs_cpp = [np.get_include()]
extra_objects_cpp = [path_lib_conda + i + lib_end for i in ["libembree3"]]
# -----------------------------------------------------------------------------
# Compile Cython/C++ code
# -----------------------------------------------------------------------------
os.environ["CC"] = compiler
ext_modules = [
Extension("horayzon.transform",
["horayzon/transform.pyx"],
libraries=libraries_cython,
extra_compile_args=extra_compile_args_cython,
extra_link_args=["-fopenmp"],
include_dirs=[np.get_include()]),
Extension("horayzon.direction",
["horayzon/direction.pyx"],
libraries=libraries_cython,
extra_compile_args=extra_compile_args_cython,
extra_link_args=["-fopenmp"],
include_dirs=[np.get_include()]),
Extension("horayzon.topo_param",
["horayzon/topo_param.pyx"],
libraries=libraries_cython,
extra_compile_args=extra_compile_args_cython,
extra_link_args=["-fopenmp"],
include_dirs=[np.get_include()]),
Extension("horayzon.horizon",
sources=["horayzon/horizon.pyx", "horayzon/horizon_comp.cpp"],
include_dirs=include_dirs_cpp,
extra_objects=extra_objects_cpp,
extra_compile_args=extra_compile_args_cpp,
language="c++"),
Extension("horayzon.shadow",
sources=["horayzon/shadow.pyx", "horayzon/shadow_comp.cpp"],
include_dirs=include_dirs_cpp,
extra_objects=extra_objects_cpp,
extra_compile_args=extra_compile_args_cpp,
language="c++")
]
setup(name="horayzon",
version="1.2",
packages=["horayzon"],
cmdclass={"build_ext": build_ext},
ext_modules=ext_modules)