Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please make Pull Request in official Rep #2

Open
Ed1ks opened this issue May 24, 2024 · 2 comments
Open

Please make Pull Request in official Rep #2

Ed1ks opened this issue May 24, 2024 · 2 comments

Comments

@Ed1ks
Copy link

Ed1ks commented May 24, 2024

Hello, and thank you for your great Work @Gadgetoid

This repo is a nice workaround for people who need GPIO inside Docker for Raspberry Pi 5.

But please consider creating a Pull request in official Repo:
https://github.com/joan2937/lg/pulls

So maybe it will accepted and you got the official lgpio repaired.

@Gadgetoid
Copy link
Owner

I tried 😭

Actual packaging and distribution of lg is handled by others, and there's a fork where I brought a PR attempting to solve this problem to their attention: gpiozero/lg#1

I think this repository is about the closest you'll get to a solution. I suppose we could huck it up onto PyPI under another name 😆 Though I'd rather work with and not against my peers.

@Ed1ks
Copy link
Author

Ed1ks commented May 24, 2024

While being happy that the package got installed and creating this post, I got another issue, that I get error when using gpiozero in python code:

/usr/local/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
  warnings.warn(
/usr/local/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi'
  warnings.warn(
/usr/local/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio'
  warnings.warn(
/usr/local/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root

this is my dockerfile:

FROM python:3.11-slim-bullseye
ENV PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PUID=1000\
    PGID=1000

# Set the working directory inside the container
WORKDIR /app

# Create and set volumes

# Install system dependencies for PyAudio, evdev, and build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    supervisor \
    swig \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements.txt to the container and install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

RUN pip install pigpio gpio gpiozero
RUN pip install https://github.com/Gadgetoid/PY_LGPIO/releases/download/0.2.2.0/lgpio-0.2.2.0.tar.gz

# Copy the rest of the application code to the container
COPY . .

# Ensure the entrypoint script is executable
RUN chmod +x ./entrypoint.sh

# Expose the port the app runs on
EXPOSE 8010

ENTRYPOINT ["./entrypoint.sh"]
CMD ["supervisord", "-c", "/supervisord_docker.conf"]

the code runs fine on Raspberry Pi 5 root, but if running docker container with priviliged mode, it doesnt seem to work.
Any Ideas, whats wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants