Blink virtual environment install

Went here,
Repackage to latest boilerplate and port to gpiod by Gadgetoid · Pull Request #102 · pimoroni/blinkt (github.com)

and did the following.

pi@raspberrypi:~ $ python3 -m venv ~/my_virtual_env
pi@raspberrypi:~ $ source ~/my_virtual_env/bin/activate
(my_virtual_env) pi@raspberrypi:~ $ sudo apt install python3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-dev is already the newest version (3.11.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
(my_virtual_env) pi@raspberrypi:~ $ pip install gpiod-2.0.1.tar.gz
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./gpiod-2.0.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: gpiod
  Building wheel for gpiod (pyproject.toml) ... done
  Created wheel for gpiod: filename=gpiod-2.0.1-cp311-cp311-linux_aarch64.whl size=93876 sha256=2459abc3eebecfea81ac658c847cd5ce2226fc2188e57ed7d35225d4169f3e19
  Stored in directory: /home/pi/.cache/pip/wheels/88/37/59/bd1f565745b127d16180eb2475aba0b290cc4eaef2c34cde26
Successfully built gpiod
Installing collected packages: gpiod
  Attempting uninstall: gpiod
    Found existing installation: gpiod 2.0.1
    Uninstalling gpiod-2.0.1:
      Successfully uninstalled gpiod-2.0.1
Successfully installed gpiod-2.0.1
(my_virtual_env) pi@raspberrypi:~ $ git clone https://github.com/pimoroni/blinkt -b repackage
Cloning into 'blinkt'...
remote: Enumerating objects: 1425, done.
remote: Counting objects: 100% (243/243), done.
remote: Compressing objects: 100% (137/137), done.
remote: Total 1425 (delta 109), reused 184 (delta 78), pack-reused 1182
Receiving objects: 100% (1425/1425), 411.36 KiB | 3.49 MiB/s, done.
Resolving deltas: 100% (843/843), done.
(my_virtual_env) pi@raspberrypi:~ $ cd blinkt
(my_virtual_env) pi@raspberrypi:~/blinkt $ pip install .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing /home/pi/blinkt
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: gpiod in /home/pi/my_virtual_env/lib/python3.11/site-packages (from blinkt==0.1.2) (2.0.1)
Requirement already satisfied: gpiodevice>=0.0.2 in /home/pi/my_virtual_env/lib/python3.11/site-packages (from blinkt==0.1.2) (0.0.3)
Building wheels for collected packages: blinkt
  Building wheel for blinkt (pyproject.toml) ... done
  Created wheel for blinkt: filename=blinkt-0.1.2-py3-none-any.whl size=10539 sha256=c3e37203fe386081df943c7264b25ab7e022ed9954080f389f72c5cbbcf14271
  Stored in directory: /tmp/pip-ephem-wheel-cache-h7e295u4/wheels/1f/15/39/e27ca04201b69df7270a606a5d1fc5d9ea73eccd561ad00e2c
Successfully built blinkt
Installing collected packages: blinkt
  Attempting uninstall: blinkt
    Found existing installation: blinkt 0.1.2
    Uninstalling blinkt-0.1.2:
      Successfully uninstalled blinkt-0.1.2
Successfully installed blinkt-0.1.2
(my_virtual_env) pi@raspberrypi:~/blinkt $ pip3 install .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing /home/pi/blinkt
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: gpiod in /home/pi/my_virtual_env/lib/python3.11/site-packages (from blinkt==0.1.2) (2.0.1)
Requirement already satisfied: gpiodevice>=0.0.2 in /home/pi/my_virtual_env/lib/python3.11/site-packages (from blinkt==0.1.2) (0.0.3)
Building wheels for collected packages: blinkt
  Building wheel for blinkt (pyproject.toml) ... done
  Created wheel for blinkt: filename=blinkt-0.1.2-py3-none-any.whl size=10539 sha256=c3e37203fe386081df943c7264b25ab7e022ed9954080f389f72c5cbbcf14271
  Stored in directory: /tmp/pip-ephem-wheel-cache-ac2aklsj/wheels/1f/15/39/e27ca04201b69df7270a606a5d1fc5d9ea73eccd561ad00e2c
Successfully built blinkt
Installing collected packages: blinkt
  Attempting uninstall: blinkt
    Found existing installation: blinkt 0.1.2
    Uninstalling blinkt-0.1.2:
      Successfully uninstalled blinkt-0.1.2
Successfully installed blinkt-0.1.2
(my_virtual_env) pi@raspberrypi:~/blinkt $ cd examples
(my_virtual_env) pi@raspberrypi:~/blinkt/examples $ python3 cpu_temp.py

The cpu_temp.py file worked from command line. Could not get it to run from Thony though? blinkt has no attribute… error messages.

How do I get it to run on bootup? I guessing I have to load the virtual environment first, then run my py file? I normally launch my py file via crontab.

I usually create a small wrapper script that does that. But this is probably not necessary. I think in the Adafruit virtenv-guide I posted some time ago there was an option to start directly from within the environment.

Regarding Thonny: you will probably also have to start Thonny from the commandline after activating the virtenv.

I’ll play around with this over the weekend. I wanted to give it an honest try, without mucking up my Pi 5. That is an NVMe install that I don’t want to have to redo from scratch if I muck something up.
This is a Pi 4B running the latest Pi OS 64 bit. Standard SD Card install.

Just to add. IMHO, this ends up being very overcomplicated. And is going to frustrate the hell out of casual users, and those just starting out. At some point, since this is a Pi 4B, I will be going back to Legacy OS. I just will!