build draco lib when building blender as a python module #125556

Manually merged
Campbell Barton merged 1 commits from BuildXYZ/blender:build-draco-for-python-module into main 2024-09-06 13:18:44 +02:00
Contributor

Problem:
Building Blender as a Python module does not support Draco compression when exporting using gltf. This is important for my application but has also been brought up on forums and as issue 113469

Solution:
Blender cmake files will need to be updated to lift restrictions on building the external Draco library when also setting WITH_PYTHON_MODULE=ON. Changes made should not impact other targets and install has been updated for all platforms.

With these changes it is now it is possible to do:

cmake -C ../blender/build_files/cmake/config/bpy_module.cmake ../blender -DWITH_DRACO=ON

The result after make install is that libextern_draco.dylib will now be present in [build_dir]/bin/bpy/lib

glTF-Blender-IO will need to perform an additional search for Draco library in the usual Python module location. Note users can set BLENDER_EXTERN_DRACO_LIBRARY_PATH but this additional search streamlines the usage of Draco compression when using Python as a module. The proposed search uses an extension wildcard so it should word cross-platorm. PR for glTF-Blender-IO submitted here: https://github.com/KhronosGroup/glTF-Blender-IO/pull/2300

Test confirming Draco compression is enable if libextern_draco.dylib is present in [bpy_dir]/lib:

bpy.ops.export_scene.gltf(
    filepath=os.path.join('/tmp', 'draco_test.glb'),
    export_format='GLB',
    export_apply=True,
    use_visible=True,
    export_draco_mesh_compression_enable=True
)
gltf-transform inspect /tmp/draco_test.glb

 OVERVIEW
 ────────────────────────────────────────────
┌────────────────────┬───────────────────────────────────────────────────┐
│ key                │ value                                             │
├────────────────────┼───────────────────────────────────────────────────┤
│ version            │ 2.0                                               │
├────────────────────┼───────────────────────────────────────────────────┤
│ generator          │ Khronos glTF Blender I/O v4.2.57                  │
├────────────────────┼───────────────────────────────────────────────────┤
│ extensionsUsed     │ KHR_draco_mesh_compression, KHR_texture_transform │
├────────────────────┼───────────────────────────────────────────────────┤
│ extensionsRequired │ KHR_draco_mesh_compression, KHR_texture_transform │
└────────────────────┴───────────────────────────────────────────────────┘

**Problem:** Building Blender as a Python module does not support Draco compression when exporting using gltf. This is important for my application but has also been brought up on forums and as issue [113469](https://projects.blender.org/blender/blender/issues/113469) **Solution:** Blender cmake files will need to be updated to lift restrictions on building the external Draco library when also setting `WITH_PYTHON_MODULE=ON`. Changes made should not impact other targets and `install` has been updated for all platforms. With these changes it is now it is possible to do: ```bash cmake -C ../blender/build_files/cmake/config/bpy_module.cmake ../blender -DWITH_DRACO=ON ``` The result after `make install` is that `libextern_draco.dylib` will now be present in `[build_dir]/bin/bpy/lib` [glTF-Blender-IO](https://github.com/KhronosGroup/glTF-Blender-IO) will need to perform an additional search for Draco library in the usual Python module location. Note users can set `BLENDER_EXTERN_DRACO_LIBRARY_PATH` but this additional search streamlines the usage of Draco compression when using Python as a module. The proposed search uses an extension wildcard so it should word cross-platorm. PR for glTF-Blender-IO submitted here: https://github.com/KhronosGroup/glTF-Blender-IO/pull/2300 Test confirming Draco compression is enable if `libextern_draco.dylib` is present in `[bpy_dir]/lib`: ```python bpy.ops.export_scene.gltf( filepath=os.path.join('/tmp', 'draco_test.glb'), export_format='GLB', export_apply=True, use_visible=True, export_draco_mesh_compression_enable=True ) ``` ```bash gltf-transform inspect /tmp/draco_test.glb OVERVIEW ──────────────────────────────────────────── ┌────────────────────┬───────────────────────────────────────────────────┐ │ key │ value │ ├────────────────────┼───────────────────────────────────────────────────┤ │ version │ 2.0 │ ├────────────────────┼───────────────────────────────────────────────────┤ │ generator │ Khronos glTF Blender I/O v4.2.57 │ ├────────────────────┼───────────────────────────────────────────────────┤ │ extensionsUsed │ KHR_draco_mesh_compression, KHR_texture_transform │ ├────────────────────┼───────────────────────────────────────────────────┤ │ extensionsRequired │ KHR_draco_mesh_compression, KHR_texture_transform │ └────────────────────┴───────────────────────────────────────────────────┘ ``` ```
BuildXYZ added 1 commit 2024-07-28 05:53:29 +02:00
build draco lib when building blender as a python module
Some checks failed
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-arm64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
67355fe07d
Iliya Katushenock added this to the Platforms, Builds Tests & Devices project 2024-07-29 12:11:22 +02:00
Member

Hello @LazyDodo and @ideasman42

This PR add builing Draco for bpy as a module (this is not the case for now in main)
Can you please review it?

Hello @LazyDodo and @ideasman42 This PR add builing Draco for bpy as a module (this is not the case for now in main) Can you please review it?
Julien Duroure requested review from Ray molenkamp 2024-08-19 16:52:12 +02:00
Julien Duroure requested review from Campbell Barton 2024-08-19 16:52:23 +02:00
Campbell Barton approved these changes 2024-08-20 06:51:46 +02:00
Member

@blender-bot package bpy

@blender-bot package bpy
Member

Unknown platform bpy. See documentation for details.

Unknown platform `bpy`. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Member

@LazyDodo Any news on that?
Seems the buildbot failed.
Is that link to the PR or something is wrong with configuration for package bpy?

@LazyDodo Any news on that? Seems the buildbot failed. Is that link to the PR or something is wrong with configuration for package bpy?
Member

No news, i just prodded the linux maintainer to look at the linux failure, and we'll likely need devops for the windows one, but they are unavailable till atleast the 15th, so it could be a bit

No news, i just prodded the linux maintainer to look at the linux failure, and we'll likely need devops for the windows one, but they are unavailable till atleast the 15th, so it could be a bit
Member

@blender-bot package windows

@blender-bot package windows
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR125556) when ready.
Campbell Barton manually merged commit a0f653c002 into main 2024-09-06 13:18:44 +02:00

Resolved the sdlew linking error, a0f653c002 (see !125556).

Resolved the sdlew linking error, a0f653c0022c94461ef8c34816c1334ee74add7f (see !125556).
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#125556
No description provided.