Ver código fonte

Merge pull request #159 from openfheorg/152-fix-ci

152 fix ci
yspolyakov 1 ano atrás
pai
commit
c61579823a

+ 17 - 13
CMakeLists.txt

@@ -75,20 +75,24 @@ find_package(PythonInterp REQUIRED)
 
 # Check Python version
 if(${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER_EQUAL 10)
-execute_process(
-    COMMAND "${Python_EXECUTABLE}" -c "from sys import exec_prefix; print(exec_prefix)"
-    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
-    OUTPUT_STRIP_TRAILING_WHITESPACE
- )       
+    execute_process(
+        COMMAND "${Python_EXECUTABLE}" -c "from sys import exec_prefix; print(exec_prefix)"
+        OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
 else()
-execute_process(
-    COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
-    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
-    OUTPUT_STRIP_TRAILING_WHITESPACE
- )    
+    execute_process(
+        COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
+        OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
 endif()
 
-
-
 message(STATUS "Python site packages directory: ${PYTHON_SITE_PACKAGES}")
-install(TARGETS openfhe LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+    set(Python_Install_Location "${PYTHON_SITE_PACKAGES}")
+else()
+    set(Python_Install_Location "${CMAKE_INSTALL_PREFIX}")
+endif()
+message("***** INSTALL IS AT ${Python_Install_Location}; to change, run cmake with -DCMAKE_INSTALL_PREFIX=/your/path")
+install(TARGETS openfhe LIBRARY DESTINATION ${Python_Install_Location})

+ 1 - 1
src/include/binfhe/binfhecontext_wrapper.h

@@ -63,7 +63,7 @@ std::vector<uint64_t> GenerateLUTviaFunctionWrapper(BinFHEContext &self, py::fun
 NativeInteger StaticFunction(NativeInteger m, NativeInteger p);
 
 // Define static variables to hold the state
-extern py::function static_f;
+// extern py::function static_f;
 
 LWECiphertext EvalFuncWrapper(BinFHEContext &self, ConstLWECiphertext &ct, const std::vector<uint64_t> &LUT);
 #endif // BINFHE_CRYPTOCONTEXT_BINDINGS_H

+ 4 - 3
src/lib/binfhe/binfhecontext_wrapper.cpp

@@ -77,7 +77,7 @@ const uint64_t GetLWECiphertextModulusWrapper(LWECiphertext &self)
 }
 
 // Define static variables to hold the state
-py::function static_f;
+py::function* static_f = nullptr;
 
 // Define a static function that uses the static variables
 NativeInteger StaticFunction(NativeInteger m, NativeInteger p) {
@@ -85,7 +85,7 @@ NativeInteger StaticFunction(NativeInteger m, NativeInteger p) {
     uint64_t m_int = m.ConvertToInt<uint64_t>();
     uint64_t p_int = p.ConvertToInt<uint64_t>();
     // Call the Python function
-    py::object result_py = static_f(m_int, p_int);
+    py::object result_py = (*static_f)(m_int, p_int);
     // Convert the result to a NativeInteger
     return NativeInteger(py::cast<uint64_t>(result_py));
 }
@@ -93,8 +93,9 @@ NativeInteger StaticFunction(NativeInteger m, NativeInteger p) {
 std::vector<uint64_t> GenerateLUTviaFunctionWrapper(BinFHEContext &self, py::function f, uint64_t p)
 {
     NativeInteger p_native_int = NativeInteger(p);
-    static_f = f;
+    static_f = &f;
     std::vector<NativeInteger> result = self.GenerateLUTviaFunction(StaticFunction, p_native_int);
+    static_f = nullptr;
     std::vector<uint64_t> result_uint64_t;
     // int size_int = static_cast<int>(result.size());
     for (const auto& value : result)

+ 33 - 0
utils/print-used-modules-and-libraries-linux.py

@@ -0,0 +1,33 @@
+import sys
+
+def print_python_imported_modules():
+    # print imported Python modules with their paths
+    print("          ===== imported Python modules =====")
+    for module_name, module in sorted(sys.modules.items()):
+        try:
+            module_file = module.__file__
+            if module_file:
+                print(f"{module_name}: {module_file}")
+        except AttributeError:
+            pass
+
+def print_loaded_shared_libraries():
+    # print loaded shared libraries from /proc/self/maps
+    print("          ===== loaded shared C/C++ libraries =====")
+    with open("/proc/self/maps", "r") as maps_file:
+        lines = maps_file.readlines()
+        for line in lines:
+            if ".so" in line:
+                parts = line.split()
+                if len(parts) > 5:
+                    print(parts[5])
+
+if __name__ == "__main__":
+    # import numpy
+    # import pandas
+
+    print("")
+    print_python_imported_modules()
+    print("")
+    print_loaded_shared_libraries()
+    print("")