Implement custom Python packages into yocto

Step 1 - Find package

Firstly you should check the exact name of the Python package under this link.

Step 2 - Install pipoe

The tool to create recipes is called pipoe. It is available at pypi.org. To install it you can simply use pip or conda.

pip install pipoe

Step 3 - Generate custom recipe

If you installed and checked the name of the package you can generate recipe by executing

pipoe --package <package_name>

Tip

You can also use -h option and find out all of available posibilities.

Step 4 - Generate recipe for mfrc522

For this use case device require mfrc522 Python package. It provide compatibility layer to handle RC-522 RFID scanner. To create custom recipe which will install this package on system firstly you need to create folder structure.

mkdir -p ../meta-golemos/recipes-base/python3-mfrc522/

Next, simply generate recipe with previously installed package.

pipoe --package mfrc522 --python python3 --outdir ../meta-golemos/recipes-base/python3-mfrc522

Note

If prompted write MIT license.

Warning

This tool generate more than one recipe in order to satisfy dependencies. In meta-raspberrypi and meta-python layers there are already this dependencies. Remove other recipes and change line with RDEPENDS in relevant file to this RDEPENDS_${PN} = "rpi-gpio python3-spidev python3-setuptools". You can also add this packages to base package group.

Step 4 - Add recipe to package group

To implement this recipe in system you have to add python3-mfrc522 to the base package group in Python section.

Step 5 - Enable SPI

To enable RFID reader you need to enable SPI communication in distribution configuration. To do that add this line to golemos.conf

ENABLE_SPI_BUS = "1"

Summary

After this steps your whole layer structure should look like this.

../meta-golemos
├── COPYING.MIT
├── README
├── conf
│   ├── bblayers.conf.sample
│   ├── conf-notes.txt
│   ├── distro
│   │   └── golemos.conf
│   ├── layer.conf
│   └── local.conf.sample
├── recipes-base
│   ├── datalogger-setup-page
│   │   └── datalogger-setup-page.bb
│   ├── nginx
│   │   ├── files
│   │   │   ├── datalogger-setup.local
│   │   │   └── datalogger.local
│   │   └── nginx_%.bbappend
│   ├── python3-gunicorn
│   │   ├── files
│   │   │   ├── datalogger_setup_page.service
│   │   │   └── datalogger_setup_page.socket
│   │   └── python3-gunicorn_%.bbappend
│   └── python3-mfrc522
│       └── python3-mfrc522_0.0.7.bb
├── recipes-connectivity
│   ├── hostapd
│   │   ├── files
│   │   │   ├── hostapd@.service
│   │   │   └── wlan0.conf
│   │   └── hostapd_%.bbappend
│   ├── kea
│   │   ├── files
│   │   │   ├── kea-dhcp4.conf
│   │   │   └── kea-dhcp4.service
│   │   └── kea_%.bbappend
│   └── wpa-supplicant
│       ├── files
│       │   └── wpa_supplicant-nl80211-wlan0.conf
│       └── wpa-supplicant_%.bbappend
├── recipes-core
│   ├── images
│   │   ├── datalogger-dev-image.bb
│   │   ├── datalogger-extended-image.bb
│   │   └── datalogger-image.bb
│   ├── packagegroups
│   │   ├── datalogger-base-packagegroup.bb
│   │   ├── datalogger-core-packagegroup.bb
│   │   ├── datalogger-dev-packagegroup.bb
│   │   └── datalogger-extended-packagegroup.bb
│   ├── systemd
│   │   └── systemd_%.bbappend
│   └── systemd-conf
│       ├── files
│       │   └── wlan.network
│       └── systemd-conf_%.bbappend
└── recipes-example
    └── example
        └── example_0.1.bb