|
1 | 1 | import os
|
2 | 2 | import platform
|
3 |
| -from setuptools import setup, Extension |
| 3 | +from glob import glob |
| 4 | +from setuptools import setup |
4 | 5 | from distutils.sysconfig import get_python_inc
|
| 6 | +from pybind11.setup_helpers import Pybind11Extension, build_ext |
5 | 7 |
|
| 8 | +__version__ = "4.0.0" |
6 | 9 |
|
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'] |
17 | 11 |
|
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')) |
21 | 13 |
|
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`') |
24 | 18 | exit(0)
|
| 19 | +elif len(extra_objects) > 1: |
| 20 | + print('Exists unknown extra objects, may cause exception') |
25 | 21 |
|
26 | 22 | ext_modules = [
|
27 |
| - Extension( |
28 |
| - name='seal', |
29 |
| - sources=[wrapper_file], |
| 23 | + Pybind11Extension( |
| 24 | + "seal", |
| 25 | + sorted(glob('src/*.cpp')), |
30 | 26 | include_dirs=include_dirs,
|
31 |
| - language='c++', |
32 | 27 | extra_compile_args=cpp_args,
|
33 | 28 | extra_objects=extra_objects,
|
| 29 | + define_macros = [('VERSION_INFO', __version__)], |
34 | 30 | ),
|
35 | 31 | ]
|
36 | 32 |
|
37 | 33 | setup(
|
38 |
| - name='seal', |
39 |
| - version='4.0', |
40 |
| - author='Huelse', |
41 |
| - |
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 | + |
| 38 | + url="https://github.com/Huelse/SEAL-Python", |
| 39 | + description="Python wrapper for the Microsoft SEAL", |
| 40 | + long_description="", |
45 | 41 | ext_modules=ext_modules,
|
| 42 | + cmdclass={"build_ext": build_ext}, |
| 43 | + zip_safe=False, |
| 44 | + license='MIT', |
| 45 | + python_requires=">=3.6", |
46 | 46 | )
|
0 commit comments