Open main menu

DAVE Developer's Wiki β

Changes

DESK-XZ7-L-AN-0004: Using Python with BORA

5,694 bytes added, 1 February
no edit summary
Downloading wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
Downloading pip-23.3.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.1 MB/s eta 0:00:00
Downloading setuptools-69.0.3-py3-none-any.whl (819 kB)
|████████████████████████████████ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 819.5/819.5 kB 1.9 MB/s eta 0:00:00
Downloading wheel-0.42.0-py3-none-any.whl (65 kB)
|████████████████████████████████ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.4/65.4 kB 427.3 kB/s eta 0:00:00
DEPRECATION: gpg 1.14.0-unknown has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of gpg or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: wheel, setuptools, pip
Downloading platformdirs-4.1.0-py3-none-any.whl.metadata (11 kB)
Downloading virtualenv-20.25.0-py3-none-any.whl (3.8 MB)
|████████████████████████████████ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 1.9 MB/s eta 0:00:00
Downloading distlib-0.3.8-py2.py3-none-any.whl (468 kB)
|████████████████████████████████ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 2.2 MB/s eta 0:00:00
Downloading filelock-3.13.1-py3-none-any.whl (11 kB)
Downloading platformdirs-4.1.0-py3-none-any.whl (17 kB)
Collecting pip
Downloading pip-23.3.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1 MB 167 kB/s
Installing collected packages: pip
Attempting uninstall: pip
In this example, the following packages are installed:
* '''asyncua''' (OPCUA client and server library)
* '''bcrypt''' (password hashing)
* '''can''' (color animator)
* '''cbor''' (Concise Binary Object Representation - CBOR is comparable to JSON, has a superset of JSON’s ability)
* '''netifaces''' (network interface info)
* '''ntplib''' (Python NTP)
* '''pymodbus''' (Modbus stack protocol)
* '''python-daemon''' (Standard daemon process library)
* '''python-dateutil''' (Python extension dateutil)
* '''python-prctl''' (C extension for system call)
* '''requests''' (Python HTTP)
<pre class="board-terminal">
(desk) root@bora:~# pip3 install netifaces
Collecting netifaces
Using cached netifaces-0.11.0.tar.gz (30 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: netifaces
Building wheel for netifaces (setup.py) ... done
Created wheel for netifaces: filename=netifaces-0.11.0-cp38-cp38-linux_armv7l.whl size=35205 sha256=e405dea3379d15e715be65b57f651beef13df5df815013bb8332960a481f58ac
Stored in directory: /home/root/.cache/pip/wheels/04/e2/b4/b811799a082cacaeff801af32c856fbefe6279ba96554d9a21
Successfully built netifaces
Installing collected packages: netifaces
Successfully installed netifaces-0.11.0
(desk) root@bora:~# pip3 install can
Collecting can
Installing collected packages: six, python-dateutil
Successfully installed python-dateutil-2.8.2 six-1.16.0
(desk) root@bora:~# pip3 install python-prctl
Collecting python-prctl
Using cached python-prctl-1.8.1.tar.gz (28 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: python-prctl
Building wheel for python-prctl (setup.py) ... done
Created wheel for python-prctl: filename=python_prctl-1.8.1-cp38-cp38-linux_armv7l.whl size=25369 sha256=369d991812ce1d758297332ae01c9d725f0bd5bc480c382bf8b4a917a5ebd6c0
Stored in directory: /home/root/.cache/pip/wheels/70/90/f1/b786edccb1b2d9290281dad80c8aa0e93ab5c1f845a8d404aa
Successfully built python-prctl
Installing collected packages: python-prctl
Successfully installed python-prctl-1.8.1
(desk) root@bora:~# pip3 install pyserial
Collecting pyserial
Successfully installed pyserial-3.5
(desk) root@bora:~#
</pre>
 
=== asyncua ===
Some packages may require [https://rustup.rs/ Rust] compiler for building the (for example) <code>wheel</code>:
* download the <code>rust</code> Linux installer
<pre>
wget https://sh.rustup.rs
</pre>
* execute the installer script:
<pre>
./rustup-init.sh
root@bora:~#
</pre>
Once installed the related environment should be initialized:
<pre class="board-terminal">
(desk) root@bora:~# source "$HOME/.cargo/env"
</pre>
In this way, the <code>asyncua</code> package can be built/installed:
<pre class="board-terminal">
(desk) root@bora:~# pip3 install asyncua
Collecting asyncua
Using cached asyncua-1.0.6-py3-none-any.whl.metadata (9.3 kB)
Collecting aiofiles (from asyncua)
Using cached aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)
Collecting aiosqlite (from asyncua)
Using cached aiosqlite-0.19.0-py3-none-any.whl (15 kB)
Requirement already satisfied: python-dateutil in ./desk/lib/python3.8/site-packages (from asyncua) (2.8.2)
Collecting pytz (from asyncua)
Using cached pytz-2023.4-py2.py3-none-any.whl.metadata (22 kB)
Collecting cryptography>40.0.1 (from asyncua)
Downloading cryptography-42.0.2.tar.gz (672 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 672.8/672.8 kB 559.1 kB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting sortedcontainers (from asyncua)
Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting pyOpenSSL (from asyncua)
Downloading pyOpenSSL-24.0.0-py3-none-any.whl.metadata (12 kB)
Collecting typing-extensions (from asyncua)
Downloading typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB)
Collecting cffi>=1.12 (from cryptography>40.0.1->asyncua)
Using cached cffi-1.16.0-cp38-cp38-linux_armv7l.whl
Requirement already satisfied: six>=1.5 in ./desk/lib/python3.8/site-packages (from python-dateutil->asyncua) (1.16.0)
Collecting pycparser (from cffi>=1.12->cryptography>40.0.1->asyncua)
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Downloading asyncua-1.0.6-py3-none-any.whl (773 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 773.0/773.0 kB 2.2 MB/s eta 0:00:00
Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)
Downloading pyOpenSSL-24.0.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.6/58.6 kB 521.5 kB/s eta 0:00:00
Downloading pytz-2023.4-py2.py3-none-any.whl (506 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 506.5/506.5 kB 480.3 kB/s eta 0:00:00
Downloading typing_extensions-4.9.0-py3-none-any.whl (32 kB)
Building wheels for collected packages: cryptography
Building wheel for cryptography (pyproject.toml) ... done
Created wheel for cryptography: filename=cryptography-42.0.2-cp38-cp38-linux_armv7l.whl size=2206468 sha256=27ef627b5636e640bc179ff1ad13948ac029ad3c709d1e137670f6c5fe79c131
Stored in directory: /home/root/.cache/pip/wheels/b8/2d/51/9a40e9f8548e174065e9988ad0eece7edf49ece9b2251e0790
Successfully built cryptography
Installing collected packages: sortedcontainers, pytz, typing-extensions, pycparser, aiosqlite, aiofiles, cffi, cryptography, pyOpenSSL, asyncua
Successfully installed aiofiles-23.2.1 aiosqlite-0.19.0 asyncua-1.0.6 cffi-1.16.0 cryptography-42.0.2 pyOpenSSL-24.0.0 pycparser-2.21 pytz-2023.4 sortedcontainers-2.4.0 typing-extensions-4.9.0
(desk) root@bora:~#
</pre>
Package Version
------------------ ----------
(desk) root@bora:~#
aiofiles 23.2.1
aiosqlite 0.19.0
asyncua 1.0.6
bcrypt 4.1.2
can 0.0.0
cbor 1.0.0
certifi 2023.11.17
cffi 1.16.0
charset-normalizer 3.3.2
cryptography 42.0.2
docutils 0.20.1
idna 3.6
lockfile 0.12.2
netifaces 0.11.0
ntplib 0.4.0
pip 23.3.2
pycparser 2.21
pymodbus 3.6.3
PyNaCl 1.2.0
pyOpenSSL 24.0.0
pyserial 3.5
python-daemon 3.0.1
python-dateutil 2.8.2
python-prctl 1.8.1
pytz 2023.4
requests 2.31.0
setuptools 69.0.3
six 1.16.0
sortedcontainers 2.4.0
typing_extensions 4.9.0
urllib3 2.1.0
wheel 0.42.0
(desk) root@bora:~#
</pre>
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncua
>>> import can
>>> import cbor
>>> import daemon
>>> import dateutil
>>> import netifaces
>>> import ntplib
>>> import pymodbus
>>> import prctl
>>> import serial
>>> import requests
>>>
</pre>
8,226
edits