Skip to content
Tyler Alden Gubala edited this page Jun 12, 2020 · 9 revisions

Welcome to the blenderpy wiki!

This repository installs a python module of blender after running

pip install bpy

Option 1 - Get prebuilt bdist_wheel from pypi

Prerequisites

  1. A supported python installation with pip installed

Installation

pip install bpy

THIS WILL NOT BE AVAILABLE UNTIL PYPA INCREASES THE UPLOAD LIMIT

Please for the time being either install wheels on Google Drive or build from sources.

Option 2 - Build from sources using pypi

Prerequisites

ALL users should have the prerequisites listed on Blender's Wiki page for building Blender on their operating system. Please see this page before performing any kind of build on Blender!

  1. Windows users must have Visual Studio 2013 or later and C++ build tools installed to build from sources
  2. ALL users must have cmake 3.13.5 or higher
  3. ALL users must have git installed
  4. ALL users must have an SVN command-line provider to build from sources (this is a requirement as it is how we determine the correct release tag to grab, if any)
    • The recommended svn for Windows is TortoiseSVN
  5. ALL users must have future-fstrings installed pip install -U future-fstrings
  6. Users of Python versions 3.4 and below will probably need to update setuptools pip install -U setuptools
  7. Up-to-date wheel (if distributing)

Installation

py -m pip install bpy --no-binary

How it works

  1. Create overriding classes CMakeExtension & BuildCMake, which inheirit from the setuptools classes
    • bpy is a python extension (.pyd) and an instance of CMakeExtension
    • BuildCMake is the command that is run when installing the extension from pip (or running setup.py)
  2. Find the best Blender version for this OS, Python version and bitness using bpy-build automation
  3. Using GitPython, clone Blender sources from https://git.blender.org/
  4. Download the appropriate svn library
  5. Using cmake, configure Blender as a python module
  6. Using cmake, build the configured solution
  7. Place the built binaries in the built extension parent directory (important!)
  8. Relocate the / directory (i.e: /2.79) into the directory containing the executable from which this installation was spawned (where 'python.exe' is)
  9. Clean up using the remaining functionality from the superclasses build_ext and Extension
  10. bpy.pyd/ .so should now be installed into the site-packages

Post install

Blender has special requirements on where to find the Blender scripts. Therefore an additional command needs to be run after installation.

bpy_post_install