How to contribute - Freedom-of-Form-Foundation/anatomy3d-blender Wiki

:warning: We are currently setting up a way to easily contribute to the project. This wiki should therefore be seen as work in progress. :warning:

The Anatomy Re-engineering Framework is a plugin for Blender. In principle, it is possible to contribute using just Blender 3.2.2 and a text editor of choice. However, you would lack the tools to catch bugs early on. If you want to do serious development, we highly recommend setting up an environment that does type-checking for you. On this page, we will guide you through setting up such an environment, so that you can easily write high-quality code and test your code in Blender.

Prerequisites for high-quality contributions

Code quality is important. We recommend (and may soon require) that all code is statically analyzed by mypy (type checking), pylint (quality checking) and pycodestyle (PEP8 conformity checking) before it is committed. You can install these tools yourself, or follow the tutorial below to set up an IDE where these are enabled. We currently recommend coding in Spyder, although other IDEs such as VSCodium (VSCode) or PyCharm should also work if you follow similar steps.

Since the Python environment has to be compatible with Blender, you will need to set up Python properly. Don't worry, it won't take long!

  • Spyder
  • VSCodium / VSCode

Setting up your IDE: Spyder

The simplest way to set up Spyder is using conda. Make sure you have conda installed. Then you can just type in the following commands into your terminal and say 'y' (yes) wherever necessary.

All steps in brief

Make sure you have conda installed on your system. Then, install Spyder, MyPy, and Blender's fake-bpy module for type checking:

[[email protected]]$ conda create -n arf_dev python=3.10                   # Create an environment called "arf_dev" with Python 3.10 installed.
[[email protected]]$ conda activate arf_dev                                # Enter the "arf_dev" environment to start using Python 3.10.
(arf_dev) [[email protected]]$ conda install -c spyder-ide spyder          # Install the Spyder IDE (and pylint, pycodestyle, etc).
(arf_dev) [[email protected]]$ pip3 install pylsp-mypy                     # Install MyPy for Spyder.
(arf_dev) [[email protected]]$ pip3 install fake-bpy-module-latest         # This is so that the bpy module can be checked by Python linters.
(arf_dev) [[email protected]]$ conda deactivate                            # Leave the "arf_dev" environment again.
[[email protected]]$ 

To run Spyder, make sure you enter the arf_dev environment so that you have access to all the tools you installed:

[[email protected]]$ conda activate arf_dev
(arf_dev) [[email protected]]$ spyder

Afterwards, you can leave the arv_dev conda environment again:

(arf_dev) [[email protected]]$ conda deactivate
[[email protected]]$ 

Make sure you enable linting in Spyder's settings.

Setting up your IDE: VSCodium / VSCode

:warning: VSCode sends a lot of data to Microsoft, which might compromise your privacy. VSCodium is VSCode with telemetry removed, but unfortunately the required Python plugin still sends a lot of data to Microsoft regardless. Please consider using a different IDE if this affects you. :warning:

All steps in brief

  • Install VSCodium or VSCode.
  • Install the Python extension for VSCodium / VSCode.
  • Install conda.
  • Create a Python env that uses the same Python version as the one Blender uses: Python 3.10 for Blender 3.2.2.
conda create -n arf_dev python=3.10

VSCodium / VSCode should automatically detect the interpreter if the Python extension is correctly installed. Read the steps over here for troubleshooting.

  • Select the Python interpreter in VSCodium / VSCode.
  • Install the fake-bpy module to get linting support for Blender's libraries: run
pip3 install fake-bpy-module-latest

in the arf_dev environment.

  • In case the project's files aren't found: add the path where this project is stored on your machine to the PYTHONPATH.

Make sure you enable linting and type checking in VSCodium's or VSCode's settings.

Setting up your IDE: Any other IDE

Using a different IDE is also possible. In this case, you have to make sure that you have mypy and fake-bpy-module installed in your Python environment, and that PEP8 style checking is enabled. It is possible to develop without these modules installed, but that is not recommended for high-quality code.