Skip to content
Snippets Groups Projects
Commit ff2f5870 authored by Florian Klien's avatar Florian Klien
Browse files

fixing Cypthon dependency

force setuptools to install Cython if it's not installed
parent ff2aa5fc
No related branches found
No related tags found
No related merge requests found
......@@ -4,39 +4,59 @@ import subprocess
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
from Cython.Build import cythonize
CYTHON_VERSION = 'Cython==0.27.2'
class prepare_tinydtls(build_ext):
def run(self):
def run_command(args):
print("Running:", " ".join(args))
subprocess.check_call(args, cwd=os.path.join(os.path.dirname(__file__), "DTLSSocket","tinydtls"))
commands = [
["autoconf"],
["autoheader"],
["./configure", "--without-ecc"],
]
commands = [
["autoconf"],
["autoheader"],
["./configure", "--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)
cy_build = cythonize([
Extension("DTLSSocket.dtls",
["DTLSSocket/dtls.pyx",
"DTLSSocket/tinydtls/dtls.c", "DTLSSocket/tinydtls/crypto.c",
"DTLSSocket/tinydtls/ccm.c", "DTLSSocket/tinydtls/hmac.c", "DTLSSocket/tinydtls/netq.c",
"DTLSSocket/tinydtls/peer.c", "DTLSSocket/tinydtls/dtls_time.c",
"DTLSSocket/tinydtls/session.c", "DTLSSocket/tinydtls/dtls_debug.c",
"DTLSSocket/tinydtls/aes/rijndael.c", "DTLSSocket/tinydtls/sha2/sha2.c"],
include_dirs=['DTLSSocket/tinydtls'],
define_macros=[('DTLSv12', '1'),
('WITH_SHA256', '1'),
('DTLS_CHECK_CONTENTTYPE', '1'),
('_GNU_SOURCE', '1')],
undef_macros = [ "NDEBUG" ],
)])
# force setuptools to install Cython before proceeding
try:
from Cython.Build import cythonize
except:
from setuptools.dist import Distribution
Distribution(dict(setup_requires=CYTHON_VERSION))
def get_ext_modules():
from Cython.Build import cythonize
return cythonize([
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/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"
],
include_dirs=['DTLSSocket/tinydtls'],
define_macros=[('DTLSv12', '1'),
('WITH_SHA256', '1'),
('DTLS_CHECK_CONTENTTYPE', '1'),
('_GNU_SOURCE', '1')],
undef_macros = [ "NDEBUG" ],
)])
ext_modules = get_ext_modules()
setup(
name="DTLSSocket",
......@@ -47,7 +67,6 @@ setup(
url = "https://git.fslab.de/jkonra2m/tinydtls-cython",
py_modules = [ "DTLSSocket.DTLSSocket"],
cmdclass = {"build_ext": prepare_tinydtls},
ext_modules = cy_build,
setup_requires = [ "Cython==0.27.2" ],
install_requires = [ "Cython==0.27.2" ],
ext_modules = ext_modules,
setup_requires = [ CYTHON_VERSION ],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment