Преглед изворни кода

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

obs-scripting: Fix Python on MacOS
Jim пре 6 година
родитељ
комит
93411e8fc5

+ 0 - 8
UI/CMakeLists.txt

@@ -373,14 +373,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)

+ 1 - 1
cmake/Modules/ObsHelpers.cmake

@@ -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")

+ 7 - 1
deps/obs-scripting/obs-scripting-python-import.c

@@ -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);
 

+ 7 - 9
deps/obs-scripting/obspython/CMakeLists.txt

@@ -42,7 +42,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)
@@ -57,14 +62,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"