Skip to content

Commit c615798

Browse files
authored
Merge pull request #159 from openfheorg/152-fix-ci
152 fix ci
2 parents b8eee59 + d40a30c commit c615798

File tree

4 files changed

+55
-17
lines changed

4 files changed

+55
-17
lines changed

CMakeLists.txt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,24 @@ find_package(PythonInterp REQUIRED)
7575

7676
# Check Python version
7777
if(${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER_EQUAL 10)
78-
execute_process(
79-
COMMAND "${Python_EXECUTABLE}" -c "from sys import exec_prefix; print(exec_prefix)"
80-
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
81-
OUTPUT_STRIP_TRAILING_WHITESPACE
82-
)
78+
execute_process(
79+
COMMAND "${Python_EXECUTABLE}" -c "from sys import exec_prefix; print(exec_prefix)"
80+
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
81+
OUTPUT_STRIP_TRAILING_WHITESPACE
82+
)
8383
else()
84-
execute_process(
85-
COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
86-
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
87-
OUTPUT_STRIP_TRAILING_WHITESPACE
88-
)
84+
execute_process(
85+
COMMAND "${Python_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
86+
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
87+
OUTPUT_STRIP_TRAILING_WHITESPACE
88+
)
8989
endif()
9090

91-
92-
9391
message(STATUS "Python site packages directory: ${PYTHON_SITE_PACKAGES}")
94-
install(TARGETS openfhe LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})
92+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
93+
set(Python_Install_Location "${PYTHON_SITE_PACKAGES}")
94+
else()
95+
set(Python_Install_Location "${CMAKE_INSTALL_PREFIX}")
96+
endif()
97+
message("***** INSTALL IS AT ${Python_Install_Location}; to change, run cmake with -DCMAKE_INSTALL_PREFIX=/your/path")
98+
install(TARGETS openfhe LIBRARY DESTINATION ${Python_Install_Location})

src/include/binfhe/binfhecontext_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std::vector<uint64_t> GenerateLUTviaFunctionWrapper(BinFHEContext &self, py::fun
6363
NativeInteger StaticFunction(NativeInteger m, NativeInteger p);
6464

6565
// Define static variables to hold the state
66-
extern py::function static_f;
66+
// extern py::function static_f;
6767

6868
LWECiphertext EvalFuncWrapper(BinFHEContext &self, ConstLWECiphertext &ct, const std::vector<uint64_t> &LUT);
6969
#endif // BINFHE_CRYPTOCONTEXT_BINDINGS_H

src/lib/binfhe/binfhecontext_wrapper.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,25 @@ const uint64_t GetLWECiphertextModulusWrapper(LWECiphertext &self)
7777
}
7878

7979
// Define static variables to hold the state
80-
py::function static_f;
80+
py::function* static_f = nullptr;
8181

8282
// Define a static function that uses the static variables
8383
NativeInteger StaticFunction(NativeInteger m, NativeInteger p) {
8484
// Convert the arguments to int
8585
uint64_t m_int = m.ConvertToInt<uint64_t>();
8686
uint64_t p_int = p.ConvertToInt<uint64_t>();
8787
// Call the Python function
88-
py::object result_py = static_f(m_int, p_int);
88+
py::object result_py = (*static_f)(m_int, p_int);
8989
// Convert the result to a NativeInteger
9090
return NativeInteger(py::cast<uint64_t>(result_py));
9191
}
9292

9393
std::vector<uint64_t> GenerateLUTviaFunctionWrapper(BinFHEContext &self, py::function f, uint64_t p)
9494
{
9595
NativeInteger p_native_int = NativeInteger(p);
96-
static_f = f;
96+
static_f = &f;
9797
std::vector<NativeInteger> result = self.GenerateLUTviaFunction(StaticFunction, p_native_int);
98+
static_f = nullptr;
9899
std::vector<uint64_t> result_uint64_t;
99100
// int size_int = static_cast<int>(result.size());
100101
for (const auto& value : result)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys
2+
3+
def print_python_imported_modules():
4+
# print imported Python modules with their paths
5+
print(" ===== imported Python modules =====")
6+
for module_name, module in sorted(sys.modules.items()):
7+
try:
8+
module_file = module.__file__
9+
if module_file:
10+
print(f"{module_name}: {module_file}")
11+
except AttributeError:
12+
pass
13+
14+
def print_loaded_shared_libraries():
15+
# print loaded shared libraries from /proc/self/maps
16+
print(" ===== loaded shared C/C++ libraries =====")
17+
with open("/proc/self/maps", "r") as maps_file:
18+
lines = maps_file.readlines()
19+
for line in lines:
20+
if ".so" in line:
21+
parts = line.split()
22+
if len(parts) > 5:
23+
print(parts[5])
24+
25+
if __name__ == "__main__":
26+
# import numpy
27+
# import pandas
28+
29+
print("")
30+
print_python_imported_modules()
31+
print("")
32+
print_loaded_shared_libraries()
33+
print("")

0 commit comments

Comments
 (0)