From a4a3440d53dc62c53402bc0f56619e8b3298f6f0 Mon Sep 17 00:00:00 2001 From: Spencer Killen Date: Sun, 9 Jan 2022 10:01:10 -0700 Subject: [PATCH] Add venv for bpy --- .gitignore | 3 +++ create_venv.bash | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .gitignore create mode 100755 create_venv.bash diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf60b52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.blend* +.env +venv diff --git a/create_venv.bash b/create_venv.bash new file mode 100755 index 0000000..6ed6195 --- /dev/null +++ b/create_venv.bash @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [[ -d venv ]]; then + source ./venv/bin/activate + return +fi + +if ! [[ -f .env ]]; then + echo "Add a .env file with PYTHON_PATH containing an absolute path path to" + echo "blender's python build with bpy. " + echo "E.g PYTHON_PATH=~/blender-git/lib/linux_centos7_x86_64/python/bin/python3.9" + echo "PYTHON_PATH=~/blender-git/lib/linux_centos7_x86_64/python/bin/python3.9" > .env + echo "Created the file. Now go edit it" + exit 1; +fi + +source .env + +if [[ -z "$PYTHON_PATH" ]]; then + echo Missing variable PYTHON_PATH in .env + exit 1 +fi + +"$PYTHON_PATH" -m venv --system-site-packages --symlinks venv +echo "venv created" +source ./venv/bin/activate