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

Use uv instead of pip #14759

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: On pull request
on:
pull_request:
paths-ignore:
- 'docs/**'
- "docs/**"

env:
DEFAULT_PYTHON: 3.9
Expand Down Expand Up @@ -71,10 +71,11 @@ jobs:
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install requirements
run: |
python3 -m pip install -U pip
python3 -m pip install -r docker/main/requirements-dev.txt
uv pip install --system -r docker/main/requirements-dev.txt
- name: Check formatting
run: |
ruff format --check --diff frigate migrations docker *.py
Expand Down
4 changes: 2 additions & 2 deletions docker/hailo8l/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ COPY --from=hailort /hailo-wheels /deps/hailo-wheels
COPY --from=hailort /rootfs/ /

# Install the wheels
RUN pip3 install -U /deps/h8l-wheels/*.whl
RUN pip3 install -U /deps/hailo-wheels/*.whl
RUN uv pip install --system -U /deps/h8l-wheels/*.whl
RUN uv pip install --system -U /deps/hailo-wheels/*.whl

# Copy base files from the rootfs stage
COPY --from=rootfs / /
Expand Down
24 changes: 15 additions & 9 deletions docker/main/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ FROM base_host AS ov-converter
ARG DEBIAN_FRONTEND

# Install OpenVino Runtime and Dev library
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY docker/main/requirements-ov.txt /requirements-ov.txt
RUN apt-get -qq update \
&& apt-get -qq install -y wget python3 python3-dev python3-distutils gcc pkg-config libhdf5-dev \
&& wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& python3 get-pip.py "pip" \
&& pip install -r /requirements-ov.txt
&& uv pip install --system -r /requirements-ov.txt

# Get OpenVino Model
RUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \
Expand Down Expand Up @@ -167,19 +166,26 @@ RUN apt-get -qq update \
# Ensure python3 defaults to python3.9
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1

# need to install pip for requirements
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& python3 get-pip.py "pip"

RUN python3 -m pip install --upgrade pip setuptools wheel appdirs

# install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# install required python deps
COPY docker/main/requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
RUN uv pip install --system --no-build-isolation -r /requirements.txt

# Build pysqlite3 from source
COPY docker/main/build_pysqlite3.sh /build_pysqlite3.sh
RUN /build_pysqlite3.sh

COPY docker/main/requirements-wheels.txt /requirements-wheels.txt
RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt

RUN uv add --requirements /requirements-wheels.txt \
&& uv build --wheel --out-dir /wheels

# Collect deps in a single layer
FROM scratch AS deps-rootfs
Expand Down Expand Up @@ -218,12 +224,12 @@ ENV PATH="/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PA
ENV LIBAVFORMAT_VERSION_MAJOR=60

# Install dependencies
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \
/deps/install_deps.sh

RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
python3 -m pip install --upgrade pip && \
pip3 install -U /deps/wheels/*.whl
uv pip install --system -U /deps/wheels/*.whl

COPY --from=deps-rootfs / /

Expand Down Expand Up @@ -270,7 +276,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \
pip3 install -r requirements-dev.txt
uv pip install --system -r requirements-dev.txt

HEALTHCHECK NONE

Expand Down
3 changes: 2 additions & 1 deletion docker/rockchip/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ FROM wheels as rk-wheels
COPY docker/main/requirements-wheels.txt /requirements-wheels.txt
COPY docker/rockchip/requirements-wheels-rk.txt /requirements-wheels-rk.txt
RUN sed -i "/https:\/\//d" /requirements-wheels.txt
# we have to use pip to build wheel
RUN pip3 wheel --wheel-dir=/rk-wheels -c /requirements-wheels.txt -r /requirements-wheels-rk.txt

FROM deps AS rk-frigate
ARG TARGETARCH

RUN --mount=type=bind,from=rk-wheels,source=/rk-wheels,target=/deps/rk-wheels \
pip3 install -U /deps/rk-wheels/*.whl
uv pip install -U /deps/rk-wheels/*.whl

WORKDIR /opt/frigate/
COPY --from=rootfs / /
Expand Down
9 changes: 6 additions & 3 deletions docker/rocm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ RUN apt-get -y install libnuma1
WORKDIR /opt/frigate/
COPY --from=rootfs / /

# install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# install required rocm deps
COPY docker/rocm/requirements-wheels-rocm.txt /requirements.txt
RUN python3 -m pip install --upgrade pip \
&& pip3 uninstall -y onnxruntime-openvino \
&& pip3 install -r /requirements.txt
RUN uv pip uninstall --system -y onnxruntime-openvino \
&& uv pip install --system -r /requirements.txt

#######################################################################
FROM scratch AS rocm-dist
Expand Down
5 changes: 3 additions & 2 deletions docker/tensorrt/Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG TARGETARCH

# Add TensorRT wheels to another folder
COPY docker/tensorrt/requirements-amd64.txt /requirements-tensorrt.txt
# we have to use pip here to build full dependency
RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt

# Build CuDNN
Expand All @@ -29,7 +30,7 @@ RUN wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_6
FROM tensorrt-base AS frigate-tensorrt
ENV TRT_VER=8.5.3
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
pip3 install -U /deps/trt-wheels/*.whl && \
uv pip install --system -U /deps/trt-wheels/*.whl && \
ldconfig
COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda

Expand All @@ -46,4 +47,4 @@ COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda
COPY docker/tensorrt/detector/rootfs/ /
COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
pip3 install -U /deps/trt-wheels/*.whl
uv pip install --system -U /deps/trt-wheels/*.whl
6 changes: 3 additions & 3 deletions docker/tensorrt/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ RUN --mount=type=bind,source=docker/tensorrt/detector/build_python_tensorrt.sh,t
COPY docker/tensorrt/requirements-arm64.txt /requirements-tensorrt.txt
ADD https://nvidia.box.com/shared/static/9aemm4grzbbkfaesg5l7fplgjtmswhj8.whl /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl

RUN pip3 uninstall -y onnxruntime-openvino \
RUN uv pip uninstall --system -y onnxruntime-openvino \
&& pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt \
&& pip3 install --no-deps /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl
&& uv pip install --system --no-deps /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl

FROM build-wheels AS trt-model-wheels
ARG DEBIAN_FRONTEND
Expand Down Expand Up @@ -76,7 +76,7 @@ COPY --from=jetson-ffmpeg /rootfs /
COPY --from=trt-wheels /etc/TENSORRT_VER /etc/TENSORRT_VER
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
--mount=type=bind,from=trt-model-wheels,source=/trt-model-wheels,target=/deps/trt-model-wheels \
pip3 install -U /deps/trt-wheels/*.whl /deps/trt-model-wheels/*.whl \
uv pip install --system -U /deps/trt-wheels/*.whl /deps/trt-model-wheels/*.whl \
&& ldconfig

WORKDIR /opt/frigate/
Expand Down
2 changes: 1 addition & 1 deletion docker/tensorrt/detector/build_python_tensorrt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [[ "${TARGETARCH}" == "arm64" ]]; then

# Collect dependencies
EXT_PATH=/workspace/external && mkdir -p $EXT_PATH
pip3 install pybind11 && ln -s /usr/local/lib/python3.9/dist-packages/pybind11 $EXT_PATH/pybind11
uv pip install --system pybind11 && ln -s /usr/local/lib/python3.9/dist-packages/pybind11 $EXT_PATH/pybind11
ln -s /usr/include/python3.9 $EXT_PATH/python3.9
ln -s /usr/include/aarch64-linux-gnu/NvOnnxParser.h /workspace/TensorRT/parsers/onnx/

Expand Down
Loading