Skip to content

Add macOS build helper for Blender 5.1 Python 3.13#73

Open
HMiranda00 wants to merge 3 commits into
martijnberger:masterfrom
HMiranda00:codex/macos-blender-51-build-docs
Open

Add macOS build helper for Blender 5.1 Python 3.13#73
HMiranda00 wants to merge 3 commits into
martijnberger:masterfrom
HMiranda00:codex/macos-blender-51-build-docs

Conversation

@HMiranda00

@HMiranda00 HMiranda00 commented Jun 6, 2026

Copy link
Copy Markdown

Summary

This adds a macOS build helper for Blender 5.1 / Python 3.13, documents the CPython ABI mismatch that prevents Python 3.11 extension modules from loading in Blender 5.1, and adds .skp drag-and-drop import support through Blender's FileHandler API.

Why

Blender 5.1 bundles Python 3.13. When the add-on ships with sketchup.cpython-311-darwin.so, Blender cannot import the native sketchup module. The error shown by Blender can look like a circular import:

cannot import name 'sketchup' from partially initialized module 'sketchup_importer'

The root cause is that the binary extension was compiled for CPython 3.11, while Blender 5.1 imports CPython 3.13 extension modules.

What changed

  • Added scripts/build_macos_blender_extension.sh.
  • Documented the Blender 5.1 / Python 3.13 macOS build flow in README.md.
  • Registered a .skp FileHandler that forwards dropped files to import_scene.skp.
  • Reworked imported collection creation so imports are grouped under SKP Imports and a per-file SKP - <filename> collection, instead of relying on shared top-level import collections.
  • The helper:
    • uses Blender's bundled Python to derive the extension suffix,
    • downloads matching CPython source headers when Blender does not provide Python.h,
    • supports CPYTHON_SOURCE_DIR for offline/header-cache builds,
    • builds sketchup.cpython-313-darwin.so,
    • rewrites the SketchUpAPI.framework install name to @loader_path,
    • verifies that the built module imports.

Validation

Tested locally on macOS arm64 with Blender 5.1.0 / Python 3.13.9:

Loaded .../sketchup.cpython-313-darwin.so
Built .../sketchup.cpython-313-darwin.so

The resulting module also loaded from Blender's add-on directory after being copied into ~/Library/Application Support/Blender/5.1/scripts/addons/sketchup_importer/.

The Python add-on file was syntax-checked with Blender's bundled Python:

python3.13 -m py_compile sketchup_importer/__init__.py

@HMiranda00 HMiranda00 marked this pull request as ready for review June 6, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant