Spaces:
Running
on
Zero
Running
on
Zero
Update setup_blender.sh
Browse files- setup_blender.sh +53 -10
setup_blender.sh
CHANGED
@@ -1,19 +1,62 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
4 |
BLENDER_VERSION="4.2.0"
|
|
|
|
|
5 |
BLENDER_TARBALL="blender-${BLENDER_VERSION}-linux-x64.tar.xz"
|
6 |
-
BLENDER_URL="https://download.blender.org/release/
|
7 |
INSTALL_DIR="/opt/blender-${BLENDER_VERSION}-linux-x64"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
#
|
10 |
-
|
|
|
11 |
|
12 |
-
|
13 |
-
tar -xvf /tmp/${BLENDER_TARBALL} -C /opt
|
14 |
|
15 |
-
#
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
rm /tmp/${BLENDER_TARBALL}
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Exit immediately if a command exits with a non-zero status.
|
4 |
+
set -e
|
5 |
+
|
6 |
+
# --- Configuration ---
|
7 |
BLENDER_VERSION="4.2.0"
|
8 |
+
BLENDER_MAJOR_MINOR="4.2" # Matches the version directory structure
|
9 |
+
BLENDER_PYTHON_VERSION="python3.11" # Blender 4.2 uses Python 3.11
|
10 |
BLENDER_TARBALL="blender-${BLENDER_VERSION}-linux-x64.tar.xz"
|
11 |
+
BLENDER_URL="https://download.blender.org/release/Blender${BLENDER_MAJOR_MINOR}/blender-${BLENDER_VERSION}-linux-x64.tar.xz"
|
12 |
INSTALL_DIR="/opt/blender-${BLENDER_VERSION}-linux-x64"
|
13 |
+
BLENDER_PY_EXEC="${INSTALL_DIR}/${BLENDER_MAJOR_MINOR}/python/bin/${BLENDER_PYTHON_VERSION}"
|
14 |
+
# Assuming unirig_requirements.txt is in the root directory alongside this script and app.py
|
15 |
+
# If UniRig repo is cloned first, adjust path e.g., "UniRig/unirig_requirements.txt"
|
16 |
+
UNIRIG_REQS_FILE="unirig_requirements.txt"
|
17 |
+
|
18 |
+
# --- Download and Extract Blender ---
|
19 |
+
echo "Downloading Blender ${BLENDER_VERSION}..."
|
20 |
+
wget -nv -O /tmp/${BLENDER_TARBALL} ${BLENDER_URL}
|
21 |
+
echo "Download complete."
|
22 |
+
|
23 |
+
echo "Extracting Blender to ${INSTALL_DIR}..."
|
24 |
+
mkdir -p /opt # Ensure /opt exists
|
25 |
+
tar -xJf /tmp/${BLENDER_TARBALL} -C /opt
|
26 |
+
echo "Extraction complete."
|
27 |
+
|
28 |
+
# --- Create Blender Symlink ---
|
29 |
+
echo "Creating symlink for Blender executable..."
|
30 |
+
ln -sf ${INSTALL_DIR}/blender /usr/local/bin/blender # Use -f to force overwrite if exists
|
31 |
+
echo "Symlink created."
|
32 |
+
|
33 |
+
# --- Install UniRig Dependencies into Blender's Python ---
|
34 |
+
echo "Installing UniRig Python dependencies into Blender's Python (${BLENDER_PYTHON_VERSION})..."
|
35 |
+
|
36 |
+
if [ ! -f "${BLENDER_PY_EXEC}" ]; then
|
37 |
+
echo "ERROR: Blender Python executable not found at ${BLENDER_PY_EXEC} after extraction!"
|
38 |
+
exit 1
|
39 |
+
fi
|
40 |
+
|
41 |
+
if [ ! -f "${UNIRIG_REQS_FILE}" ]; then
|
42 |
+
echo "ERROR: UniRig requirements file not found at ${UNIRIG_REQS_FILE}!"
|
43 |
+
echo "Ensure this file exists in the root directory."
|
44 |
+
exit 1
|
45 |
+
fi
|
46 |
+
|
47 |
+
# Upgrade pip within Blender's Python environment
|
48 |
+
echo "Upgrading pip for Blender Python..."
|
49 |
+
"${BLENDER_PY_EXEC}" -m pip install --upgrade pip setuptools wheel
|
50 |
|
51 |
+
# Install packages from unirig_requirements.txt
|
52 |
+
echo "Installing packages from ${UNIRIG_REQS_FILE}..."
|
53 |
+
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE}"
|
54 |
|
55 |
+
echo "UniRig dependency installation for Blender Python complete."
|
|
|
56 |
|
57 |
+
# --- Cleanup ---
|
58 |
+
echo "Cleaning up downloaded tarball..."
|
59 |
+
rm /tmp/${BLENDER_TARBALL}
|
60 |
+
echo "Cleanup complete."
|
61 |
|
62 |
+
echo "Blender setup finished successfully."
|
|