// apparently PATH_MAX is not standard and not defined by MSVC #ifdef _WIN32 #ifdef PATH_MAX #undef PATH_MAX #endif #define PATH_MAX EXTENDED_MAX_PATH #endif #ifndef PATH_MAX #ifdefined _MAX_PATH #define PATH_MAX _MAX_PATH #elifdefined MAX_PATH #define PATH_MAX MAX_PATH #else #error no PATH_MAX #endif #endif
using pyuno::PyRef; using pyuno::NOT_NULL; using pyuno::Runtime; using pyuno::PyThreadAttach;
using com::sun::star::uno::Reference; using com::sun::star::uno::XInterface; using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::RuntimeException;
// pythonhome+pythonpath must be set before Py_Initialize(), otherwise there appear warning on the console // sadly, there is no api for setting the pythonpath, we have to use the environment variable if( !pythonHome.isEmpty() ) #if PY_VERSION_HEX >= 0x03080000
setPythonHome( pythonHome, &config ); #else
setPythonHome( pythonHome ); #endif
#ifdef _WIN32 //extend PATH under windows to include the branddir/program so ssl libs will be found //for use by terminal mailmerge dependency _ssl.pyd
OUString sEnvName("PATH");
OUString sPath;
osl_getEnvironment(sEnvName.pData, &sPath.pData);
OUString sBrandLocation("$BRAND_BASE_DIR/program");
rtl::Bootstrap::expandMacros(sBrandLocation);
osl::FileBase::getSystemPathFromFileURL(sBrandLocation, sBrandLocation);
sPath = sPath + OUStringChar(SAL_PATHSEPARATOR) + sBrandLocation;
osl_setEnvironment(sEnvName.pData, sPath.pData); #endif
PyThreadState *tstate = PyThreadState_Get();
PyEval_ReleaseThread( tstate ); #if PY_VERSION_HEX < 0x030B0000 // This tstate is never used again, so delete it here. // This prevents an assertion in PyThreadState_Swap on the // PyThreadAttach below.
PyThreadState_Delete(tstate); #endif
}
// tdf#114815 init python only once, via single-instance="true" in pythonloader.component
pythonInit();
Reference< XInterface > ret;
PyThreadAttach attach( PyInterpreterState_Head() );
{ // note: this can't race against getComponentContext() because // either (in soffice.bin) CreateInstance() must be called before // getComponentContext() can be called, or (in python.bin) the other // way around if( ! Runtime::isInitialized() )
{
Runtime::initialize( ctx );
}
Runtime runtime;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.