Back to News
Advertisement
nnutti about 5 hours ago 0 commentsRead Article on github.com

ZH version is available. Content is displayed in original English for accuracy.

I wanted to share fake-bpy-module, a collection of fake Blender Python API stubs designed to enable code auto-completion and type hinting in external IDEs like VSCode. I have been maintaining this open-source project for over 8 years, tracking Blender's active ecosystem from Blender version 2.78 to 5.2+.

-- The Pain Point for Development in Blender Python --

Blender does not expose its Python API (bpy) as standard Python files outside of its built-in text editor. This makes add-on development in external IDEs tedious and prone to type errors.

-- Solution & How it Works --

Instead of relying on the starndard inspect module which often fails to handle edge cases in Blender's dynamic environment. fake-bpy-module parses the official Blender Python API documentation to generate .pyi stub files.

Of course, documentation parsing comes with its own challenges. Some APIs are undocumented, and others cannot be used as-is (such as the bpy_prop_collection class). To address this, the generator internally transforms and patches the types during the stub generation phase to ensure strict compatibility.

-- Availability & Daily CI/CD --

The stubs are available via PyPI (ex. pip install fake-bpy-module-5.2) and support a wide range of Blender versions.

The latest stubs based on the latest Blender code are also available (pip install fake-bpy-module). To realize this, our custom CI/CD system builds the Blender binary daily from the latest source code.

-- Sub-project: fake-bge-module --

UPBGE is an open-source game engine fork based on Blender. I have also created a dedicated sub-project fake-bge-module, for the UPBGE Python API (bge). https://github.com/nutti/fake-bge-module

I would love to hear your feedback on these tools!

Advertisement

Discussion (0 Comments)Read Original on HackerNews

No comments available or they could not be loaded.