Skip to content

Commit 6338e43

Browse files
committed
New setup
1 parent 98b4db5 commit 6338e43

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

pyproject.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
[build-system]
3+
requires = [
4+
"setuptools>=42",
5+
"wheel",
6+
"pybind11>=2.9.1",
7+
]
8+
9+
build-backend = "setuptools.build_meta"

setup.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
import os
22
import platform
3-
from setuptools import setup, Extension
3+
from glob import glob
4+
from setuptools import setup
45
from distutils.sysconfig import get_python_inc
6+
from pybind11.setup_helpers import Pybind11Extension, build_ext
57

8+
__version__ = "4.0.0"
69

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

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

22-
if not os.path.exists(extra_objects[0]):
23-
print('Not found the seal lib file')
14+
cpp_args = ['/std:c++latest'] if platform.system() == "Windows" else ['-std=c++17']
15+
16+
if len(extra_objects) < 1 or not os.path.exists(extra_objects[0]):
17+
print('Not found the seal lib file, check the `SEAL/build/lib`')
2418
exit(0)
19+
elif len(extra_objects) > 1:
20+
print('Exists unknown extra objects, may cause exception')
2521

2622
ext_modules = [
27-
Extension(
28-
name='seal',
29-
sources=[wrapper_file],
23+
Pybind11Extension(
24+
"seal",
25+
sorted(glob('src/*.cpp')),
3026
include_dirs=include_dirs,
31-
language='c++',
3227
extra_compile_args=cpp_args,
3328
extra_objects=extra_objects,
29+
define_macros = [('VERSION_INFO', __version__)],
3430
),
3531
]
3632

3733
setup(
38-
name='seal',
39-
version='4.0',
40-
author='Huelse',
41-
author_email='[email protected]',
42-
description='Python wrapper for the Microsoft SEAL',
43-
url='https://github.com/Huelse/SEAL-Python',
44-
license='MIT',
34+
name="seal",
35+
version=__version__,
36+
author="Huelse",
37+
author_email="[email protected]",
38+
url="https://github.com/Huelse/SEAL-Python",
39+
description="Python wrapper for the Microsoft SEAL",
40+
long_description="",
4541
ext_modules=ext_modules,
42+
cmdclass={"build_ext": build_ext},
43+
zip_safe=False,
44+
license='MIT',
45+
python_requires=">=3.6",
4646
)

src/wrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ PYBIND11_MAKE_OPAQUE(std::vector<std::int64_t>);
1313

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

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

0 commit comments

Comments
 (0)