Skip to content

Commit df4b4b7

Browse files
committed
Fix build warning
1 parent abdf8f4 commit df4b4b7

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Microsoft SEAL For Python
22

3+
This is a python binding for the Microsoft SEAL library.
4+
35
Microsoft [**SEAL**](https://github.com/microsoft/SEAL) is an easy-to-use open-source ([MIT licensed](https://github.com/microsoft/SEAL/blob/master/LICENSE)) homomorphic encryption library developed by the Cryptography Research group at Microsoft.
46

57
[**pybind11**](https://github.com/pybind/pybind11) is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code.
68

7-
This is a python binding for the Microsoft SEAL library.
8-
99
[![Supported Versions](https://img.shields.io/pypi/pyversions/SEAL-Python.svg)](https://github.com/Huelse/SEAL-Python)
1010

1111

@@ -35,6 +35,16 @@ python -m pip install seal-python
3535

3636
## Build
3737

38+
On macOS, use the same deployment target for both the SEAL static library and the Python extension to avoid linker warnings about mismatched macOS versions:
39+
40+
```shell
41+
export MACOSX_DEPLOYMENT_TARGET=$(python3 - <<'PY'
42+
import sysconfig
43+
print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") or "15.0")
44+
PY
45+
)
46+
```
47+
3848
* ### Linux
3949

4050
Recommend: Clang++ (>= 10.0) or GNU G++ (>= 9.4), CMake (>= 3.16)
@@ -58,6 +68,8 @@ python -m pip install seal-python
5868
# Build the SEAL lib without the msgsl zlib and zstandard compression
5969
cd SEAL
6070
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
71+
# macOS:
72+
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
6173
cmake --build build
6274
cd ..
6375

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55
from shutil import copy2
66
import sys
7+
import sysconfig
78
from setuptools import setup
89
from distutils.sysconfig import get_python_inc
910
import pybind11
@@ -24,6 +25,17 @@
2425
extra_objects = sorted(glob('SEAL/build/lib/*.a'))
2526

2627
cpp_args = ['/std:c++17', '/utf-8', '/bigobj'] if platform.system() == "Windows" else ['-std=c++17']
28+
link_args = []
29+
30+
if platform.system() == "Darwin":
31+
deployment_target = os.environ.get("MACOSX_DEPLOYMENT_TARGET") or sysconfig.get_config_var(
32+
"MACOSX_DEPLOYMENT_TARGET"
33+
)
34+
if deployment_target:
35+
deployment_flag = f"-mmacosx-version-min={deployment_target}"
36+
os.environ.setdefault("MACOSX_DEPLOYMENT_TARGET", deployment_target)
37+
cpp_args.append(deployment_flag)
38+
link_args.append(deployment_flag)
2739

2840
if len(extra_objects) < 1 or not os.path.exists(extra_objects[0]):
2941
print('Not found the seal lib file, check the "SEAL/build/lib"')
@@ -60,6 +72,7 @@ def _copy_typing_files(self):
6072
sorted(glob('src/*.cpp')),
6173
include_dirs=include_dirs,
6274
extra_compile_args=cpp_args,
75+
extra_link_args=link_args,
6376
extra_objects=extra_objects,
6477
define_macros=[('VERSION_INFO', __version__)],
6578
),
@@ -83,7 +96,6 @@ def _copy_typing_files(self):
8396
"Development Status :: 4 - Beta",
8497
"Intended Audience :: Developers",
8598
"Intended Audience :: Science/Research",
86-
"License :: OSI Approved :: MIT License",
8799
"Programming Language :: Python :: 3",
88100
"Programming Language :: Python :: 3 :: Only",
89101
"Programming Language :: Python :: 3.8",

0 commit comments

Comments
 (0)