diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 0976e25fc1..974d5b47ae 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -20,6 +20,7 @@ endif() target_compile_definitions(plugin PRIVATE BOOST_DLL_USE_STD_FS PLUGIN_IFCOPENSHELL_VERSION="${PROJECT_VERSION}" + IFCOPENSHELL_INSTALL_PLUGIN_DIRECTORY="${CMAKE_INSTALL_FULL_LIBDIR}" ) target_link_libraries(plugin PRIVATE ${Boost_LIBRARIES}) diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp index 78754e8e2b..268d078418 100644 --- a/src/plugin/plugin.cpp +++ b/src/plugin/plugin.cpp @@ -357,6 +357,17 @@ PLUGIN_API std::filesystem::path ifcopenshell::plugin::add_search_paths_or_defau manager.add_search_path(lib); } } + + // A static IfcParse/IfcGeom embedded in a Python extension resolves to the + // extension's site-packages directory, while plug-ins retain CMake's normal + // install location. This also covers Python installations outside the CMake + // prefix, such as GitHub Actions' hosted Python. +#ifdef IFCOPENSHELL_INSTALL_PLUGIN_DIRECTORY + const auto install_plugin_directory = std::filesystem::path(IFCOPENSHELL_INSTALL_PLUGIN_DIRECTORY); + if (install_plugin_directory != path && std::filesystem::exists(install_plugin_directory)) { + manager.add_search_path(install_plugin_directory); + } +#endif #endif // Bundle-aware fallback search paths. The primary search path is