-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup_manual.py
100 lines (90 loc) · 3.79 KB
/
setup_manual.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
# Description: Setup file for 'manual' installation (this method works for
# instance with 'pip')
#
# Installation of package: mv setup_manual.py setup.py
# 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
# -----------------------------------------------------------------------------
# Manual settings
# -----------------------------------------------------------------------------
# Paths for Intel Embree and Threading Building Blocks (TBB)
path_include = ["/opt/local/include/"]
path_lib = ["/opt/local/lib/libembree3"] # without file ending
# - depending on defined library paths and loaded modules, it might be
# necessary to add paths to further libraries like 'libimf' and 'libtbb'
# - in case a library is not found during execution of HORAYZON, it has to be
# defined before running Python/HORAYZON via 'LD_LIBRARY_PATH'.
# Compiler
compiler = "clang++" # (like gcc, clang, clang++, default)
# "default": compiler is not redefined
# -----------------------------------------------------------------------------
# Operating system dependent settings
# -----------------------------------------------------------------------------
if sys.platform in ["linux", "linux2"]:
print("Operating system: Linux")
lib_end = ".so"
extra_compile_args_cpp = ["-O3"]
elif sys.platform in ["darwin"]:
print("Operating system: Mac OS X")
lib_end = ".dylib"
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")
extra_compile_args_cython = ["-O3", "-ffast-math", "-fopenmp"]
libraries_cython = ["m", "pthread"]
include_dirs_cpp = [np.get_include()] + path_include
extra_objects_cpp = [i + lib_end for i in path_lib]
# -----------------------------------------------------------------------------
# Compile Cython/C++ code
# -----------------------------------------------------------------------------
if compiler != "default":
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)