@@ -2844,12 +2844,10 @@ SEXP main_process_python_info_unix() {
2844
2844
return R_NilValue;
2845
2845
}
2846
2846
2847
-
2848
- if (PyGILState_Ensure == NULL )
2849
- loadSymbol (pLib, " PyGILState_Ensure" , (void **)&PyGILState_Ensure);
2850
-
2851
- if (PyGILState_Release == NULL )
2847
+ if (PyGILState_Release == NULL ) {
2852
2848
loadSymbol (pLib, " PyGILState_Release" , (void **)&PyGILState_Release);
2849
+ loadSymbol (pLib, " PyGILState_Ensure" , (void **)&PyGILState_Ensure);
2850
+ }
2853
2851
2854
2852
GILScope scope;
2855
2853
@@ -2930,6 +2928,19 @@ void py_initialize(const std::string& python,
2930
2928
if (Py_IsInitialized ()) {
2931
2929
// if R is embedded in a python environment, rpycall has to be loaded as a regular
2932
2930
// module.
2931
+
2932
+ // We don't currently support running embedded on windows?
2933
+ #ifndef _WIN32
2934
+ void * pLib = NULL ;
2935
+ pLib = ::dlopen (NULL , RTLD_NOW | RTLD_GLOBAL);
2936
+ // replace symbols that we initialized with dummy functions
2937
+ // in reticulate_init
2938
+ loadSymbol (pLib, " PyIter_Check" , (void **) &PyIter_Check);
2939
+ loadSymbol (pLib, " PyCallable_Check" , (void **) &PyCallable_Check);
2940
+ loadSymbol (pLib, " PyGILState_Ensure" , (void **) &PyGILState_Ensure);
2941
+ ::dlclose (pLib);
2942
+ #endif
2943
+
2933
2944
GILScope scope;
2934
2945
PyImport_AddModule (" rpycall" );
2935
2946
PyDict_SetItemString (PyImport_GetModuleDict (), " rpycall" , initializeRPYCall ());
0 commit comments