From c7e7a343fa14c39c4b4d9b0285e5698562ae7250 Mon Sep 17 00:00:00 2001 From: alexanderkomarovincode3 Date: Wed, 21 Aug 2024 12:01:14 +0200 Subject: [PATCH 1/3] Rename cv .github folder Add github workflow file Update gw Update gw update gw Update gw update gw Update gw update gw update gw update gw update gw update gw update gw update gw update gw update gw Update gw update gw --- .github/workflows/build.yaml | 46 +++++++++++++++++++ {.github => .github_init}/issue_template.md | 0 .../workflows/build_wheels_linux.yml | 0 .../workflows/build_wheels_linux_arm.yml | 0 .../workflows/build_wheels_macos.yml | 0 .../workflows/build_wheels_macos_m1.yml | 0 .../workflows/build_wheels_windows.yml | 0 Dockerfile.incode_build | 37 +++++++++++++++ 8 files changed, 83 insertions(+) create mode 100644 .github/workflows/build.yaml rename {.github => .github_init}/issue_template.md (100%) rename {.github => .github_init}/workflows/build_wheels_linux.yml (100%) rename {.github => .github_init}/workflows/build_wheels_linux_arm.yml (100%) rename {.github => .github_init}/workflows/build_wheels_macos.yml (100%) rename {.github => .github_init}/workflows/build_wheels_macos_m1.yml (100%) rename {.github => .github_init}/workflows/build_wheels_windows.yml (100%) create mode 100644 Dockerfile.incode_build diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..cac3fc73 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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/.github/issue_template.md b/.github_init/issue_template.md similarity index 100% rename from .github/issue_template.md rename to .github_init/issue_template.md diff --git a/.github/workflows/build_wheels_linux.yml b/.github_init/workflows/build_wheels_linux.yml similarity index 100% rename from .github/workflows/build_wheels_linux.yml rename to .github_init/workflows/build_wheels_linux.yml diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github_init/workflows/build_wheels_linux_arm.yml similarity index 100% rename from .github/workflows/build_wheels_linux_arm.yml rename to .github_init/workflows/build_wheels_linux_arm.yml diff --git a/.github/workflows/build_wheels_macos.yml b/.github_init/workflows/build_wheels_macos.yml similarity index 100% rename from .github/workflows/build_wheels_macos.yml rename to .github_init/workflows/build_wheels_macos.yml diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github_init/workflows/build_wheels_macos_m1.yml similarity index 100% rename from .github/workflows/build_wheels_macos_m1.yml rename to .github_init/workflows/build_wheels_macos_m1.yml diff --git a/.github/workflows/build_wheels_windows.yml b/.github_init/workflows/build_wheels_windows.yml similarity index 100% rename from .github/workflows/build_wheels_windows.yml rename to .github_init/workflows/build_wheels_windows.yml 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 / From 348b24a72dfb63d4c7250dfa8cc9dce9c60988af Mon Sep 17 00:00:00 2001 From: alexanderkomarovincode3 Date: Thu, 22 Aug 2024 16:10:15 +0200 Subject: [PATCH 2/3] Return original worfklow. I disabled it in github actions. --- {.github_init => .github}/issue_template.md | 0 {.github_init => .github}/workflows/build_wheels_linux.yml | 0 {.github_init => .github}/workflows/build_wheels_linux_arm.yml | 0 {.github_init => .github}/workflows/build_wheels_macos.yml | 0 {.github_init => .github}/workflows/build_wheels_macos_m1.yml | 0 {.github_init => .github}/workflows/build_wheels_windows.yml | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {.github_init => .github}/issue_template.md (100%) rename {.github_init => .github}/workflows/build_wheels_linux.yml (100%) rename {.github_init => .github}/workflows/build_wheels_linux_arm.yml (100%) rename {.github_init => .github}/workflows/build_wheels_macos.yml (100%) rename {.github_init => .github}/workflows/build_wheels_macos_m1.yml (100%) rename {.github_init => .github}/workflows/build_wheels_windows.yml (100%) diff --git a/.github_init/issue_template.md b/.github/issue_template.md similarity index 100% rename from .github_init/issue_template.md rename to .github/issue_template.md diff --git a/.github_init/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml similarity index 100% rename from .github_init/workflows/build_wheels_linux.yml rename to .github/workflows/build_wheels_linux.yml diff --git a/.github_init/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml similarity index 100% rename from .github_init/workflows/build_wheels_linux_arm.yml rename to .github/workflows/build_wheels_linux_arm.yml diff --git a/.github_init/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml similarity index 100% rename from .github_init/workflows/build_wheels_macos.yml rename to .github/workflows/build_wheels_macos.yml diff --git a/.github_init/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml similarity index 100% rename from .github_init/workflows/build_wheels_macos_m1.yml rename to .github/workflows/build_wheels_macos_m1.yml diff --git a/.github_init/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml similarity index 100% rename from .github_init/workflows/build_wheels_windows.yml rename to .github/workflows/build_wheels_windows.yml From e977dfedadc59f0e273cc3a33c9c382672da9e0f Mon Sep 17 00:00:00 2001 From: alexanderkomarovincode3 Date: Thu, 22 Aug 2024 16:11:19 +0200 Subject: [PATCH 3/3] Rename incode workflow file. --- .github/workflows/{build.yaml => build_wheels_linux_incode.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build.yaml => build_wheels_linux_incode.yml} (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build_wheels_linux_incode.yml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/build_wheels_linux_incode.yml