Merge pull request #2085 from ratwithacompiler/macos-python-fix

obs-scripting: Fix Python on MacOS
This commit is contained in:
Jim 2019-11-14 20:38:53 -08:00 committed by GitHub
commit 9bdb21205d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 19 deletions

View file

@ -375,14 +375,6 @@ if (APPLE)
target_link_libraries(obs
Qt5::MacExtras)
set_target_properties(obs PROPERTIES LINK_FLAGS "-pagezero_size 10000 -image_base 100000000")
set_property(
TARGET obs
APPEND
PROPERTY INSTALL_RPATH
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/"
"/Library/Frameworks/Python.framework/Versions/3.6/lib/"
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/"
)
endif()
define_graphic_modules(obs)

View file

@ -61,7 +61,7 @@ if(NOT UNIX_STRUCTURE)
set(OBS_INSTALL_PREFIX "")
set(OBS_RELATIVE_PREFIX "../")
set(OBS_SCRIPT_PLUGIN_DESTINATION "${OBS_DATA_DESTINATION}/obs-scripting/${_lib_suffix}bit")
set(OBS_SCRIPT_PLUGIN_DESTINATION "${OBS_DATA_DESTINATION}/obs-scripting")
else()
set(OBS_EXECUTABLE_DESTINATION "bin/${_lib_suffix}bit")
set(OBS_EXECUTABLE32_DESTINATION "bin/32bit")

View file

@ -32,6 +32,12 @@
#define SO_EXT ".dylib"
#endif
#ifdef __APPLE__
#define PYTHON_LIB_SUBDIR "lib/"
#else
#define PYTHON_LIB_SUBDIR ""
#endif
bool import_python(const char *python_path)
{
struct dstr lib_path;
@ -44,7 +50,7 @@ bool import_python(const char *python_path)
dstr_init_copy(&lib_path, python_path);
dstr_replace(&lib_path, "\\", "/");
if (!dstr_is_empty(&lib_path)) {
dstr_cat(&lib_path, "/");
dstr_cat(&lib_path, "/" PYTHON_LIB_SUBDIR);
}
dstr_cat(&lib_path, PYTHON_LIB SO_EXT);

View file

@ -47,7 +47,12 @@ if(CMAKE_VERSION VERSION_GREATER 3.7.2)
else()
SWIG_ADD_MODULE(obspython python obspython.i ../cstrcache.cpp ../cstrcache.h)
endif()
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
IF(APPLE)
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs)
ELSE()
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
ENDIF()
function(install_plugin_bin_swig target additional_target)
if(APPLE)
@ -62,14 +67,7 @@ function(install_plugin_bin_swig target additional_target)
PREFIX "")
if (APPLE)
set_property(
TARGET ${additional_target}
APPEND
PROPERTY INSTALL_RPATH
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/"
"/Library/Frameworks/Python.framework/Versions/3.6/lib/"
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/"
)
SET_TARGET_PROPERTIES(${additional_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"