Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
102 lines (85 loc) · 2.94 KB
/
Copy pathsetup.py
File metadata and controls
102 lines (85 loc) · 2.94 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import shutil
import re
import sys
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.develop import develop as _develop
from distutils.command.clean import clean as _clean
def paramsets():
pattern = "params-sphincs-([a-zA-Z-][a-zA-Z0-9-]*).h"
pfiles = os.listdir(os.path.join("src", "sphincsplus", "ref", "params"))
for paramset in pfiles:
try:
yield re.search(pattern, paramset).group(1).replace('-', '_')
except AttributeError:
raise Exception("Cannot parse name of parameter set {}"
.format(paramset))
def create_param_wrappers():
for paramset in paramsets():
with open(os.path.join("src", "pyspx", paramset + ".py"), 'w') as f:
f.write(
"from pyspx.bindings import PySPXBindings as _PySPXBindings\n"
"from _spx_{} import ffi as _ffi, lib as _lib\n"
"\n"
"import sys\n"
"\n"
"sys.modules[__name__] = _PySPXBindings(_ffi, _lib)\n"
.format(paramset)
)
class build_py(_build_py):
def run(self):
create_param_wrappers()
_build_py.run(self)
class develop(_develop):
def run(self):
create_param_wrappers()
_develop.run(self)
class clean(_clean):
def run(self):
for paramset in paramsets():
try:
os.remove(os.path.join("src", "pyspx", paramset + ".py"))
except:
pass
if sys.version_info[0] < 3:
objname = "_spx_{}.so".format(paramset)
else:
objname = "_spx_{}.abi3.so".format(paramset)
try:
os.remove(os.path.join("src", objname))
except:
pass
shutil.rmtree(os.path.join("src", "sphincsplus-instances"))
_clean.run(self)
with open('README.md') as f:
long_description = f.read()
setup(
name="PySPX",
version="0.5.0",
packages=['pyspx'],
author="Joost Rijneveld, Peter Schwabe, Ruben Gonzalez",
author_email='contact@sphincs.org',
url="https://github.com/sphincs/pyspx",
description='Python bindings for SPHINCS+',
long_description=long_description,
long_description_content_type="text/markdown",
package_dir={'': 'src'},
classifiers=[
'Topic :: Security :: Cryptography',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
'Programming Language :: Python :: 3',
],
install_requires=["cffi>=1.0.0"],
setup_requires=["cffi>=1.0.0"],
tests_require=["pytest", "cffi>=1.0.0"],
cffi_modules=["src/pyspx/build.py:{}".format(x) for x in paramsets()],
cmdclass={
"build_py": build_py,
"develop": develop,
"clean": clean,
},
zip_safe=False,
)