From 073bbebe317d22b0c1ec19110d7cdc2f1696cb69 Mon Sep 17 00:00:00 2001 From: "Thadah D. Denyse" Date: Tue, 24 Sep 2024 15:41:58 +0200 Subject: [PATCH] Fix #174 Install openfhe as a pip package in Docker --- docker/Dockerfile | 4 ++++ setup.py | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 65feee0..c351f06 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -44,6 +44,10 @@ RUN git clone https://github.com/openfheorg/openfhe-python.git \ && make -j$(nproc) \ && make install +# Install openfhe as a pip package +WORKDIR /openfhe-python +RUN python3 setup.py sdist bdist_wheel && pip install dist/openfhe-*.whl + # Expose the port JupyterLab will listen on EXPOSE 8888 diff --git a/setup.py b/setup.py index 062672c..af09a2c 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,9 @@ import glob import shutil -__version__ = '0.8.4' +__version__ = '0.9.0' +OPENFHE_PATH = 'openfhe/' +OPENFHE_LIB = 'openfhe.so' class CMakeExtension(Extension): def __init__(self, name, sourcedir=''): @@ -22,7 +24,7 @@ def run(self): self.build_cmake(ext) def build_cmake(self, ext): - if os.path.exists('openfhe/openfhe.so'): + if os.path.exists(OPENFHE_PATH + OPENFHE_LIB): return extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) print(extdir) @@ -46,14 +48,14 @@ def build_cmake(self, ext): raise RuntimeError("Cannot find any built .so file in " + extdir) src_file = so_files[0] - dst_file = os.path.join('openfhe', 'openfhe.so') + dst_file = os.path.join('openfhe', OPENFHE_LIB) shutil.move(src_file, dst_file) # Run build_ext before sdist class SDist(_sdist): def run(self): - if os.path.exists('openfhe/openfhe.so'): - os.remove('openfhe/openfhe.so') + if os.path.exists(OPENFHE_PATH + OPENFHE_LIB): + os.remove(OPENFHE_PATH + OPENFHE_LIB) self.run_command('build_ext') super().run()