Backport fixes from wolfcrypt-py

* Make wolfSSL a submodule
* Fix sdist packaging
* Make tox work on all py3 releases and remove pep8 for now
pull/24/head
Andrew Hutchings 2022-01-31 14:56:55 +00:00
parent f7072afbb3
commit 1aa226bff0
7 changed files with 22 additions and 25 deletions

1
.gitignore vendored
View File

@ -16,7 +16,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/

3
.gitmodules vendored 100644
View File

@ -0,0 +1,3 @@
[submodule "lib/wolfssl"]
path = lib/wolfssl
url = https://github.com/wolfssl/wolfssl

View File

@ -30,13 +30,13 @@ clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and
clean-build: ## remove build artifacts
rm -fr lib/
rm -fr build/
rm -fr dist/
rm -fr .eggs/
rm -fr wolfssl/_ffi*
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
-cd lib/wolfssl && make clean
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +

1
lib/wolfssl 160000

@ -0,0 +1 @@
Subproject commit c3513bf2573c30f6d2df815de216120e92142020

View File

@ -27,10 +27,6 @@ from setuptools import setup
from setuptools.command.build_ext import build_ext
# Adding src folder to the include path in order to import from wolfssl
package_dir = os.path.dirname(__file__)
sys.path.insert(0, package_dir)
import wolfssl
from wolfssl._build_wolfssl import build_wolfssl
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
@ -90,7 +86,6 @@ setup(
license=wolfssl.__license__,
packages=["wolfssl"],
package_dir={"":package_dir},
zip_safe=False,
cffi_modules=["./wolfssl/_build_ffi.py:ffi"],

View File

@ -1,6 +1,5 @@
[tox]
envlist = py39, pep8
skipsdist = True
envlist = py3
[testenv]
setenv =

View File

@ -34,14 +34,13 @@ def local_path(path):
return os.path.abspath(os.path.join(current, path))
WOLFSSL_GIT_ADDR = "https://github.com/wolfssl/wolfssl.git"
WOLFSSL_SRC_PATH = local_path("lib/wolfssl/src")
WOLFSSL_SRC_PATH = local_path("lib/wolfssl")
def wolfssl_inc_path():
wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL")
if wolfssl_path is None:
return local_path("lib/wolfssl/src")
return local_path("lib/wolfssl")
else:
if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path):
return wolfssl_path + "/include"
@ -86,20 +85,17 @@ def chdir(new_path, mkdir=False):
os.chdir(old_path)
def clone_wolfssl(ref):
""" Clone wolfSSL C library repository
"""
call("git clone --depth=1 --branch={} {} {}".format(
ref, WOLFSSL_GIT_ADDR, WOLFSSL_SRC_PATH))
def checkout_ref(ref):
""" Ensure that we have the right version
"""
with chdir(WOLFSSL_SRC_PATH):
current = subprocess.check_output(
["git", "describe", "--all", "--exact-match"]
).strip().decode().split('/')[-1]
current = ""
try:
current = subprocess.check_output(
["git", "describe", "--all", "--exact-match"]
).strip().decode().split('/')[-1]
except:
pass
if current != ref:
tags = subprocess.check_output(
@ -119,9 +115,13 @@ def checkout_ref(ref):
def ensure_wolfssl_src(ref):
""" Ensure that wolfssl sources are presents and up-to-date
"""
if not os.path.isdir(WOLFSSL_SRC_PATH):
clone_wolfssl(ref)
return True
if not os.path.isdir("lib"):
os.mkdir("lib")
with chdir("lib"):
subprocess.run(["git", "clone", "--depth=1", "https://github.com/wolfssl/wolfssl"])
if not os.path.isdir(os.path.join(WOLFSSL_SRC_PATH, "wolfssl")):
subprocess.run(["git", "submodule", "update", "--init", "--depth=1"])
return checkout_ref(ref)