Skip to content

Commit 1aa226b

Browse files
committed
Backport fixes from wolfcrypt-py
* Make wolfSSL a submodule * Fix sdist packaging * Make tox work on all py3 releases and remove pep8 for now
1 parent f7072af commit 1aa226b

7 files changed

Lines changed: 22 additions & 25 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dist/
1616
downloads/
1717
eggs/
1818
.eggs/
19-
lib/
2019
lib64/
2120
parts/
2221
sdist/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/wolfssl"]
2+
path = lib/wolfssl
3+
url = https://github.com/wolfssl/wolfssl

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and
3030

3131

3232
clean-build: ## remove build artifacts
33-
rm -fr lib/
3433
rm -fr build/
3534
rm -fr dist/
3635
rm -fr .eggs/
3736
rm -fr wolfssl/_ffi*
3837
find . -name '*.egg-info' -exec rm -fr {} +
3938
find . -name '*.egg' -exec rm -f {} +
39+
-cd lib/wolfssl && make clean
4040

4141
clean-pyc: ## remove Python file artifacts
4242
find . -name '*.pyc' -exec rm -f {} +

lib/wolfssl

Submodule wolfssl added at c3513bf

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
from setuptools.command.build_ext import build_ext
2828

2929

30-
# Adding src folder to the include path in order to import from wolfssl
31-
package_dir = os.path.dirname(__file__)
32-
sys.path.insert(0, package_dir)
33-
3430
import wolfssl
3531
from wolfssl._build_wolfssl import build_wolfssl
3632
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
@@ -90,7 +86,6 @@ def build_extension(self, ext):
9086
license=wolfssl.__license__,
9187

9288
packages=["wolfssl"],
93-
package_dir={"":package_dir},
9489

9590
zip_safe=False,
9691
cffi_modules=["./wolfssl/_build_ffi.py:ffi"],

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[tox]
2-
envlist = py39, pep8
3-
skipsdist = True
2+
envlist = py3
43

54
[testenv]
65
setenv =

wolfssl/_build_wolfssl.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ def local_path(path):
3434
return os.path.abspath(os.path.join(current, path))
3535

3636

37-
WOLFSSL_GIT_ADDR = "https://github.com/wolfssl/wolfssl.git"
38-
WOLFSSL_SRC_PATH = local_path("lib/wolfssl/src")
37+
WOLFSSL_SRC_PATH = local_path("lib/wolfssl")
3938

4039

4140
def wolfssl_inc_path():
4241
wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL")
4342
if wolfssl_path is None:
44-
return local_path("lib/wolfssl/src")
43+
return local_path("lib/wolfssl")
4544
else:
4645
if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path):
4746
return wolfssl_path + "/include"
@@ -86,20 +85,17 @@ def chdir(new_path, mkdir=False):
8685
os.chdir(old_path)
8786

8887

89-
def clone_wolfssl(ref):
90-
""" Clone wolfSSL C library repository
91-
"""
92-
call("git clone --depth=1 --branch={} {} {}".format(
93-
ref, WOLFSSL_GIT_ADDR, WOLFSSL_SRC_PATH))
94-
95-
9688
def checkout_ref(ref):
9789
""" Ensure that we have the right version
9890
"""
9991
with chdir(WOLFSSL_SRC_PATH):
100-
current = subprocess.check_output(
101-
["git", "describe", "--all", "--exact-match"]
102-
).strip().decode().split('/')[-1]
92+
current = ""
93+
try:
94+
current = subprocess.check_output(
95+
["git", "describe", "--all", "--exact-match"]
96+
).strip().decode().split('/')[-1]
97+
except:
98+
pass
10399

104100
if current != ref:
105101
tags = subprocess.check_output(
@@ -119,9 +115,13 @@ def checkout_ref(ref):
119115
def ensure_wolfssl_src(ref):
120116
""" Ensure that wolfssl sources are presents and up-to-date
121117
"""
122-
if not os.path.isdir(WOLFSSL_SRC_PATH):
123-
clone_wolfssl(ref)
124-
return True
118+
if not os.path.isdir("lib"):
119+
os.mkdir("lib")
120+
with chdir("lib"):
121+
subprocess.run(["git", "clone", "--depth=1", "https://github.com/wolfssl/wolfssl"])
122+
123+
if not os.path.isdir(os.path.join(WOLFSSL_SRC_PATH, "wolfssl")):
124+
subprocess.run(["git", "submodule", "update", "--init", "--depth=1"])
125125

126126
return checkout_ref(ref)
127127

0 commit comments

Comments
 (0)