Skip to content

Commit dfcbbfc

Browse files
fix: 修正构建
1 parent 1bec4af commit dfcbbfc

File tree

3 files changed

+188
-8
lines changed

3 files changed

+188
-8
lines changed

.github/workflows/build-manywheel-images.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- cron: 0 0 * * *
77

88
jobs:
9-
build:
9+
build_loongarch64_wheels:
10+
name: Build image for loongarch64
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Check version
@@ -39,12 +40,10 @@ jobs:
3940
if: env.build == '1'
4041
run: |
4142
mkdir -p docker/manylinux_2_38
43+
wget -qO docker/manylinux_2_38/Dockerfile_loongarch64 https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
44+
patch -p1 < loong64.patch
4245
cd docker/manylinux_2_38
43-
wget -qO Dockerfile_loongarch64 https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_aarch64
44-
sed -i "[email protected]/opencv-ci/[email protected]/loong64/manylinux_2_38_loongarch64@g" Dockerfile_loongarch64
45-
sed -i "s@cp /usr/include/lapacke@# cp /usr/include/lapacke@g" Dockerfile_loongarch64
46-
sed -i 's/epel-release//g' Dockerfile_loongarch64
47-
46+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM ghcr.io/loong64/manylinux_2_38_loongarch64@g" Dockerfile_loongarch64
4847
image_tag=$(cat Dockerfile_loongarch64 | grep "Version:" | sed 's/# Version: //')
4948
echo "image_tag=${image_tag}" >> $GITHUB_ENV
5049
@@ -59,7 +58,8 @@ jobs:
5958
if: env.build == '1'
6059
uses: docker/build-push-action@v6
6160
with:
62-
context: docker/manylinux_2_38
61+
context: .
62+
file: docker/manylinux_2_38/Dockerfile_loongarch64
6363
platforms: linux/loong64
6464
push: true
6565
tags: |
@@ -83,4 +83,4 @@ jobs:
8383
uses: softprops/action-gh-release@v2
8484
with:
8585
repository: ${{ github.repository }}
86-
tag_name: ${{ env.version }}
86+
tag_name: ${{ env.version }}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Linux loongarch64
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *'
6+
workflow_dispatch:
7+
8+
9+
jobs:
10+
Check:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
build: ${{ steps.check_version.outputs.build }}
14+
version: ${{ steps.check_version.outputs.version }}
15+
steps:
16+
- name: Check version
17+
id: check_version
18+
run: |
19+
version=$(curl -s "https://api.github.com/repos/opencv/opencv-python/releases/latest" | jq -r .tag_name)
20+
if [ -z "${version}" ] || [ "${version}" == "null" ]; then
21+
echo "Failed to get version"
22+
exit 1
23+
fi
24+
25+
echo "version=${version}" >> $GITHUB_ENV
26+
echo "version=${version}" >> $GITHUB_OUTPUT
27+
echo ""
28+
echo "========== Build Args =========="
29+
echo "opencv-python version: ${version}"
30+
31+
gh release view ${version} -R ${{ github.repository }} | grep opencv.*.whl >/dev/null 2>&1 || echo "build=1" >> $GITHUB_ENV
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
Build:
36+
runs-on: ubuntu-22.04
37+
needs: Check
38+
if: needs.Check.outputs.build == '1'
39+
defaults:
40+
run:
41+
shell: bash
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
python-version: ['3.9']
46+
platform: [x64]
47+
with_contrib: [0, 1]
48+
without_gui: [0, 1]
49+
build_sdist: [0]
50+
env:
51+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
52+
REPO_DIR: .
53+
PROJECT_SPEC: opencv-python
54+
MB_PYTHON_VERSION: ${{ matrix.python-version }}
55+
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
56+
MB_ML_VER: _2_38
57+
TRAVIS_BUILD_DIR: ${{ github.workspace }}
58+
CONFIG_PATH: travis_config.sh
59+
DOCKER_IMAGE: ghcr.io/loong64/opencv-python-manylinux_2_38-loongarch64:latest
60+
USE_CCACHE: 0
61+
UNICODE_WIDTH: 32
62+
PLAT: loongarch64
63+
SDIST: ${{ matrix.build_sdist || 0 }}
64+
ENABLE_HEADLESS: ${{ matrix.without_gui }}
65+
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
66+
VERSION: ${{ needs.Check.outputs.version }}
67+
steps:
68+
- name: Cleanup
69+
run: find . -mindepth 1 -delete
70+
working-directory: ${{ github.workspace }}
71+
- name: Setup environment
72+
run: |
73+
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
74+
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
75+
fi
76+
- name: Checkout
77+
uses: actions/checkout@v3
78+
with:
79+
repository: opencv/opencv-python
80+
ref: ${{ env.VERSION }}
81+
submodules: false
82+
fetch-depth: 0
83+
- name: Build a package
84+
run: source scripts/build.sh
85+
- name: Saving a wheel accordingly to matrix
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
89+
path: wheelhouse/opencv*.whl
90+
91+
Release:
92+
runs-on: ubuntu-22.04
93+
needs: [Check, Build]
94+
if: needs.Check.outputs.build == '1'
95+
env:
96+
VERSION: ${{ needs.Check.outputs.version }}
97+
defaults:
98+
run:
99+
shell: bash
100+
steps:
101+
- uses: actions/download-artifact@v4
102+
with:
103+
name: wheels
104+
path: wheelhouse/
105+
- name: Upload wheels
106+
run: |
107+
pip install twine==6.0.1
108+
for file in wheelhouse/*.whl; do
109+
twine upload --repository-url https://gitlab.com/api/v4/projects/65746188/packages/pypi $file || true
110+
done
111+
env:
112+
TWINE_USERNAME: ${{ github.repository_owner }}
113+
TWINE_PASSWORD: ${{ secrets.GL_TOKEN }}
114+
115+
- name: Upload release
116+
run: |
117+
gh release upload ${{ env.VERSION }} -R ${{ github.repository }} wheelhouse/*.whl --clobber
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

loong64.patch

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/docker/manylinux_2_38/Dockerfile_loongarch64 b/docker/manylinux_2_38/Dockerfile_loongarch64
2+
index 3ed3aa4..783ee6a 100644
3+
--- a/docker/manylinux_2_38/Dockerfile_loongarch64
4+
+++ b/docker/manylinux_2_38/Dockerfile_loongarch64
5+
@@ -18,10 +18,11 @@ ARG AVIF_VERSION=v1.3.0
6+
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
7+
8+
# epel-release need for aarch64 to get openblas packages
9+
-RUN yum install zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
10+
+RUN yum install zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel perl-lib -y && \
11+
yum install openblas-devel dejavu-sans-fonts -y && \
12+
cp /usr/include/openblas/*.h /usr/include/ && \
13+
- cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
14+
+ # cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
15+
+ cp -R /usr/share/fonts/dejavu-sans-fonts /usr/share/fonts/dejavu && \
16+
# libpng will be built from source
17+
yum remove libpng -y
18+
19+
@@ -50,6 +51,7 @@ RUN mkdir ~/freetype_sources && \
20+
RUN curl -O -L https://download.qt.io/archive/qt/5.15/${QT_VERSION}/single/qt-everywhere-opensource-src-${QT_VERSION}.tar.xz && \
21+
tar -xf qt-everywhere-opensource-src-${QT_VERSION}.tar.xz && \
22+
cd qt-everywhere-src-${QT_VERSION} && \
23+
+ sed -i 's/defined(__mips__) || /defined(__mips__) || defined(__loongarch__) || /g' qtbase/src/3rdparty/double-conversion/include/double-conversion/utils.h && \
24+
export MAKEFLAGS=-j$(nproc) && \
25+
./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
26+
make && \
27+
@@ -87,6 +89,8 @@ RUN mkdir ~/yasm_sources && \
28+
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
29+
tar -xf yasm-${YASM_VERSION}.tar.gz && \
30+
cd yasm-${YASM_VERSION} && \
31+
+ curl -o config/config.sub -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.sub && \
32+
+ curl -o config/config.guess -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.guess && \
33+
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
34+
make -j$(getconf _NPROCESSORS_ONLN) && \
35+
make install && \
36+
@@ -97,6 +101,8 @@ RUN mkdir ~/libvpx_sources && \
37+
cd ~/libvpx_sources && \
38+
git clone --depth 1 -b ${VPX_VERSION} https://chromium.googlesource.com/webm/libvpx.git && \
39+
cd libvpx && \
40+
+ curl -L https://github.com/webmproject/libvpx/commit/a7863b9a2f01e5d22919a51c95cbc4a9c10fbb2c.patch | patch -p1 && \
41+
+ curl -L https://github.com/webmproject/libvpx/commit/a604e10afbb2e711e62d8d9ca9c64b368e30b0e2.patch | patch -p1 && \
42+
./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
43+
make -j$(getconf _NPROCESSORS_ONLN) && \
44+
make install && \
45+
@@ -137,6 +143,8 @@ RUN mkdir ~/ffmpeg_sources && \
46+
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
47+
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
48+
cd ccache-${CCACHE_VERSION} && \
49+
+ curl -O -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.sub && \
50+
+ curl -O -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.guess && \
51+
./configure && \
52+
make -j$(getconf _NPROCESSORS_ONLN) && \
53+
make install && \
54+
@@ -157,6 +165,7 @@ USER ci
55+
# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
56+
RUN git config --global --add safe.directory /io
57+
58+
+ENV PIP_EXTRA_INDEX_URL https://gitlab.com/api/v4/projects/65746188/packages/pypi/simple
59+
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig
60+
ENV LDFLAGS -L/ffmpeg_build/lib
61+
ENV PATH "$HOME/bin:$PATH"

0 commit comments

Comments
 (0)