I’ve been trying to create a vary crude build system for building and testing my python add-on. Basically it builds it using Blender Extensions CLI, and then it would run Blender, whilst installing it using install-file subcommand. However, the install-file dosent seem to accually work!
...
(Roblox Lighting Data): ===== Registering... =====
Add-on not loaded: "bl_ext.vscode_development.blend-sanitizer", cause: No module named 'bl_ext.vscode_development.blend-sanitizer'
....
(Roblox Lighting Data): ===== Unregistering... =====
Help would be appreciated! ![]()
FULL SCRIPTS
test.sh
(The one I’m running)
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <blender_executable> <platform>"
echo "Missing <blender_executable>"
exit 1
fi
if [ -z "$2" ]; then
echo "Usage: $0 <blender_executable> <platform>"
echo "Missing <platform>"
exit 1
fi
set -euo pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BUILD_DIR="$(pwd)/builds"
VALID_PLATFORMS=("windows_x64" "macos_x64" "macos_arm64" "linux_x64" "linux_arm64")
function clear_dir() {
local glob="${1:-}"
for file in "$1"/$glob; do
if [ ! -f "$file" ]; then continue; fi
rm -f "$file"
done
}
# Check the given platform
platform="$2"
extension_zip=$(echo $BUILD_DIR/*$2.zip)
if [[ ! -f $extension_zip ]]; then
echo "Invalid platform! ( $(printf '%s ' "${VALID_PLATFORMS[@]}"))"
echo "[File not found: '$extension_zip']"
exit 1
fi
if [[ -d $BUILD_DIR ]]; then
echo -e "Clearing old builds...\n"
clear_dir "$BUILD_DIR" "*.zip"
else
mkdir -p $BUILD_DIR
fi
echo -e "Regenerating Builds\n"
blend_path="$1"
"$SCRIPT_DIR"/build.sh "$blend_path"
echo -e "Opening Blender\n"
"$blend_path" --command extension install-file "$extension_zip" --repo vscode_development --enable
build.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <blender_executable>"
exit 1
fi
set -euo pipefail
BUILD_DIR="$(pwd)/builds"
if [[ -d $BUILD_DIR ]]; then
mkdir -p $BUILD_DIR
else
rmdir -rf $BUILD_DIR
fi
blend_path="$1"
"$blend_path" --command extension build --source-dir "blend-sanitizer/" --output-dir "$BUILD_DIR" --split-platforms
echo -e "\nSuccessfully built addon to $BUILD_DIR"
download_wheels.sh
set -euo pipefail
EXTENSION_NAME="blend-sanitizer"
PYTHON_VERSION="3.11"
CV2_VERSION="4.12.0.88"
PLATFORMS=("win_amd64" "manylinux_2_17_x86_64" "manylinux_2_17_aarch64" "macosx_13_0_x86_64" "macosx_13_0_arm64")
WHEELS_DIR="$(pwd)/$EXTENSION_NAME/.wheels"
MANIFEST_FILE="$(pwd)/$EXTENSION_NAME/blender_manifest.toml"
function clear_dir() {
local glob="${1:-}"
for file in "$1"/$glob; do
if [ ! -f "$file" ]; then continue; fi
rm -f "$file"
done
}
echo -e "Fetching Python executable...\n"
python_executable="$(pwd)/.venv/Scripts/python.exe"
if [[ ! -f $python_executable ]]; then
python_executable="$(pwd)/.venv/bin/python"
if [[ ! -f $python_executable ]]; then
echo "Could not find python executable in '$(pwd)/.venv'"
fi
fi
if [[ -d $WHEELS_DIR ]]; then
echo -e "Clearing old wheels...\n"
clear_dir "$WHEELS_DIR" "*.whl"
else
mkdir -p $WHEELS_DIR
fi
echo -e "Downloading new wheels..."
for platform in "${PLATFORMS[@]}"; do
echo -e "Downloading opencv-python==$CV2_VERSION for platform $platform..."
"$python_executable" -m pip download "opencv-python==$CV2_VERSION" --dest $WHEELS_DIR --only-binary=:all: --python-version="$PYTHON_VERSION" --platform="$platform" -q -q --no-input
wheel_file="$WHEELS_DIR/opencv_python-$CV2_VERSION"*"$platform*.whl"
if [ ! -f $wheel_file ]; then
echo "could not download" $wheel_file
echo $([[ -f $wheel_file ]])
exit 1
fi
done
echo -e "\nAdding wheels to manifest...\n"
# Generate wheel list lines
wheel_lines=""
for f in "$WHEELS_DIR"/*.whl; do
wheel_lines+="\t\"./.wheels/$(basename "$f")\",\n"
done
# Replace the entire wheels section
awk -v newlist="$wheel_lines" '
BEGIN { in_wheels=0 }
{
if ($1 == "wheels" && $2 == "=") {
print "wheels = ["
printf "%s", newlist
print "]"
in_wheels=1
next
}
if (in_wheels && $0 ~ /^\]/) { in_wheels=0; next }
if (!in_wheels) print
}' "$MANIFEST_FILE" > "$MANIFEST_FILE.tmp"
mv "$MANIFEST_FILE.tmp" "$MANIFEST_FILE"