diff --git a/.gitattributes b/.gitattributes index 91a3cbd..a259262 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ *.psk filter=lfs diff=lfs merge=lfs -text *.psa filter=lfs diff=lfs merge=lfs -text *.pskx filter=lfs diff=lfs merge=lfs -text +*.blend filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index fa532a7..3440da1 100644 --- a/.gitignore +++ b/.gitignore @@ -104,4 +104,5 @@ venv.bak/ .mypy_cache/ # PyCharm -.idea \ No newline at end of file +.idea +*.blend1 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a2f59dd --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "io_scene_psk_psa: test", + "type": "shell", + "command": "docker run -it --volume ${PWD}/io_scene_psk_psa:/addons/io_scene_psk_psa --volume ${PWD}/tests:/tests $(docker build -q .)" + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ecf81c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:22.04 + +ARG BLENDER_VERSION=4.4 + +RUN apt-get update -y && \ + apt-get install -y libxxf86vm-dev libxfixes3 libxi-dev libxkbcommon-x11-0 libgl1 libglx-mesa0 python3 python3-pip \ + libxrender1 libsm6 + +RUN pip install --upgrade pip +RUN pip install pytest-blender +RUN pip install blender-downloader + +# Set BLENDER_EXECUTABLE and BLENDER_PYTHON as environment variables +RUN BLENDER_EXECUTABLE=$(blender-downloader $BLENDER_VERSION --extract --remove-compressed --print-blender-executable) && \ + BLENDER_PYTHON=$(pytest-blender --blender-executable "${BLENDER_EXECUTABLE}") && \ + echo "Blender executable: $BLENDER_EXECUTABLE" && \ + echo "Blender Python: $BLENDER_PYTHON" && \ + echo "export BLENDER_EXECUTABLE=${BLENDER_EXECUTABLE}" >> /etc/environment && \ + echo "export BLENDER_PYTHON=${BLENDER_PYTHON}" >> /etc/environment && \ + echo $BLENDER_EXECUTABLE > /blender_executable_path + +# Source the environment variables and install Python dependencies +RUN . /etc/environment && \ + $BLENDER_PYTHON -m ensurepip && \ + $BLENDER_PYTHON -m pip install pytest + +# Persist BLENDER_EXECUTABLE as an environment variable +RUN echo $(cat /blender_executable_path) > /tmp/blender_executable_path_env && \ + export BLENDER_EXECUTABLE=$(cat /tmp/blender_executable_path_env) +ENV BLENDER_EXECUTABLE /tmp/blender_executable_path_env + +ENTRYPOINT [ "/bin/bash", "-c" ] +CMD ["export BLENDER_EXECUTABLE=$(cat /blender_executable_path) && echo $BLENDER_EXECUTABLE && pytest -svv tests --blender-executable $BLENDER_EXECUTABLE --blender-addons-dirs addons"]