Skip to content

Commit

Permalink
Fix openfheorg#174 Install openfhe as a pip package in Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Thadah committed Sep 24, 2024
1 parent c1504f3 commit 073bbeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=''):
Expand All @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit 073bbeb

Please sign in to comment.