From 8afccd766ee20c00b3eabd9f7fc3b319daab904c Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Wed, 4 Oct 2023 12:33:23 +0000 Subject: [PATCH] [PyBind] Remove env variable and use Py_IsInitialized() function. --- include/aidge/utils/Registrar.hpp | 4 ++-- python_binding/pybind_core.cpp | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/aidge/utils/Registrar.hpp b/include/aidge/utils/Registrar.hpp index de543e95a..993519f38 100644 --- a/include/aidge/utils/Registrar.hpp +++ b/include/aidge/utils/Registrar.hpp @@ -35,7 +35,7 @@ public: { #ifdef PYBIND #define _CRT_SECURE_NO_WARNINGS - if (std::getenv("AIDGE_CORE_WITH_PYBIND")){ + if (Py_IsInitialized()){ std::string name = std::string("registrar_")+typeid(Registrable<DerivedClass, Key, Func>).name(); static auto shared_data = reinterpret_cast<std::map<Key, std::function<Func>> *>(py::get_shared_data(name)); if (!shared_data) @@ -73,4 +73,4 @@ struct Registrar { }; } -#endif //AIDGE_CORE_UTILS_REGISTRAR_H_ \ No newline at end of file +#endif //AIDGE_CORE_UTILS_REGISTRAR_H_ diff --git a/python_binding/pybind_core.cpp b/python_binding/pybind_core.cpp index d1287c0a9..8bd2c51d2 100644 --- a/python_binding/pybind_core.cpp +++ b/python_binding/pybind_core.cpp @@ -48,14 +48,8 @@ void init_Recipies(py::module&); void init_Scheduler(py::module&); void init_TensorUtils(py::module&); -void set_python_flag(){ - // Set an env variable to know if we run with ypthon or cpp - py::module os_module = py::module::import("os"); - os_module.attr("environ")["AIDGE_CORE_WITH_PYBIND"] = "1"; -} void init_Aidge(py::module& m){ - set_python_flag(); init_Data(m); init_Tensor(m); -- GitLab