From 81558783e40394c2c60f61626eb6814f17128503 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Sep 2022 10:25:35 +1000 Subject: Python: install "bpy" as a package WITH_PYTHON_MODULE Building WITH_PYTHON_MODULE was creating a "bpy" module that required Blenders data-files to be located in the module search path too. This mean that a typical installation on Linux would create: - `/usr/lib/python3.10/site-packages/bpy.so` - `/usr/lib/python3.10/site-packages/3.4` (containing `scripts` & `datafiles`). The new behavior creates: - `/usr/lib/python3.10/site-packages/bpy/__init__.so` - `/usr/lib/python3.10/site-packages/bpy/3.4` With the advantage that the "bpy" directory is the self contained Python module. No changes are needed for the module loading logic as the mechanism to swap in blend internal Python "bpy" module (defined in `release/scripts/modules/bpy/__init__.py`) works the same in both instances. Thanks to Brecht for macOS support. Reviewed by brecht Ref D15911 --- source/blender/blenkernel/CMakeLists.txt | 4 ++++ source/blender/blenkernel/intern/appdir.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 9521da8417e..b982c69a378 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -659,6 +659,10 @@ if(WITH_PYTHON) ) add_definitions(-DWITH_PYTHON) + if(WITH_PYTHON_MODULE) + add_definitions(-DWITH_PYTHON_MODULE) + endif() + if(WITH_PYTHON_SAFETY) add_definitions(-DWITH_PYTHON_SAFETY) endif() diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index c19afdb4fb8..4bd8cfd5f47 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -374,7 +374,7 @@ static bool get_path_local_ex(char *targetpath, /* Try `{g_app.program_dirname}/2.xx/{folder_name}` the default directory * for a portable distribution. See `WITH_INSTALL_PORTABLE` build-option. */ const char *path_base = g_app.program_dirname; -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) /* Due new code-sign situation in OSX > 10.9.5 * we must move the blender_version dir with contents to Resources. */ char osx_resourses[FILE_MAX]; -- cgit v1.2.3