Giter VIP home page Giter VIP logo

openfhe-python's Introduction

Official Python wrapper for OpenFHE

Table of Contents

Running from Docker

Please see Instructions for the Docker setup

Building from Source

Requirements

Before building, make sure you have the following dependencies installed:

We recommend following OpenFHE C++ installation instructions first (which covers Linux, Windows and MacOS) and then getting back to this repo. See notes on installing pybind11 below

Linux

System-level installation

To install OpenFHE-python directly to your system, ensure the dependencies are set up. Then clone the repository, open a terminal in the repo folder and run the following commands:

pip install "pybind11[global]" 
mkdir build
cd build
cmake ..  # Alternatively, cmake .. -DOpenFHE_DIR=/path/to/installed/openfhe if you installed OpenFHE elsewhere
make
make install  # You may have to run sudo make install

At this point the .so file has been built. Your exact installation process will depend on your virtual environment. Cmake will automatically find the python installation path, if unwanted, you can specify the python path by adding -DPYTHON_EXECUTABLE_PATH=/path/to/python to the cmake command.

If you see an error saying that one of OpenFHE .so files cannot be found when running a Python example (occurs only for some environments), add the path where the .so files reside to the PYTHONPATH environment variable:

export PYTHONPATH=(path_to_OpenFHE_so_files):$PYTHONPATH

In some environments (this happens rarely), it may also be necessary to add the OpenFHE libraries path to LD_LIBRARY_PATH.

Conda

Alternatively you can install the library and handle the linking via Conda. Clone the repository, open a terminal in the repo folder and run the following commands:

conda create -n ${ENV_NAME} python=3.{X} anaconda

where ${ENV_NAME} should be replaced with the name of your environment, and {X} should be replaced with your desired python version. For example you might have conda create -n openfhe_python python=3.9 anaconda. Now, you would install pybind11 either via:

pip install "pybind11[global]" or via conda install -c conda-forge pybind11, but for now we recommend using the first method, with pip. Some users have reported issues when using the conda pybind11

Now, you would clone the repository, and run the following commands to install :

mkdir build
cd build
cmake .. # Add in -DOpenFHE_DIR=/path/to/installed/openfhe if you installed OpenFHE elsewhere
make
make install  # You may have to run sudo make install

Then, you can develop the library to link

cd ..
mkdir lib
mv *.so lib
conda develop lib

which creates a lib folder, moves the built .so file into that lib folder, and tells conda where to look for external libraries.

Note You may wish to copy the .so file to any projects of your own, or add it to your system path to source from.

Running Tests

Run tests with pytest, which may be called pytest-3 on your system. See the testing readme for more information.

pytest [--run-long]

Code Examples

To get familiar with the OpenFHE Python API, check out the examples:

OpenFHE Python Wrapper Documentation

OpenFHE Python Wrapper API Reference

Contributing Guide

OpenFHE Development - Contributing Guide

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.