diff --git a/.github/workflows/build_wheels_linux_incode.yml b/.github/workflows/build_wheels_linux_incode.yml new file mode 100644 index 00000000..cac3fc73 --- /dev/null +++ b/.github/workflows/build_wheels_linux_incode.yml @@ -0,0 +1,46 @@ +name: Linux x86_64 incode +on: + push: + tags: + - "*_incode" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10', '3.11' ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: get tag + id: get_tag + run: | + tag=${{ github.ref_name }} + echo "tag: ${tag//[^0-9]/}" + echo "tag=${tag//[^0-9]/}" >> $GITHUB_OUTPUT + - name: Build wheel + uses: docker/build-push-action@v4 + with: + file: Dockerfile.incode_build + platforms: linux/amd64 + push: false + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + target: export-stage + build-args: | + PYTHON_VERSION=${{ matrix.python-version }} + OPENCV_TAG=${{ steps.get_tag.outputs.tag }} + tags: | + incodetech/opencv-python-env + outputs: type=local,dest=./ + - name: Create release + if: ${{ startsWith(github.ref, 'refs/tags/') == true }} + uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + files: | + opencv_python_*.whl diff --git a/Dockerfile.incode_build b/Dockerfile.incode_build new file mode 100644 index 00000000..e1e91831 --- /dev/null +++ b/Dockerfile.incode_build @@ -0,0 +1,37 @@ +FROM ubuntu:20.04 as build-stage + +ARG PYTHON_VERSION +ARG OPENCV_TAG +ARG NUMPY_VERSION=1.23.5 + +RUN apt update && apt install -y software-properties-common curl + +RUN add-apt-repository -y 'ppa:deadsnakes/ppa' \ + && apt update && apt install -y --no-install-recommends \ + python${PYTHON_VERSION} python${PYTHON_VERSION}-venv python${PYTHON_VERSION}-dev \ + && rm -rf /var/lib/apt/lists/* \ + && curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \ + && pip install -U pip \ + && pip --no-cache-dir install numpy==${NUMPY_VERSION} + +ENV VENV_ROOT_PREFIX=/opt/venv +RUN python${PYTHON_VERSION} -m venv ${VENV_ROOT_PREFIX} + + +WORKDIR /opt/ +RUN apt update && apt install -y git build-essential cmake libopenblas-dev liblapacke-dev libjpeg-dev \ + # trick to opencv find openblas and numpy headers + && cp /usr/include/x86_64-linux-gnu/cblas.h /usr/include/ \ + && ln -s /usr/local/lib/python${PYTHON_VERSION}/dist-packages/numpy/core/include/numpy /usr/include/numpy \ + && git clone https://github.com/opencv/opencv-python.git \ + && cd opencv-python \ + && git checkout ${OPENCV_TAG} \ + && git submodule update --init --recursive \ + && export ENABLE_HEADLESS=1 \ + && MAKEFLAGS='-j3' pip wheel . --verbose \ + # trick to pack openblas lib to wheel + && pip install auditwheel patchelf \ + && auditwheel repair *.whl --plat manylinux_2_31_x86_64 + +FROM scratch AS export-stage +COPY --from=build-stage /opt/opencv-python/wheelhouse /