add USE_LOCAL_WOLFSSL to allow use of local wolfSSL library install

pull/8/head
Chris Conlon 2019-01-03 13:06:20 -08:00
parent d26781d774
commit 0ca4dd9a08
4 changed files with 32 additions and 5 deletions

View File

@ -63,7 +63,11 @@ class cffiBuilder(build_ext, object):
def build_extension(self, ext):
""" Compile manually the wolfssl-py extension, bypass setuptools
"""
build_wolfssl(wolfssl.__wolfssl_version__)
# if USE_LOCAL_WOLFSSL environment variable has been defined,
# do not clone and compile wolfSSL from GitHub
if os.environ.get("USE_LOCAL_WOLFSSL") is None:
build_wolfssl(wolfssl.__wolfssl_version__)
super(cffiBuilder, self).build_extension(ext)

View File

@ -375,6 +375,7 @@ class SSLSocket(object):
self.ciphers = ciphers
self.server_hostname = server_hostname
# set SNI if passed in
if server_hostname is not None:
self._context.use_sni(server_hostname)

View File

@ -25,7 +25,7 @@
from distutils.util import get_platform
from cffi import FFI
from wolfssl.__about__ import __wolfssl_version__ as version
from wolfssl._build_wolfssl import local_path
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
ffi = FFI()
@ -35,9 +35,8 @@ ffi.set_source(
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>
""",
include_dirs=[local_path("lib/wolfssl/src")],
library_dirs=[local_path("lib/wolfssl/{}/{}/lib".format(
get_platform(), version))],
include_dirs=[wolfssl_inc_path()],
library_dirs=[wolfssl_lib_path()],
libraries=["wolfssl"],
)

View File

@ -37,6 +37,29 @@ WOLFSSL_GIT_ADDR = "https://github.com/wolfssl/wolfssl.git"
WOLFSSL_SRC_PATH = local_path("lib/wolfssl/src")
def wolfssl_inc_path():
wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL")
if wolfssl_path is None:
return local_path("lib/wolfssl/src")
else:
if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path):
return wolfssl_path + "/include"
else:
return "/usr/local/include"
def wolfssl_lib_path():
wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL")
if wolfssl_path is None:
return local_path("lib/wolfssl/{}/{}/lib".format(
get_platform(), version))
else:
if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path):
return wolfssl_path + "/lib"
else:
return "/usr/local/lib"
def call(cmd):
print("Calling: '{}' from working directory {}".format(cmd, os.getcwd()))