the-raspberry-pi-guy / lcd

This repository contains all of the code for interfacing with a 16x2 Character I2C LCD Display. This accompanies my YouTube tutorial here: https://www.youtube.com/watch?v=fR5XhHYzUK0
186 stars 107 forks source link

Maintaining Python 2.7 compatibility moving forward #45

Closed cgomesu closed 2 years ago

cgomesu commented 2 years ago

Issues #41 and #42 (#43, #44) are diagnostic of a growing compatibility issue, namely, the almost complete lack of Python 2.7 support--and of its modules, such as smbus--via the official package managers (either apt or pip) starting with Raspberry Pi OS bullseye. Moving forward, there are a couple of alternatives to deal with this:

  1. The RPi Foundation is still maintaining a Raspberry Pi OS Legacy version, namely buster, which is fully compatible with the current LCD driver. Users can be encouraged to use it instead.
  2. Build smbus from https://github.com/pimoroni/py-smbus. I think they are the current maintainers of the smbus pkg and it seems that there hasn't been any update in more than 5 years. I've tried to build it using the latest buster Raspberry Pi OS but ran into issues (build requirements seem outdated as well).
  3. We could change reliance from the old smbus to smbus2 (https://pypi.org/project/smbus2/) which is fully compatible with the LCD driver (just change import smbus to import smbus2) and it doesn't seem to break any demos. This module can be built from source (tested it installs just fine and the module is picked up by pip afterwards). The install from source procedure would be appended to setup.sh.
  4. Edit setup.sh to try to install both python-smbus and python3-smbus via apt and then add a note to README.md that users running the latest distro (bullseye and above) should use python3 with the LCD driver if they run into issue with python, which seems to be linked to Python 2.7 even in bullseye.

Anyway, these are the options that I can think of right now. They are not all mutually exclusive. In any case, the growing compatibility issue needs to be addressed asap. If anyone wants to chime in, please do so before Jan 14th. Otherwise, I'll merge the changes that I think are the most reasonable ones.

the-raspberry-pi-guy commented 2 years ago

Thanks for your hard-work on this as ever Carlos!