forked from princeton-vl/infinigen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·120 lines (101 loc) · 3.53 KB
/
install.sh
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
if ! command -v wget &> /dev/null
then
echo "wget could not be found, please 'sudo apt-get install wget' or 'brew install wget'"
exit
fi
OS=$(uname -s)
ARCH=$(uname -m)
if [ "${OS}" = "Linux" ]; then
BLENDER_WGET_LINK='https://download.blender.org/release/Blender3.3/blender-3.3.1-linux-x64.tar.xz'
BLENDER_WGET_FILE='blender.tar.xz'
BLENDER_UNTAR_DIR='blender-3.3.1-linux-x64'
BLENDER_DIR='blender'
BLENDER_PYTHON="${BLENDER_DIR}/3.3/python/bin/python3.10"
BLENDER_INCLUDE="${BLENDER_DIR}/3.3/python/include/python3.10"
BLENDER_PACKAGES="${BLENDER_DIR}/3.3/python/lib/python3.10/site-packages"
NURBS_SCRIPT="setup_linux.py"
elif [ "${OS}" = "Darwin" ]; then
if [ "${ARCH}" = "arm64" ]; then
BLENDER_WGET_LINK='https://download.blender.org/release/Blender3.3/blender-3.3.1-macos-arm64.dmg'
NURBS_SCRIPT="setup_macos_as.py"
else
BLENDER_WGET_LINK='https://download.blender.org/release/Blender3.3/blender-3.3.1-macos-x64.dmg'
NURBS_SCRIPT="setup_macos.py"
fi
if [ "${ARCH}" = "arm64" ]; then
HOMEBREW_PREFIX="/opt/homebrew/"
else
HOMEBREW_PREFIX="/usr/local"
fi
BLENDER_WGET_FILE='blender.dmg'
BLENDER_VOLM='/Volumes/Blender'
BLENDER_DIR='./Blender.app'
BLENDER_PYTHON="${BLENDER_DIR}/Contents/Resources/3.3/python/bin/python3.10"
BLENDER_INCLUDE="${BLENDER_DIR}/Contents/Resources/3.3/python/include/python3.10"
BLENDER_PACKAGES="${BLENDER_DIR}/Contents/Resources/3.3/python/lib/python3.10/site-packages"
export CC="${HOMEBREW_PREFIX}/opt/llvm/bin/clang"
export CPATH="${HOMEBREW_PREFIX}/include:${CPATH}"
else
echo "Unsupported OS"
exit -1
fi
REQUIREMENTS_PATH='./requirements.txt'
PYTHON_WGET_LINK='https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz'
PYTHON_WGET_FILE='Python-3.10.2.tgz'
PYTHON_DIR='Python-3.10.2'
git submodule init
git submodule update
if [ ! -d "${BLENDER_DIR}" ]; then
# Download Blender
wget -O "${BLENDER_WGET_FILE}" "${BLENDER_WGET_LINK}"
# Unzip Blender
if [ "${OS}" = "Darwin" ]; then
hdiutil attach "${BLENDER_WGET_FILE}"
cp -r "${BLENDER_VOLM}/Blender.app" "${BLENDER_DIR}"
hdiutil detach "${BLENDER_VOLM}"
else
tar -xf "${BLENDER_WGET_FILE}"
mv "${BLENDER_UNTAR_DIR}" "${BLENDER_DIR}"
fi
rm "${BLENDER_WGET_FILE}"
fi
# Install llvm for MacOS
if [ "${OS}" = "Darwin" ]; then
brew install llvm open-mpi libomp glm glew
fi
# Install Conda dependencies
pip install -r "${REQUIREMENTS_PATH}"
pip install fake-bpy-module-latest
if [ ! -d "${PYTHON_DIR}" ]; then
# Install Python include file
wget -O "${PYTHON_WGET_FILE}" "${PYTHON_WGET_LINK}"
tar -xf "${PYTHON_WGET_FILE}"
rm "${PYTHON_WGET_FILE}"
fi
cp -r "${PYTHON_DIR}/Include/"* "${BLENDER_INCLUDE}"
# Install Blender dependencies
"${BLENDER_PYTHON}" -m ensurepip
CFLAGS="-I$(realpath ${BLENDER_INCLUDE}) ${CFLAGS}" "${BLENDER_PYTHON}" -m pip install -r "${REQUIREMENTS_PATH}"
# Build terrain
rm -rf ${BLENDER_PACKAGES}/terrain-*
rm -rf *.egg-info
rm -rf __pycache__
rm -rf ./worldgen/terrain/build
cd ./worldgen/terrain
if [ -f "/usr/local/cuda/bin/nvcc" ]; then
USE_CUDA=1 bash install_terrain.sh
else
USE_CUDA=0 bash install_terrain.sh
fi
"../../${BLENDER_PYTHON}" setup.py build_ext --inplace --force
cd -
# Build NURBS
cd ./worldgen/assets/creatures/geometry/cpp_utils
rm -f *.so
rm -rf build
"../../../../../${BLENDER_PYTHON}" "${NURBS_SCRIPT}" build_ext --inplace
cd -
if [ "$1" = "opengl" ]; then
bash ./worldgen/tools/compile_opengl.sh
fi