forked from mclab-hbrs/DTLSSocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
70 lines (65 loc) · 2.77 KB
/
setup.py
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
import os.path
import subprocess
import sys
from setuptools import setup
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
class prepare_tinydtls(build_ext):
def run(self):
def run_command(args):
print("Running:", " ".join(args))
try:
subprocess.check_call(args, cwd=os.path.join(os.path.dirname(__file__), "DTLSSocket","tinydtls"))
except Exception as e:
print(f"Trying to run {args[0]} failed, please make sure {args[0]} is installed")
sys.exit(1)
commands = [
["sh", "-c", "autoconf"],
["sh", "-c", "autoheader"],
["sh", "-c", "./configure"], # no --without-ecc
]
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'DTLSSocket','tinydtls','dtls.c')):
run_command(["git", "submodule", "update", "--init"])
for command in commands:
run_command(command)
build_ext.run(self)
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="DTLSSocket",
version='0.1.17',
description = "DTLSSocket is a cython wrapper for tinydtls with a Socket like interface",
long_description=long_description,
long_description_content_type="text/markdown",
author = "Jannis Konrad",
author_email= "[email protected]",
url = "https://git.fslab.de/jkonra2m/tinydtls-cython",
py_modules = [ "DTLSSocket.DTLSSocket"],
cmdclass = {"build_ext": prepare_tinydtls},
ext_modules = [Extension("DTLSSocket.dtls",
[
"DTLSSocket/dtls.pyx",
"DTLSSocket/tinydtls/ccm.c",
"DTLSSocket/tinydtls/crypto.c",
"DTLSSocket/tinydtls/dtls.c",
"DTLSSocket/tinydtls/dtls_debug.c",
"DTLSSocket/tinydtls/ecc/ecc.c",
"DTLSSocket/tinydtls/dtls_time.c",
"DTLSSocket/tinydtls/hmac.c",
"DTLSSocket/tinydtls/netq.c",
"DTLSSocket/tinydtls/peer.c",
"DTLSSocket/tinydtls/session.c",
"DTLSSocket/tinydtls/aes/rijndael.c",
"DTLSSocket/tinydtls/sha2/sha2.c",
"DTLSSocket/tinydtls/platform-specific/dtls_prng_posix.c",
],
include_dirs=['DTLSSocket/tinydtls'],
define_macros=[('DTLSv12', '1'),
('WITH_SHA256', '1'),
('DTLS_CHECK_CONTENTTYPE', '1'),
('_GNU_SOURCE', '1'),
('NDEBUG', '1'),
],
# undef_macros = [ "NDEBUG" ],
),]
)