Skip to content

Commit 0741d01

Browse files
author
Brecht Van Lommel
committed
Fix: Blender as Python Module shared library directory wrong
This could affect for example the USD and MaterialX Python modules that are now bundled, and need appropriate paths to their libraries. Ref #134676 Pull Request: https://projects.blender.org/blender/blender/pulls/134937
1 parent d2ecf66 commit 0741d01

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/site/sitecustomize.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,25 @@
77
import sys
88
import os
99

10-
exe_dir, exe_file = os.path.split(sys.executable)
11-
is_python = exe_file.startswith("python")
12-
1310
# Path to Blender shared libraries.
1411
shared_lib_dirname = "blender.shared" if sys.platform == "win32" else "lib"
15-
if is_python:
16-
shared_lib_dir = os.path.abspath(os.path.join(exe_dir, "..", "..", "..", shared_lib_dirname))
12+
13+
if os.path.basename(__file__) == "bpy_site_customize.py":
14+
# Blender as Python Module.
15+
is_python = True
16+
shared_lib_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
17+
# On Windows no subdirectory is used.
18+
if sys.platform != "win32":
19+
shared_lib_dir = os.path.join(shared_lib_dir, shared_lib_dirname)
1720
else:
18-
shared_lib_dir = os.path.abspath(os.path.join(exe_dir, shared_lib_dirname))
21+
exe_dir, exe_file = os.path.split(sys.executable)
22+
is_python = exe_file.startswith("python")
23+
if is_python:
24+
# Python executable bundled with Blender.
25+
shared_lib_dir = os.path.abspath(os.path.join(exe_dir, "..", "..", "..", shared_lib_dirname))
26+
else:
27+
# Blender executable.
28+
shared_lib_dir = os.path.abspath(os.path.join(exe_dir, shared_lib_dirname))
1929

2030
if sys.platform == "win32":
2131
# Directory for extensions to find DLLs.

0 commit comments

Comments
 (0)