Installation

This is an installation guide for developers using Linux and macOS. On Windows, you can use WSL and follow the Linux instructions. See the user’s installation guide for information on how to run Blender from WSL.

Requirements

To get started, install Poetry. Poetry is used to manage dependencies and so called Poetry shells, which are essentially virtual environments.

Make sure you have git and make.

Debian and Ubuntu (and derivatives)
sudo apt install git make

On macOS, git and make come with Apple’s Xcode Command Line Tools. You can just try to run one of the commands, for example git in a terminal and they will be installed automatically if necessary.

Getting the source code

Generate an SSH key pair following the gitlab instructions.

Clone the repository into your favourite directory using:

git clone git@gitlab.discretization.de:pyddg/pyddg.git

This will create a directory pyddg.

To push local changes on git don’t forget to tell git who you are by running

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

If you want to use git blame, you should configure git to ignore non-relevant commits:

git config blame.ignoreRevsFile .git-blame-ignore-revs

Installing the library and Blender

Linux/WSL

Warning

Don’t install Blender using other methods unless you know what you are doing. The setup_blender script ensures that Blender can use virtual environments. For more details, consult the Blender documentation and the setup_blender source code.

Install Blender

# Install Blender 3.6.21 to ~/blender
scripts/setup_blender ~/blender 3 6 21

Warning

Blender is expected to crash if you attempt to run it now. Blender won’t work until you enter the Poetry shell or virtual environment and set certain environment variables as described below.

Then run

cd pyddg    # the project directory
poetry env use ~/blender/blender-3.6.21/3.6/_python/bin/python3.10
poetry install --all-extras --with dev,docs,tests,style,codequality

Enter the virtual environment with

# poetry
export PATH="$HOME/blender/blender-3.6.21:$PATH"
export PYTHONPATH="$(poetry env info -p)/lib/python3.10/site-packages/"
poetry shell

macOS

Install Blender 3.6 for Apple Silicon with the following command. If you’re running Intel, pass x64 instead of arm64. Note that it requires root privileges because Blender is installed to /Applications/. It is installed under a new name, so it will not interfere with any existing Blender installation.

# Install Blender 3.6.21 to /Applications/
sh <(curl https://gitlab.discretization.de/pyddg/pyddg/-/raw/develop/scripts/setup_blender_macos) arm64 3 6 21

Warning

Blender is expected to crash if you attempt to run it now. Blender won’t work until you enter the Poetry shell or virtual environment and set certain environment variables as described below.

Then run

cd pyddg    # the project directory
poetry env use /Applications/Blender-3.6.21-pyddg.app/Contents/Resources/3.6.21/_python/bin/python3.10
poetry install --all-extras --with dev,docs,tests,style,codequality

Enter the virtual environment with

# poetry
export PATH="/Applications/Blender-3.6.21-pyddg.app/Contents/MacOS/:$PATH"
export PYTHONPATH="$(poetry env info -p)/lib/python3.10/site-packages/"
poetry shell

Test your installation

Run tests with

python3 test.py

You can run tests selectively. For all options, consult

python3 test.py --help

Build documentation with

Linux and macOS
make -C docs/ docs
Windows
docs\make.bat docs

and open docs/build/index.html in your favorite browser.

Clean the build artifacts with

Linux and macOS
make -C docs/ clean
Windows
docs\make.bat clean

Exit the Poetry shell with

exit