Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Latest commit

 

History

History
48 lines (31 loc) · 1.9 KB

README.md

File metadata and controls

48 lines (31 loc) · 1.9 KB

bpy_lambda

🎥 A compiled binary of Blender-as-a-Python-Module (bpy) for use in AWS Lambda

PyPI version

Installation

pip install bpy_lambda

Works great with Zappa!

Usage

bpy_lambda is a simple wrapper around the bpy. You can read more about bpy usage in the Blender Documentation.

from bpy_lambda import bpy

# bpy can be used normally!
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
cube = bpy.context.scene.objects.active
cube.scale = (1, 2, 3)
bpy.ops.export_scene.obj(filepath='my_model.obj')

bpy_lambda will only work in a Lambda environment (perhaps some linux distros as well, if you have a similar set of library versions to AWS Lambda).

For local development, it will be useful to install bpy normally with the instructions on the Blender website. (Unfortunately, this requires building from source).

With a local version of bpy installed, you can use this code to switch seamlessly between your local environment and Lambda:

try:
    import bpy
except ImportError:
    from bpy_lambda import bpy

Contribution / Building from Source

The Dockerfile is the easiest way to create a version of bpy that works on Lambda. Building this docker image will download the necessary libraries and compile a minimal version of Blender that works in a Lambda environment.

For easy installation / local setup, run ./build.sh. This will create a directory called bpy_lambda that contains all the necessary package files.

Running ./test.sh will spin up a test Lambda invocation (using the excellent lambci/docker-lambda). Any import or dependency errors should be caught by this test.