forked from softwareQinc/staq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
59 lines (45 loc) · 1.47 KB
/
setup.py
File metadata and controls
59 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup
import ctypes as ct # to call native
import ctypes.util as ctu
import platform # to learn the OS we're on
extra_compile_args = ["-Ilibs", "-Iinclude", "-Iqasmtools/include"]
extra_links_args = []
def _load_shared_obj(name):
"""Attempts to load native OQS library."""
paths = []
# search typical locations
paths += [ctu.find_library(name)]
paths += [ctu.find_library("lib" + name)]
dll = ct.windll if platform.system() == "Windows" else ct.cdll
for path in paths:
if path:
lib = dll.LoadLibrary(path)
return lib
raise RuntimeError("No " + name + " shared libraries found")
found_GMP = True
try:
_libgmp = _load_shared_obj("gmp")
_libgmpxx = _load_shared_obj("gmpxx")
except:
found_GMP = False
if found_GMP:
extra_compile_args.append("-DGRID_SYNTH")
extra_compile_args.append("-DEXPR_GMP")
extra_links_args = ["-lgmp", "-lgmpxx"]
# If the platform seem to be MSVC
if sys.platform == "win32" and not sys.platform == "cygwin" and not sys.platform == "msys":
extra_compile_args.append("-Ilibs/pthreadwin32")
ext_modules = [
Pybind11Extension(
"pystaq",
["pystaq/staq_wrapper.cpp"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_links_args,
cxx_std=17,
include_pybind11=False,
),
]
setup(platforms=sys.platform,
ext_modules=ext_modules)