Need help building with yocto/bitbake
bitbake/yocto are a cross-build system for making OS images for embedded projects. I'm trying to build a yocto image that includes PyNaCl as a dependency. There are a lot of other packages in the process that build flawlessly, but when it comes time to cross-build sodium and stuff, PyNaCl's setup.py break down. I've got a small patch that was necessary to get PyNaCl to even attempt to build, but it's thus far insufficient to the complete task and leaves me with the following error:
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2662, in load_entry_point return ep.load() File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2316, in load return self.resolve() File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2322, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/lib/python3.5/site-packages/crossbar/controller/cli.py", line 62, in <module> from crossbar.controller.node import _read_release_pubkey, _read_node_pubkey File "/usr/lib/python3.5/site-packages/crossbar/controller/node.py", line 44, in <module> from nacl.signing import SigningKey File "/usr/lib/python3.5/site-packages/nacl/signing.py", line 19, in <module> import nacl.bindings File "/usr/lib/python3.5/site-packages/nacl/bindings/__init__.py", line 17, in <module> from nacl.bindings.crypto_box import ( File "/usr/lib/python3.5/site-packages/nacl/bindings/crypto_box.py", line 18, in <module> from nacl._sodium import ffi, lib ImportError: No module named 'nacl._sodium'
This is the patch that allows PyNaCl to at least attempt to (And seemingly successfully) build libsodium:
From 63a491f190645eb649308fec3186f8fd07236376 Mon Sep 17 00:00:00 2001
From: Christ Schlacta <[email protected]>
Date: Tue, 17 Apr 2018 18:08:11 -0700
Subject: [PATCH] modify setup.py to actually work
setup.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
mode change 100644 => 100755 setup.py
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index eaa3e23..34ba3ed
--- a/setup.py
+++ b/setup.py
@@ -39,10 +39,12 @@ except ImportError:
requirements = ["six"]
setup_requirements = []
-test_requirements = ["pytest>=3.2.1,!=3.3.0",
- "hypothesis>=3.27.0"]
-docs_requirements = ["sphinx>=1.6.5",
- "sphinx_rtd_theme"]
+test_requirements = []
+docs_requirements = []
+#test_requirements = ["pytest>=3.2.1,!=3.3.0",
+# "hypothesis>=3.27.0"]
+#docs_requirements = ["sphinx>=1.6.5",
+# "sphinx_rtd_theme"]
if platform.python_implementation() == "PyPy":
@@ -52,8 +54,9 @@ if platform.python_implementation() == "PyPy":
"upgrade PyPy to use this library."
)
else:
- requirements.append("cffi>=1.4.1")
- setup_requirements.append("cffi>=1.4.1")
+ #requirements.append("cffi>=1.4.1")
+ #setup_requirements.append("cffi>=1.4.1")
+ pass
def here(*paths):
@@ -167,6 +170,7 @@ class build_clib(_build_clib):
configure, "--disable-shared", "--enable-static",
"--disable-debug", "--disable-dependency-tracking",
"--with-pic", "--prefix", os.path.abspath(self.build_clib),
+ "--host", "arm-poky-linux-gnueabi"
],
cwd=build_temp,
)
@@ -176,7 +180,7 @@ class build_clib(_build_clib):
subprocess.check_call(["make"] + make_args, cwd=build_temp)
# Check the build library
- subprocess.check_call(["make", "check"] + make_args, cwd=build_temp)
+ # subprocess.check_call(["make", "check"] + make_args, cwd=build_temp)
# Install the built library
subprocess.check_call(["make", "install"] + make_args, cwd=build_temp)
--
2.7.4
and lastly the recipe for PyNaCl in bitbake/yocto: python3-pynacl_1.2.1.bb
inherit setuptools3
DESCRIPTION = "PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library."
HOMEPAGE = "https://pypi.org/project/PyNaCl/"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8cc789b082b3d97e1ccc5261f8594d3f"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-modify-setup.py-to-actually-work.patch"
DEPENDS += " \
${PYTHON_PN}-cffi \
${PYTHON_PN}-six \
${PYTHON_PN}-pycparser \
${PYTHON_PN}-hypothesis \
${PYTHON_PN}-pytest \
"
RDEPENDS_${PN} += " \
${PYTHON_PN}-cffi \
${PYTHON_PN}-six \
${PYTHON_PN}-pycparser \
${PYTHON_PN}-hypothesis \
${PYTHON_PN}-pytest \
"
RDEPENDS_${PN}_class-target += " \
${PYTHON_PN}-cffi \
${PYTHON_PN}-six \
${PYTHON_PN}-pycparser \
${PYTHON_PN}-hypothesis \
${PYTHON_PN}-pytest \
"
SRC_URI[md5sum] = "1db3e111775fbe6b66772ff30af7a956"
SRC_URI[sha256sum] = "e0d38fa0a75f65f556fb912f2c6790d1fa29b7dd27a1d9cc5591b281321eaaa9"
PYPI_PACKAGE = "PyNaCl"
export SODIUM_INSTALL="bundled"
inherit pypi
First, I've just edited your comment, inserting a couple of ``` markers to get readable output from GH's markdown renderer.
I don't understand the context leading to the from crossbar.controller.node import ... action.
As for your patch, I don't think you should need removing the dependency declarations from the project's setup.py, unless the versions of the pre-built packages on whose the bitbake recipe depends were lesser than the ones required.
In general, python distutils and cffi are not very "cross-build friendly"; if the runtime environment of the build system is not arm-*-gnueabi, a crash while trying to import a just built arm-poky-linux-gnueabi module in the build system's default python interpreter is expected.
If at all possible, you should try to build in a environment homogeneous to the build target, or verify if there is some way to run the already built target python interpreter using qemu-user along the lines described in https://wiki.gentoo.org/wiki/Crossdev_qemu-static-user-chroot and https://wiki.debian.org/QemuUserEmulation.