glTF: Install Draco lib in the same directory as the glTF2 addon
This changes the location of the Draco library installation path. The new location is at the root of addons_core/io_scene_gltf2 addon, as the library is created for this addon only. This will solve issues where the gltf addon couldn't find the library in case of global python installation or custom script/lib paths Pull Request: https://projects.blender.org/blender/blender/pulls/131080
This commit is contained in:
committed by
Sebastian Parborg
parent
377d272f72
commit
faaa12a101
@@ -1237,13 +1237,6 @@ set_and_warn_dependency(WITH_PYTHON WITH_CYCLES OFF)
|
||||
set_and_warn_dependency(WITH_PYTHON WITH_DRACO OFF)
|
||||
set_and_warn_dependency(WITH_PYTHON WITH_MOD_FLUID OFF)
|
||||
|
||||
if(NOT WITH_PYTHON_MODULE)
|
||||
if(WITH_DRACO AND NOT WITH_PYTHON_INSTALL)
|
||||
message(STATUS "WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now")
|
||||
set(WITH_DRACO OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# enable boost for cycles, audaspace or i18n
|
||||
# otherwise if the user disabled
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||
"version": (4, 4, 23),
|
||||
'blender': (4, 3, 0),
|
||||
"version": (4, 4, 24),
|
||||
'blender': (4, 4, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
'warning': '',
|
||||
|
||||
@@ -8,59 +8,25 @@ from pathlib import Path
|
||||
import bpy
|
||||
|
||||
|
||||
def find_draco_dll_in_module(library_name: str) -> Path:
|
||||
"""
|
||||
Get the extern Draco library if it exist in the default location used when
|
||||
build PYthon as a module
|
||||
:return: DLL/shared library path.
|
||||
"""
|
||||
bpy_path = Path(bpy.__file__).resolve()
|
||||
bpy_dir = bpy_path.parents[4]
|
||||
lib_dir = bpy_dir / 'lib'
|
||||
|
||||
draco_path = lib_dir / library_name
|
||||
if draco_path.exists():
|
||||
return draco_path
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def dll_path() -> Path:
|
||||
"""
|
||||
Get the DLL path depending on the underlying platform.
|
||||
:return: DLL path.
|
||||
Get the library path, that should be at addon root
|
||||
:return: library path.
|
||||
"""
|
||||
lib_name = 'extern_draco'
|
||||
blender_root = Path(bpy.app.binary_path).parent
|
||||
python_lib = Path('{v[0]}.{v[1]}/python/lib'.format(v=bpy.app.version))
|
||||
python_version = 'python{v[0]}.{v[1]}'.format(v=sys.version_info)
|
||||
|
||||
path = os.environ.get('BLENDER_EXTERN_DRACO_LIBRARY_PATH')
|
||||
if path is not None:
|
||||
return Path(path)
|
||||
|
||||
library_name = {
|
||||
'win32': '{}.dll'.format(lib_name),
|
||||
'linux': 'lib{}.so'.format(lib_name),
|
||||
'darwin': 'lib{}.dylib'.format(lib_name)
|
||||
}.get(sys.platform)
|
||||
|
||||
path = find_draco_dll_in_module(library_name)
|
||||
path = os.path.dirname(sys.modules['io_scene_gltf2'].__file__)
|
||||
if path is not None:
|
||||
return path
|
||||
return Path(os.path.join(path, library_name))
|
||||
|
||||
path = {
|
||||
'win32': blender_root / python_lib / 'site-packages',
|
||||
'linux': blender_root / python_lib / python_version / 'site-packages',
|
||||
'darwin': blender_root.parent / 'Resources' / python_lib / python_version / 'site-packages'
|
||||
}.get(sys.platform)
|
||||
|
||||
if path is None or library_name is None:
|
||||
if library_name is None:
|
||||
print('WARNING', 'Unsupported platform {}, Draco mesh compression is unavailable'.format(sys.platform))
|
||||
|
||||
return path / library_name
|
||||
|
||||
|
||||
def dll_exists(quiet=False) -> bool:
|
||||
"""
|
||||
Checks whether the DLL path exists.
|
||||
|
||||
@@ -479,6 +479,14 @@ if(WITH_PYTHON)
|
||||
endif()
|
||||
endif()
|
||||
unset(FREESTYLE_EXCLUDE_CONDITIONAL)
|
||||
|
||||
if(WITH_DRACO)
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${TARGETDIR_VER}/scripts/addons_core/io_scene_gltf2
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# fonts
|
||||
@@ -983,19 +991,6 @@ file(REMOVE ${CMAKE_BINARY_DIR}/bin/lib/libglapi.so.0.0.0)\n
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_DRACO)
|
||||
if(WITH_PYTHON_MODULE)
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/bin/bpy/lib
|
||||
)
|
||||
else()
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}/site-packages
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if(WITH_WINDOWS_EXTERNAL_MANIFEST)
|
||||
install(
|
||||
@@ -1536,20 +1531,6 @@ elseif(WIN32)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_DRACO)
|
||||
if(WITH_PYTHON_MODULE)
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/bin/bpy/lib
|
||||
)
|
||||
else()
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_PYTHON_MODULE AND TARGETDIR_BPY)
|
||||
install(
|
||||
TARGETS blender
|
||||
@@ -1680,19 +1661,6 @@ elseif(APPLE)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_DRACO)
|
||||
if(WITH_PYTHON_MODULE)
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/bin/bpy/lib
|
||||
)
|
||||
else()
|
||||
install(
|
||||
PROGRAMS $<TARGET_FILE:extern_draco>
|
||||
DESTINATION ${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}/site-packages
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user