Merge pull request #329 from makermelissa/main

Updated Blinka installer to at least install the correct packages
This commit is contained in:
Limor "Ladyada" Fried 2024-11-20 13:27:12 -05:00 committed by GitHub
commit bbeb37b210
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -92,15 +92,18 @@ def install_blinka(user=False):
username = None username = None
if user: if user:
username = os.environ["SUDO_USER"] username = os.environ["SUDO_USER"]
shell.run_command(f"{pip_command} RPi.GPIO", run_as_user=username)
shell.run_command(f"{pip_command} adafruit-blinka", run_as_user=username) shell.run_command(f"{pip_command} adafruit-blinka", run_as_user=username)
# Custom function to run additional commands for Pi 5 # Custom function to run additional commands for Pi 5
def check_and_install_for_pi5(pi_model): def check_and_install_for_pi5(pi_model, user=False):
if pi_model.startswith("RASPBERRY_PI_5"): if pi_model.startswith("RASPBERRY_PI_5"):
username = None
if user:
username = os.environ["SUDO_USER"]
print("Detected Raspberry Pi 5, applying additional fixes...") print("Detected Raspberry Pi 5, applying additional fixes...")
os.system("sudo apt remove python3-rpi.gpio") shell.run_command("sudo apt remove python3-rpi.gpio")
os.system("pip3 install rpi-lgpio") shell.run_command("pip3 uninstall -y RPi.GPIO", run_as_user=username)
shell.run_command("pip3 install --upgrade rpi-lgpio", run_as_user=username)
else: else:
print(f"Detected {pi_model}, no additional fixes needed.") print(f"Detected {pi_model}, no additional fixes needed.")
@ -139,8 +142,8 @@ Raspberry Pi and installs Blinka
update_pip() update_pip()
install_blinka(True) install_blinka(True)
# Check and install for Pi 5 if detected # Check and install any Pi 5 fixes if detected
check_and_install_for_pi5(pi_model) check_and_install_for_pi5(pi_model, True)
# Done # Done
print("""DONE. print("""DONE.