Skip to content

Commit

Permalink
ensure correct numpy version for python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
roflcoopter committed Jul 8, 2024
1 parent c43c791 commit 7f94317
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
!docker/ffprobe_wrapper
!requirements.txt
!requirements_test.txt
!requirements-3.9.txt
!docker/opencv-python-headless-setup.py
!docker/jetson-nano/opencv-tuple.patch
!rootfs/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
!/requirements_ci.txt
!/requirements_test.txt
!/requirements.txt
!/requirements-3.9.txt
!setup.py
!manager.py

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OPENVINO_VERSION="2024.0.0"
FFMPEG_VERSION="5.1.2"
DLIB_VERSION="19.24.4"
SKLEARN_VERSION="1.2.2"
WHEELS_VERSION="1.6"
WHEELS_VERSION="1.7"
S6_OVERLAY_VERSION="2.1.0.2"
CMAKE_VERSION=3.20.0
MAKEFLAGS="-j 5"
Expand Down
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ FROM roflcoopter/${ARCH}-base:${BASE_VERSION}
WORKDIR /src

COPY --from=wheels /wheels /wheels
COPY --from=wheels /wheels-3.9 /wheels-3.9

ARG S6_OVERLAY_ARCH
ARG S6_OVERLAY_VERSION
Expand Down Expand Up @@ -135,10 +136,8 @@ RUN \
&& echo "libedgetpu1-max libedgetpu/accepted-eula select true" | debconf-set-selections \
&& apt-get -qq update && apt-get -qq install -y --no-install-recommends \
libedgetpu1-max \
&& python3.9 -m pip install \
--extra-index-url https://google-coral.github.io/py-repo/ \
--extra-index-url https://www.piwheels.org/simple \
pycoral~=2.0 \
&& python3.9 -m pip install install /wheels-3.9/*.whl \
&& rm -r /wheels-3.9 \
\
&& chmod +x /tmp/s6-overlay-installer && /tmp/s6-overlay-installer / \
&& apt-get autoremove -y \
Expand Down
20 changes: 18 additions & 2 deletions docker/Dockerfile.wheels
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RUN \
[ "$ARCH" = "aarch64" ] ; then echo "Crossbuilding!" && cross-build-start; fi

RUN apt-get -yqq update && apt-get install -yq --no-install-recommends \
software-properties-common \
gnupg \
cmake \
curl \
python3 \
Expand All @@ -29,7 +31,15 @@ RUN apt-get -yqq update && apt-get install -yq --no-install-recommends \
python3-wheel \
libgirepository1.0-dev\
libcairo2-dev \
# Install Python 3.9 if it doesn't exist
&& if [ ! -f /usr/local/bin/python3.9 ]; then \
add-apt-repository ppa:deadsnakes/ppa -y && \
apt-get update && apt-get install -y --no-install-recommends \
python3.9 \
python3.9-distutils ; \
fi \
&& python3 -m pip install --upgrade pip \
&& python3.9 -m pip install --upgrade pip \
&& apt-get autoremove -y && apt-get clean -y

# Pip does not find our OpenCV built from source so we fake it here
Expand All @@ -42,17 +52,23 @@ RUN echo "opencv-python-headless==$OPENCV_VERSION" >> /requirements.txt

# We need to setup Rust compiler for bcrypt
# A tmpfs is needed: https://github.com/rust-lang/cargo/issues/8719
ADD requirements-3.9.txt requirements-3.9.txt
RUN --mount=type=tmpfs,target=/root/.cargo curl https://sh.rustup.rs -sSf | bash -s -- -y \
&& . $HOME/.cargo/env \
&& mkdir -p /wheels \
&& mkdir -p /wheels /wheels-3.9 \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "amd64-cuda" ]; then export PLATFORM="x86_64"; \
elif [ "$ARCH" = "armhf" ] || [ "$ARCH" = "rpi3" ]; then export PLATFORM="armv7l"; \
else export PLATFORM="$ARCH"; fi \
\
&& python3 -m pip wheel --wheel-dir=/wheels --find-links=/wheels ${EXTRA_PIP_ARGS} /opencv-python-headless -r /requirements.txt \
&& python3.9 -m pip wheel \
--extra-index-url https://google-coral.github.io/py-repo/ \
--wheel-dir=/wheels-3.9 \
${EXTRA_PIP_ARGS} -r /requirements-3.9.txt \
\
&& ls -al /wheels/
&& ls -al /wheels/ /wheels-3.9/

FROM scratch

COPY --from=build /wheels /wheels
COPY --from=build /wheels-3.9 /wheels-3.9
11 changes: 10 additions & 1 deletion docker/jetson-nano/Dockerfile.wheels
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG DLIB_VERSION
ARG JETPACK_VERSION
FROM roflcoopter/jetson-nano-dlib:${DLIB_VERSION} as dlib
FROM roflcoopter/jetson-nano-python:${PYTHON_VERSION} as python
FROM roflcoopter/jetson-nano-python:3.9.19 as python-3.9.19
FROM balenalib/jetson-nano-ubuntu:${UBUNTU_VERSION}-build as qemu
FROM nvcr.io/nvidia/l4t-base:r${JETPACK_VERSION} as build

Expand All @@ -14,6 +15,7 @@ COPY --from=qemu /usr/bin/resin-xbuild /usr/bin/resin-xbuild

COPY --from=dlib /wheels /wheels

COPY --from=python-3.9.19 /usr/local /usr/local/
COPY --from=python /usr/local /usr/local/
RUN \
cd /usr/local/bin && \
Expand Down Expand Up @@ -58,12 +60,19 @@ RUN sed -i "s/OPENCV_VERSION=/OPENCV_VERSION=\"$OPENCV_VERSION\"/" /opencv-pytho
RUN echo "opencv-python-headless==$OPENCV_VERSION" >> /requirements.txt

ADD requirements.txt requirements.txt
ADD requirements-3.9.txt requirements-3.9.txt
RUN \
mkdir -p /wheels \
\
&& python3 -m pip wheel --wheel-dir=/wheels --find-links=/wheels /opencv-python-headless -r /requirements.txt \
&& python3.9 -m pip wheel \
--extra-index-url https://google-coral.github.io/py-repo/ \
--wheel-dir=/wheels-3.9 \
--find-links=/wheels ${EXTRA_PIP_ARGS} /opencv-python-headless -r /requirements-3.9.txt \
\
&& ls -al /wheels/
&& ls -al /wheels/ /wheels-3.9/

FROM scratch

COPY --from=build /wheels /wheels
COPY --from=build /wheels-3.9 /wheels-3.9
2 changes: 2 additions & 0 deletions requirements-3.9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy==1.26.4
pycoral~=2.0
2 changes: 1 addition & 1 deletion viseron/components/edgetpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __init__(self, vis, config, domain) -> None:
self._process_initialization_done = mp.Event()
self._process_initialization_error = mp.Event()
super().__init__(vis, f"{COMPONENT}.{domain}")
self._process_initialization_done.wait(10)
self._process_initialization_done.wait(30)
if (
not self._process_initialization_done.is_set()
or self._process_initialization_error.is_set()
Expand Down

0 comments on commit 7f94317

Please sign in to comment.