Finding / compiling Python packages for OpenWrt

I am trying to port a software package written in Python to OpenWrt.

The package I am porting uses many of the standard Python packages. So far, I have been able to install these Python packages either using pip or using opkg. The process I have been using is to try to install the python package using pip first. For some reason, there are many Python packages that do not install with pip on OpenWrt. It is not clear to me why this is. In any case, when "pip install" does not work, I look for the package in the OpenWrt package repository and install it using "opkg install".

Now I have come across a Python package "pyNaCl" which I can not find in the OpenWrt package repository. I assume this means I need to build this package from source in order to use it. If this is not a case, I would appreciate a pointer to where I can find a version of "pyNaCl" for OpenWrt.

I have found this guide for porting Python packages to OpenWrt:


I assume that if I install a build environment for OpenWrt and then follow the instructions in this guide, I should be able to build this missing package.

If anyone has any tips on the process of compiling and creating a Python package for OpenWrt, please get back.

Maybe you can install this package via pip ?

I'm not interested anyhow in PyNaCl, but these days, I was looking in Python packages, so I may take a look. If I can get it working, I will send the pull request to OpenWrt.

@Pepe, it's been a long time already, but I'm just curios if you have any updates regarding PyNaCl package?

opkg remove python3-pip
opkg remove python3-setuptools
python3 -m pip install --upgrade pip

requires TLS CA Bundle...

I ported PyNaCl a couple months ago. I never checked it into the source tree because I have only tested it with Python2, not Python3.

The Makefile depends on non-default build flags. Here's the line from the Makefile dealing with this:
DEPENDS+=libsodium @!LIBSODIUM_MINIMAL

I don't know if having a DEPENDS like this in the Makefile will break the nightly OpenWrt build. Another reason I never checked it in.

If you want the Makefile, I can send it to you.

Sure, it would be great if you can share your solution!

Actually I'm stuck with getting libsodium compiled for mips, even though PyNaCl has a very nice option that allows you to skip libsodium from the build process and use a system provided library by setting SODIUM_INSTALL="system". But eventually I get this in the runtime:

ImportError: Error relocating /usr/lib/python3.6/site-packages/nacl/_sodium.abi3.so: crypto_shorthash_siphashx24_keybytes: symbol not found

and that seemingly has some common roots with the issue mentioned by @nariox here:
https://forum.openwrt.org/t/ath79-builds-with-all-kmod-packages-through-opkg-flow-offloading/15897/226

I can't remember all the errors I fixed along the way of getting PyNaCl to work. I suspect the error "crypto_shorthash_siphashx24_keybytes: symbol not found" was solved by adding "DEPENDS+=libsodium @!LIBSODIUM_MINIMAL" to the Makefile.

Here's the Makefile
https://paste2.org/fjjszUzF

Did you get it to work in the end? Got it to compile using makefile provided by @brucet but also stuck with same error when trying to use it?

Meanwhile this package has become a dependency if you want to use the mobile_app integration in Home Assistant. Would be great if we could add it to openwrt? (I somehow am not able to create a working package myself, see other posts)

I am also looking for PyNaCl package built for MIPS. Came across to this thread while struggling to install Home Assitant on my OpenWRT router.

For me, the base libsodium_1.0.18-1_mipsel_24kc.ipk package is a "minimal" build, which excludes out necessary functions.

Check this with: `strings /usr/lib/libsodium.so.23.3.0 | grep crypto_shorthash_siphashx24_keybytes'

By setting up an OpenWrt build environment and compiling without the Minimal advanced setting flag in .config, made PyNaCl for HomeAssistant work without errors, and mobile_app works perfectly.