From 25f71596ec323bfc56d3e5681e749994631f0bef Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin <15985472+sarlinpe@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:38:34 +0100 Subject: [PATCH] Prevent double initialization of glog for <=0.5 (#59) --- _pyceres/logging.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_pyceres/logging.h b/_pyceres/logging.h index 3b8d53a..5dd92fa 100644 --- a/_pyceres/logging.h +++ b/_pyceres/logging.h @@ -219,9 +219,13 @@ void BindLogging(py::module& m) { .value("ERROR", Logging::LogSeverity::GLOG_ERROR) .value("FATAL", Logging::LogSeverity::GLOG_FATAL) .export_values(); + #if defined(GLOG_VERSION_MAJOR) && \ (GLOG_VERSION_MAJOR > 0 || GLOG_VERSION_MINOR >= 6) if (!google::IsGoogleLoggingInitialized()) +#else + // Check whether pycolmap has already been imported. + if (!py::module_::import("sys").attr("modules").contains("pycolmap")) #endif { google::InitGoogleLogging("");