Skip to content

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

License

Notifications You must be signed in to change notification settings

samuelgundry/bpy_lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 65.6%
  • Python 27.6%
  • Shell 6.8%