Page MenuHome

Blender as Python Module - OSX scripts/modules search directory
Open, Needs Triage by DeveloperPublic

Description

System Information

Operating system: Mac OSX Catalina
Graphics card: None

Blender Version

Broken: Blender 2.82 (master)

Short description of error

When compiling Blender as a Python module on Mac OSX, an additional redundant directory is required for the Mac System to find the scripts/modules directory, called Resources. My understanding is that this is strictly for the OSX Packaging scheme for the Blender "bundle". I think that for creation as a Python module however, it should be sufficient to just place it in site-packages.

Reference here

Exact steps for others to reproduce the error

Prerequisites

  1. Install Python from python.org
  2. Install XCode

Build Steps

NOTE: Audaspace errors with various numpy array object errors, OpenMP also cannot be built on OSX

export PATH="/Applications/CMake.app/Contents/bin":"$PATH"
echo PATH="/Applications/CMake.app/Contents/bin":"\$PATH" >> ~/.profile
mkdir .blenderpy
cd .blenderpy
mkdir master
cd master
git clone http://git.blender.org/blender.git
cd blender
make update
cd ..
mkdir build_bpy_darwin_custom
cd build_bpy_darwin_custom
cmake ../blender -DWITH_PLAYER=OFF -DWITH_PYTHON_INSTALL=OFF -DWITH_PYTHON_MODULE=ON -DWITH_OPENMP=OFF -DWITH_AUDASPACE=OFF
make install

Install Steps

python3 -m venv ~/.blenderpy/venv # Or wherever you want your venv

cp bin/bpy.so ~/.blenderpy/venv/lib/python3.7/site-packages

mkdir ~/.blenderpy/venv/python3.7/Resources
# Because of an OSX packaging scheme, Blender's script directory search was changed
# This above line is what the task is about

cp -R bin/2.82 ~/.blenderpy/venv/lib/python3.7/Resources

Additional Reading

NOTE: I am working on documenting various build errors with bpy.so and caveats for using it at the blenderpy repo on GitHub. Through this I supply the bpy package also on PYPI, though if anyone has qualms with that I can take it down too.

Mac Support for bpy.so

Details

Type
Bug