Skip to content

Commit

Permalink
New setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Huelse committed Apr 5, 2022
1 parent 98b4db5 commit 6338e43
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[build-system]
requires = [
"setuptools>=42",
"wheel",
"pybind11>=2.9.1",
]

build-backend = "setuptools.build_meta"
54 changes: 27 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import os
import platform
from setuptools import setup, Extension
from glob import glob
from setuptools import setup
from distutils.sysconfig import get_python_inc
from pybind11.setup_helpers import Pybind11Extension, build_ext

__version__ = "4.0.0"

# python include dir
py_include_dir = os.path.join(get_python_inc())
# cpp flags
cpp_args = ['-std=c++17']
# include directories
include_dirs = [py_include_dir, './pybind11/include', './SEAL/native/src', './SEAL/build/native/src']
# library path
extra_objects = ['./SEAL/build/lib/libseal-4.0.a']
# available wrapper: src/wrapper.cpp, src/wrapper_with_pickle.cpp
wrapper_file = 'src/wrapper.cpp'
include_dirs = [get_python_inc(), 'pybind11/include', 'SEAL/native/src', 'SEAL/build/native/src']

if platform.system() == "Windows":
cpp_args[0] = '/std:c++latest' # /std:c++1z
extra_objects[0] = './SEAL/build/lib/seal-4.0.lib'
extra_objects = sorted(glob('SEAL/build/lib/*.lib') if platform.system() == "Windows" else glob('SEAL/build/lib/*.a'))

if not os.path.exists(extra_objects[0]):
print('Not found the seal lib file')
cpp_args = ['/std:c++latest'] if platform.system() == "Windows" else ['-std=c++17']

if len(extra_objects) < 1 or not os.path.exists(extra_objects[0]):
print('Not found the seal lib file, check the `SEAL/build/lib`')
exit(0)
elif len(extra_objects) > 1:
print('Exists unknown extra objects, may cause exception')

ext_modules = [
Extension(
name='seal',
sources=[wrapper_file],
Pybind11Extension(
"seal",
sorted(glob('src/*.cpp')),
include_dirs=include_dirs,
language='c++',
extra_compile_args=cpp_args,
extra_objects=extra_objects,
define_macros = [('VERSION_INFO', __version__)],
),
]

setup(
name='seal',
version='4.0',
author='Huelse',
author_email='huelse@oini.top',
description='Python wrapper for the Microsoft SEAL',
url='https://github.com/Huelse/SEAL-Python',
license='MIT',
name="seal",
version=__version__,
author="Huelse",
author_email="topmaxz@protonmail.com",
url="https://github.com/Huelse/SEAL-Python",
description="Python wrapper for the Microsoft SEAL",
long_description="",
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext},
zip_safe=False,
license='MIT',
python_requires=">=3.6",
)
3 changes: 2 additions & 1 deletion src/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ PYBIND11_MAKE_OPAQUE(std::vector<std::int64_t>);

PYBIND11_MODULE(seal, m)
{
m.doc() = "Microsoft SEAL (4.0) for Python, from https://github.com/Huelse/SEAL-Python";
m.doc() = "Microsoft SEAL for Python, from https://github.com/Huelse/SEAL-Python";
m.attr("__version__") = "4.0.0";

py::bind_vector<std::vector<double>>(m, "VectorDouble", py::buffer_protocol());
py::bind_vector<std::vector<std::int64_t>>(m, "VectorInt", py::buffer_protocol());
Expand Down

0 comments on commit 6338e43

Please sign in to comment.