Skip to content

Commit b602083

Browse files
LinuxJedidanielinux
authored andcommitted
Fix build recursion issue
Windows had an issue where it was trying to build the CFFI module after it had already imported the CFFI module. Which caused permissions errors during builds. This fix does several things to make the Windows build work properly and improve the Linux build too: * The CFFI module is only build when needed, not as part of an sdist package * Version numbering spilt out into separate file so __init__.py import is not required * Merged _build_ffi.py and _build_wolfssl.py into one file * Made CFFI only build when called as an executable (which happens during binary build time) * Make tox use bdist-wheel instead of sdist
1 parent 744a49e commit b602083

File tree

6 files changed

+308
-333
lines changed

6 files changed

+308
-333
lines changed

setup.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@
2626
from setuptools import setup
2727
from setuptools.command.build_ext import build_ext
2828

29-
import wolfcrypt
30-
from wolfcrypt._build_wolfssl import build_wolfssl
29+
import re
30+
VERSIONFILE = "wolfcrypt/_version.py"
31+
verstrline = open(VERSIONFILE, "rt").read()
32+
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
33+
mo = re.search(VSRE, verstrline, re.M)
34+
if mo:
35+
verstr = mo.group(1)
36+
else:
37+
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
38+
VSRE = r"^__wolfssl_version__ = ['\"]([^'\"]*)['\"]"
39+
mo = re.search(VSRE, verstrline, re.M)
40+
if mo:
41+
wolfverstr = mo.group(1)
42+
else:
43+
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
3144

3245

3346
# long_description
@@ -38,30 +51,15 @@
3851
long_description = long_description.replace(".. include:: LICENSING.rst\n",
3952
licensing_file.read())
4053

41-
42-
class cffiBuilder(build_ext, object):
43-
44-
def build_extension(self, ext):
45-
""" Compile manually the wolfcrypt-py extension, bypass setuptools
46-
"""
47-
48-
# if USE_LOCAL_WOLFSSL environment variable has been defined,
49-
# do not clone and compile wolfSSL from GitHub
50-
if os.environ.get("USE_LOCAL_WOLFSSL") is None:
51-
build_wolfssl(wolfcrypt.__wolfssl_version__)
52-
53-
super(cffiBuilder, self).build_extension(ext)
54-
55-
5654
setup(
57-
name=wolfcrypt.__title__,
58-
version=wolfcrypt.__version__,
59-
description=wolfcrypt.__summary__,
55+
name="wolfcrypt",
56+
version=verstr,
57+
description="Python module that encapsulates wolfSSL's crypto engine API.",
6058
long_description=long_description,
61-
author=wolfcrypt.__author__,
62-
author_email=wolfcrypt.__email__,
63-
url=wolfcrypt.__uri__,
64-
license=wolfcrypt.__license__,
59+
author="wolfSSL Inc.",
60+
author_email="[email protected]",
61+
url="https://github.com/wolfssl/wolfcrypt-py",
62+
license="GPLv2 or Commercial License",
6563

6664
packages=["wolfcrypt"],
6765

@@ -83,6 +81,5 @@ def build_extension(self, ext):
8381
],
8482

8583
setup_requires=["cffi"],
86-
install_requires=["cffi"],
87-
cmdclass={"build_ext" : cffiBuilder}
84+
install_requires=["cffi"]
8885
)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
envlist = py3
33

44
[testenv]
5+
wheel = true
56
setenv =
67
PYTHONPATH = {toxinidir}:{toxinidir}/wolfcrypt-py
78

wolfcrypt/__init__.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,12 @@
1818
# along with this program; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2020

21+
from wolfcrypt._version import __version__, __wolfssl_version__
22+
2123
__title__ = "wolfcrypt"
2224
__summary__ = "Python module that encapsulates wolfSSL's crypto engine API."
2325
__uri__ = "https://github.com/wolfssl/wolfcrypt-py"
2426

25-
# When bumping the C library version, reset the POST count to 0
26-
27-
__wolfssl_version__ = "v5.1.1-stable"
28-
29-
# We're using implicit post releases [PEP 440] to bump package version
30-
# while maintaining the C library version intact for better reference.
31-
# https://www.python.org/dev/peps/pep-0440/#implicit-post-releases
32-
#
33-
# MAJOR.MINOR.BUILD-POST
34-
35-
__version__ = "5.1.1-0"
36-
3727
__author__ = "wolfSSL Inc."
3828
__email__ = "[email protected]"
3929

0 commit comments

Comments
 (0)