Skip to content

Instantly share code, notes, and snippets.

@iyunbo
Last active June 16, 2023 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iyunbo/0e5f180e8e3571bc6f5c96b8b923a786 to your computer and use it in GitHub Desktop.
Save iyunbo/0e5f180e8e3571bc6f5c96b8b923a786 to your computer and use it in GitHub Desktop.
Build blender as python module (bpy) for Ubuntu
# install building tools and dependencies
sudo apt-get update
sudo apt-get --assume-yes install xpra build-essential git subversion cmake libx11-dev libxxf86vm-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libglew-dev
# create working directory
mkdir ~/blender-git
# get the source code
cd ~/blender-git
git clone https://git.blender.org/blender.git --single-branch --depth 1
# install libraries
mkdir ~/blender-git/lib
cd ~/blender-git/lib
# it is important to keep the name `linux_centos7_x86_64` even for other distro of linux, ex: ubuntu
# see: https://devtalk.blender.org/t/build-bpy-succeeded-on-macosx-m1-but-failed-on-ubuntu-20-04/22518?u=iyunbo
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64
# now build bpy
cd ~/blender-git/blender
make update
make bpy
# go to build directory
cd ~/blender-git/build_linux_bpy
# now install the bpy python module
make install
# test bpy
DISPLAY=:10
xpra start ${DISPLAY}
~/blender-git/lib/linux_centos7_x86_64/python/bin/python3.9 -c "import bpy; bpy.ops.render.render(write_still=True)"
# built objects are inside `./build_linux_bpy`
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c5b5eb317e..febf3971c52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,6 +252,7 @@ mark_as_advanced(WITH_HEADLESS)
option(WITH_QUADRIFLOW "Build with quadriflow remesher support" ON)
option(WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON)
+set(WITH_AUDASPACE ON)
option(WITH_SYSTEM_AUDASPACE "Build with external audaspace library installed on the system (only enable if you know what you're doing!)" OFF)
mark_as_advanced(WITH_AUDASPACE)
mark_as_advanced(WITH_SYSTEM_AUDASPACE)
@@ -303,6 +304,7 @@ option(WITH_IMAGE_HDR "Enable HDR Image Support" ON)
# Audio/Video format support
option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON)
option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON)
+set(WITH_CODEC_FFMPEG ON)
option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" ON)
# Alembic support
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install gcc-9 g++-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
@iyunbo
Copy link
Author

iyunbo commented Jan 29, 2022

with AUDASPACE support
with FFMPEG support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment