Page MenuHome

Python: install "bpy" as a package WITH_PYTHON_MODULE
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Sep 8 2022, 8:27 AM.

Details

Summary

Building WITH_PYTHON_MODULE was creating a "bpy" module that required Blenders data-files to be located in the module search path too.

This mean that a typical installation on Linux would create:

  • /usr/lib/python3.10/site-packages/bpy.so
  • /usr/lib/python3.10/site-packages/3.4 (containing scripts & datafiles).

The new behavior creates:

  • /usr/lib/python3.10/site-packages/bpy/__init__.so
  • /usr/lib/python3.10/site-packages/bpy/3.4

With the advantage that the "bpy" directory is the self contained Python module.

No changes are needed for the module loading logic as the mechanism to swap in blend internal Python "bpy" module (defined in release/scripts/modules/bpy/__init__.py) works the same in both instances.

Diff Detail

Repository
rB Blender
Branch
TEMP-BPY-AS-PACKAGE (branched from master)
Build Status
Buildable 23660
Build 23660: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) requested review of this revision.Sep 8 2022, 8:27 AM
Campbell Barton (campbellbarton) created this revision.
Campbell Barton (campbellbarton) retitled this revision from Python: install "bpy" as a package WITH_PYTHON_MODULE to [WIP] Python: install "bpy" as a package WITH_PYTHON_MODULE.Sep 8 2022, 8:40 AM
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
  • Fix loading on WIN32 (copy DLL's into the package path, otherwise they're not found).

macOS needs these additional changes: P3177

We don't necessarily need to solve it in this patch, but there's also inconsistency between platforms in the WITH_INSTALL_PORTABLE=OFF case. It's not supported on Windows, on macOS it assumes a Python install in /Library/Frameworks from python.org which is probably less common than using Python from Apple command line tools or Homebrew. I'm not also sure what Python libraries typically do, if they perhaps install to some user site packages by default instead of a system path.

Campbell Barton (campbellbarton) retitled this revision from [WIP] Python: install "bpy" as a package WITH_PYTHON_MODULE to Python: install "bpy" as a package WITH_PYTHON_MODULE.Sep 8 2022, 3:59 PM
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

Looks fine as a change by itself now.

This revision is now accepted and ready to land.Sep 8 2022, 4:22 PM