I'm on a Linux Ubuntu 18.04.1 LTS System.
As the title states I was unable to find any precise documentation how to build blender as Python Module for uses in scripts.
If anyone can help me I'd really appreciate it.
Thanks in advance.
I'm on a Linux Ubuntu 18.04.1 LTS System.
As the title states I was unable to find any precise documentation how to build blender as Python Module for uses in scripts.
If anyone can help me I'd really appreciate it.
Thanks in advance.
Ok, i managed to actually build it as a Python module. It might appear strange to ask a question and immediately answer it. But i decided to share my experience with this process.
In this way it could help someone in the future who struggled the same way as i did.
Now to the process of the solution.
Starting point were the following three sources as follows :
How did i achieve the build ?
I started by following the description provided of the 2. Source; which wasn't really precise in how to handle the source and so on and did not work for me in the end.
After a few failures of this, i went on by just following the 3. Source.
So i did what was stated there :
mkdir ~/blender-git
cd ~/blender-git
git clone https://git.blender.org/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master
Afterwards :
cd ~/blender-git
./blender/build_files/build_environment/install_deps.sh
Now I had every bit of blender code and all dependencies installed. Since i did not want blender compiled with UI (as normal programm) i was curious what (described in the next step, step 3, in Source 3.) make in ~/blender-git/blender offered.
So i proceeded with simply calling make help which gave the following (truncated for brevity) output :
Convenience targets provided for building blender, (multiple at once can be used)
* debug - build a debug binary
* full - enable all supported dependencies & options
* lite - disable non essential features for a smaller binary and faster build
* headless - build without an interface (renderfarm or server automation)
* cycles - build Cycles standalone only, without Blender
* bpy - build as a python module which can be loaded from python directly
* deps - build library dependencies (intended only for platform maintainers)
* config - run cmake configuration tool to set build options
Note, passing the argument 'BUILD_DIR=path' when calling make will override the
default build dir.
Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
"Oh Hey, look what we got!" There it was, a make bpy which promised to solve all my problems.
So i executed it and it compiled. But I ended up with the Python module in a, at least for my desires, wrong directory : /usr/local/PYTHON_SITE_PACKAGES-NOTFOUND. I wondered how this happend.
I soon figured out that I had to reconfigure cmake in the new created ~/blender-git/linux_build_bpy via ccmake linux_build_bpy while in ~/blender-git. There i needed to enable the Advanced Settings via pressing t and then editing the Key PYTHON_SITE_PACKAGES from PYTHON_SITE_PACKAGES-NOTFOUND to my desired Path /usr/lib/python3.6/site-packages.
After changing this i had to rebuild the project, which didn't actually rebuild since the changed setting didn't affect the main build process.
Rebuild in ~/blender-git/blender via make bpy.
In the End I also deleted the stuff in /usr/local/PYTHON_SITE_PACKAGES-NOTFOUND.
(Ofc i could've just moved/copied it...)
That's how it worked form me. I hope this is helpful in any kind for anyone in the future.
NOTES:
make bpy might need superuser-rights so do a sudo make bpy and don't worry
about a complete rebuild (it's allready done just linking/copying in the end needs
those rights).
The configuration after the first build might not be needed or can be done before hand, but i didn't figure out how to do so.
If followed through these steps, and the Python module (strangely a directory
called 2.80 or simmilar number) exists in the desired path but yet you are not able to import the module bpy in any of your scripts, make sure that your desired path is included in your PYTHONPATH Env-variable.
make bpyI basically stick toconfigure, make, [sudo] make install. cmake-gui is my configure tool of choice pre building a blender target – batFINGER Dec 25 '18 at 03:07