forked from lpp-crypto/sboxU
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
79 lines (64 loc) · 2.33 KB
/
setup.py
File metadata and controls
79 lines (64 loc) · 2.33 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import sys
import re
import multiprocessing
from setuptools import find_packages, setup
from setuptools.extension import Extension
from Cython.Build import cythonize
DEBUG = os.environ.get("DEBUG", "0") == "1"
# !SECTION! Setting up the compilation of the C++ part
if sys.platform == 'darwin': #macOs
os.environ["CC"] = "clang"
os.environ["CXX"] = "clang++"
else:
os.environ["CC"] = "g++"
os.environ["CXX"] = "g++"
extra_compile_args = ["-O3", "-march=native", "-std=c++20", "-pthread", "-Wno-narrowing", "-w"] #narrowing warnings in fp_lat when calling shape_t{p}
extra_link_args=[]
if sys.platform == 'darwin':
extra_compile_args += ['-lomp', '-I/opt/homebrew/opt/libomp/include']
extra_link_args += ['-lomp', '-L/opt/homebrew/opt/libomp/lib']
else:
extra_compile_args += ['-fopenmp']
extra_link_args += ['-fopenmp']
if DEBUG :
extra_compile_args+=["-g", "-O1", "-fsanitize=address"]
extra_link_args+=["-fsanitize=address"]
# !SECTION! Declaring cython extensions
def declare_cython(full_module_name):
src = re.sub(r"\.", r"/", full_module_name) + ".pyx"
return Extension(
full_module_name,
sources = [ src ],
language = "c++",
extra_link_args = extra_link_args,
extra_compile_args = extra_compile_args,
)
# !WARNING! The order of the modules in the list below is very important!
# ! Do not use cross dependencies in cython modules.
# ! It is crucial that the module with index i only depends on modules with indices j with j<i
all_cython_extensions = [ declare_cython(name) for name in [
"sboxU.core.f2functions.cython_functions",
"sboxU.core.spectrum.cython_functions",
"sboxU.core.sbox.cython_functions",
"sboxU.core.anf.cython_functions",
"sboxU.core.building_blocks.cython_functions",
"sboxU.algorithms.cython_functions",
"sboxU.statistics.cython_functions",
"sboxU.ccz.cython_functions",
"sboxU.ccz.affine_equivalence.cython_functions",
"sboxU.apn.cython_functions",
]]
# !SECTION! Final setup
setup( # names and others are specified in the pyproject.toml file
packages=find_packages(),
ext_modules=cythonize(
all_cython_extensions,
language_level = "3",
gdb_debug=DEBUG,
compiler_directives={
"linetrace": DEBUG,
"binding": DEBUG,
},
),
)