Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add more python modules to my yocto/openembedded project?

I wish to add more python modules to my yocto/openembedded project but I am unsure how to? I wish to add flask and its dependencies.

like image 379
timelmg Avatar asked Aug 09 '16 23:08

timelmg


People also ask

How do I install additional modules in Python?

Install module You can install modules or packages with the Python package manager (pip). To install a module system wide, open a terminal and use the pip command. If you type the code below it will install the module. That will install a Python module automatically.

What is BitBake recipe?

BitBake recipes specify how a particular package is built. Recipes consist of the source URL (http, https, ftp, cvs, svn, git, local file system) of the package, dependencies and compile or install options. They also store the metadata for the package in standard variables.

What can I do with yocto?

Yocto Project is suitable for embedded and IoT devices with limited resources: Unlike a full Linux distribution, embedded developers can use Yocto Project to create a condensed version for embedded devices. You only need to add the necessary functional tools and software packages into your Linux System.


2 Answers

This question is old, but currently in 2020 there is a python package called pipoe.

pipoe can generate .bb classes corresponding to python packages for you!

Usage:

$ pip3 install pipoe
$ pipoe -p requests
OR
$ pipoe -p requests --python python3

Now copy the generated .bb files to your layer and use them.

https://pypi.org/project/pipoe/

like image 82
Paul Avatar answered Sep 28 '22 17:09

Paul


some python packages having corresponding recipes in the meta folders, like Enum class for example:

meta-openembedded/meta-python/recipes-devtools/python/python-enum34_1.1.6.bb

unfortunately lot's of useful classes aren't available, but some might be needed for the python application. get used of installing missing packages using pip already on booted platform? but what if the target product is not IP network connected? the solution is to implement a new recipe and add to the platform meta layer (at least). Example is a recipe for the module keyboard useful for intercepting keys/buttons touch events:

  1. use PyPi web site to identify if the package is available:

https://pypi.org/project/keyboard/

  1. download archive available on the package description page:

https://github.com/boppreh/keyboard/archive/master.zip

  1. collect some useful information required to fill-out a new recipe:

    • SUMMARY - could be obtained from the package description page
    • HOMEPAGE - the project URL on github or bitbucket or sourceforge, etc
    • LICENSE - verify license type
    • LIC_FILES_CHKSUM by executing md5sum on existing LICENSE or README or PKG-INFO file located in the root of the package (preferrably)
    • SRC_URI[md5sum] - is md5sum of the archive itself. it will be used to discover and download archive on pypi server automatically with the help of supporting script inherit pypi
    • PYPI_PACKAGE_EXT - if the package is not tar.gz require to supply the correct extension
  2. create missing python-keyboard_0.13.1.bb recipe:

`

SUMMARY = "Hook and simulate keyboard events on Windows and Linux"
HOMEPAGE = "https://github.com/boppreh/keyboard"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://PKG-INFO;md5=9bc8ba91101e2f378a65d36f675c88b7"

SRC_URI[md5sum] = "d4b90e53bbde888e7b7a5a95fe580a30"
SRC_URI += "file://add_missing_CHANGES_md.patch"

PYPI_PACKAGE = "keyboard"

PYPI_PACKAGE_EXT = "zip"

inherit pypi
inherit setuptools

BBCLASSEXTEND = "native nativesdk"

`

  1. the package has been patched by adding

SRC_URI += "file://add_missing_CHANGES_md.patch"

directive to the recipe due to missing CHANGES.md file used by setup.py script to identify package version (this step is optional). the patch itself has to be placed inside the folder next to the recipe matching recipe name but without version:

python-keyboard

like image 34
Oleg Kokorin Avatar answered Sep 28 '22 16:09

Oleg Kokorin