pyca / pyca/pynacl

Need help building with yocto/bitbake

Open
#425 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-building
Dominant language
C
Stars
1.2k
Forks
267
Avg merge
42m
Merged PRs (30d)
2

Description

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 <aarcane@aarcane.org>
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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with setup.py and the python3-pynacl_1.2.1.bb recipe, then reproduce the Yocto/BitBake build using the reported cross-build configuration. Trace the nacl._sodium import failure and verify that the resulting image builds PyNaCl successfully and can import its sodium bindings.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
build-system, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.