trainingsample 0.2.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trainingsample-0.2.14/.cargo/config.toml +7 -0
- trainingsample-0.2.14/.envrc +15 -0
- trainingsample-0.2.14/.github/workflows/ci.yml +377 -0
- trainingsample-0.2.14/.github/workflows/publish.yml +291 -0
- trainingsample-0.2.14/.gitignore +84 -0
- trainingsample-0.2.14/.pre-commit-config.yaml +103 -0
- trainingsample-0.2.14/.rustfmt.toml +13 -0
- trainingsample-0.2.14/BENCHMARKS.md +112 -0
- trainingsample-0.2.14/Cargo.lock +2140 -0
- trainingsample-0.2.14/Cargo.toml +48 -0
- trainingsample-0.2.14/Dockerfile +87 -0
- trainingsample-0.2.14/LICENSE +21 -0
- trainingsample-0.2.14/PKG-INFO +21 -0
- trainingsample-0.2.14/README.md +291 -0
- trainingsample-0.2.14/clippy.toml +6 -0
- trainingsample-0.2.14/docs/API_COMPAT_CV2.md +357 -0
- trainingsample-0.2.14/docs/BUILDING_STATIC_OPENCV.md +197 -0
- trainingsample-0.2.14/pyproject.toml +70 -0
- trainingsample-0.2.14/rust-toolchain.toml +4 -0
- trainingsample-0.2.14/scripts/build-opencv-static.sh +298 -0
- trainingsample-0.2.14/scripts/repair-wheel.sh +5 -0
- trainingsample-0.2.14/scripts/run_competitive_benchmarks.sh +34 -0
- trainingsample-0.2.14/setup-env.sh +34 -0
- trainingsample-0.2.14/src/core.rs +187 -0
- trainingsample-0.2.14/src/cropping.rs +183 -0
- trainingsample-0.2.14/src/cv_batch_ops.rs +462 -0
- trainingsample-0.2.14/src/cv_batch_ops_optimized.rs +402 -0
- trainingsample-0.2.14/src/cv_compat.rs +790 -0
- trainingsample-0.2.14/src/format_conversion_simd.rs +278 -0
- trainingsample-0.2.14/src/lib.rs +148 -0
- trainingsample-0.2.14/src/loading.rs +17 -0
- trainingsample-0.2.14/src/luminance.rs +317 -0
- trainingsample-0.2.14/src/luminance_simd.rs +1041 -0
- trainingsample-0.2.14/src/opencv_ops.rs +321 -0
- trainingsample-0.2.14/src/python_bindings.rs +1987 -0
- trainingsample-0.2.14/src/tests.rs +349 -0
- trainingsample-0.2.14/src/true_batch_ops.rs +412 -0
- trainingsample-0.2.14/tests/__init__.py +1 -0
- trainingsample-0.2.14/tests/comprehensive_tests.rs +642 -0
- trainingsample-0.2.14/tests/test_comprehensive.py +452 -0
- trainingsample-0.2.14/tests/test_performance_benchmarks.py +1007 -0
- trainingsample-0.2.14/tests/test_python_bindings.py +216 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Cargo configuration for OpenCV linking
|
|
2
|
+
#
|
|
3
|
+
# Default: Uses system OpenCV (for CI and local development)
|
|
4
|
+
# Release builds: Override with static linking via workflow env vars
|
|
5
|
+
|
|
6
|
+
# This file is intentionally minimal - it lets opencv-rust probe the system.
|
|
7
|
+
# The release workflow sets OPENCV_* env vars to force static linking.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Environment variables for OpenCV Rust bindings
|
|
2
|
+
export DYLD_LIBRARY_PATH="/opt/homebrew/Cellar/llvm/21.1.1/lib:$DYLD_LIBRARY_PATH"
|
|
3
|
+
export LIBCLANG_PATH="/opt/homebrew/Cellar/llvm/21.1.1/lib"
|
|
4
|
+
export LLVM_CONFIG_PATH="/opt/homebrew/Cellar/llvm/21.1.1/bin/llvm-config"
|
|
5
|
+
|
|
6
|
+
# OpenCV environment variables
|
|
7
|
+
export OPENCV_LINK_LIBS="opencv_calib3d,opencv_core,opencv_dnn,opencv_features2d,opencv_flann,opencv_highgui,opencv_imgcodecs,opencv_imgproc,opencv_ml,opencv_objdetect,opencv_photo,opencv_stitching,opencv_video,opencv_videoio"
|
|
8
|
+
export OPENCV_LINK_PATHS="/opt/homebrew/lib"
|
|
9
|
+
export OPENCV_INCLUDE_PATHS="/opt/homebrew/include/opencv4"
|
|
10
|
+
|
|
11
|
+
# Rust build optimization
|
|
12
|
+
export RUSTFLAGS="-C target-cpu=native"
|
|
13
|
+
|
|
14
|
+
# macOS deployment target - match current system
|
|
15
|
+
export MACOSX_DEPLOYMENT_TARGET="$(sw_vers -productVersion | cut -d. -f1,2)"
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
CARGO_TERM_COLOR: always
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
rust-tests:
|
|
14
|
+
name: Rust Tests
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install OpenCV and LLVM dependencies
|
|
21
|
+
run: |
|
|
22
|
+
sudo apt-get update
|
|
23
|
+
sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
|
|
24
|
+
# Install LLVM 18 which has the proper libclang.so symlink
|
|
25
|
+
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
|
|
26
|
+
# Set environment variables for LLVM 18
|
|
27
|
+
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
|
|
28
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
|
|
29
|
+
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
30
|
+
# Verify the key files exist
|
|
31
|
+
ls -la /usr/lib/llvm-18/lib/libclang.so
|
|
32
|
+
which llvm-config-18
|
|
33
|
+
|
|
34
|
+
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
|
|
35
|
+
echo "Building OpenCV 4.12 from source..."
|
|
36
|
+
cd /tmp
|
|
37
|
+
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
|
|
38
|
+
tar -xzf 4.12.0.tar.gz
|
|
39
|
+
cd opencv-4.12.0
|
|
40
|
+
mkdir build
|
|
41
|
+
cd build
|
|
42
|
+
cmake \
|
|
43
|
+
-DCMAKE_BUILD_TYPE=RELEASE \
|
|
44
|
+
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
45
|
+
-DWITH_CUDA=OFF \
|
|
46
|
+
-DWITH_OPENGL=OFF \
|
|
47
|
+
-DWITH_OPENCL=OFF \
|
|
48
|
+
-DWITH_TBB=OFF \
|
|
49
|
+
-DWITH_IPP=OFF \
|
|
50
|
+
-DWITH_1394=OFF \
|
|
51
|
+
-DWITH_V4L=OFF \
|
|
52
|
+
-DWITH_GTK=OFF \
|
|
53
|
+
-DBUILD_TESTS=OFF \
|
|
54
|
+
-DBUILD_PERF_TESTS=OFF \
|
|
55
|
+
-DBUILD_EXAMPLES=OFF \
|
|
56
|
+
-DBUILD_opencv_python2=OFF \
|
|
57
|
+
-DBUILD_opencv_python3=OFF \
|
|
58
|
+
-DBUILD_opencv_java=OFF \
|
|
59
|
+
-DOPENCV_GENERATE_PKGCONFIG=ON \
|
|
60
|
+
..
|
|
61
|
+
make -j$(nproc)
|
|
62
|
+
sudo make install
|
|
63
|
+
sudo ldconfig
|
|
64
|
+
|
|
65
|
+
# Set OpenCV environment variables
|
|
66
|
+
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
67
|
+
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
68
|
+
|
|
69
|
+
- name: Install Rust toolchain
|
|
70
|
+
uses: dtolnay/rust-toolchain@master
|
|
71
|
+
with:
|
|
72
|
+
toolchain: 1.89
|
|
73
|
+
components: rustfmt, clippy
|
|
74
|
+
|
|
75
|
+
- name: Cache cargo registry
|
|
76
|
+
uses: actions/cache@v4
|
|
77
|
+
with:
|
|
78
|
+
path: ~/.cargo/registry
|
|
79
|
+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
80
|
+
|
|
81
|
+
- name: Cache cargo index
|
|
82
|
+
uses: actions/cache@v4
|
|
83
|
+
with:
|
|
84
|
+
path: ~/.cargo/git
|
|
85
|
+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
86
|
+
|
|
87
|
+
- name: Cache cargo target
|
|
88
|
+
uses: actions/cache@v4
|
|
89
|
+
with:
|
|
90
|
+
path: target
|
|
91
|
+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
92
|
+
|
|
93
|
+
- name: Check formatting
|
|
94
|
+
run: cargo fmt --all -- --check
|
|
95
|
+
|
|
96
|
+
- name: Run clippy
|
|
97
|
+
run: cargo clippy --all-targets --no-default-features --features python-bindings,simd,opencv -- -D warnings
|
|
98
|
+
|
|
99
|
+
- name: Run tests (no Python bindings)
|
|
100
|
+
run: cargo test --no-default-features --features simd,opencv
|
|
101
|
+
|
|
102
|
+
- name: Compile tests (Linux compatible features)
|
|
103
|
+
run: cargo test --no-default-features --features python-bindings,simd,opencv --no-run
|
|
104
|
+
|
|
105
|
+
python-tests:
|
|
106
|
+
name: Python Tests
|
|
107
|
+
runs-on: ubuntu-latest
|
|
108
|
+
strategy:
|
|
109
|
+
matrix:
|
|
110
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
111
|
+
|
|
112
|
+
steps:
|
|
113
|
+
- uses: actions/checkout@v4
|
|
114
|
+
|
|
115
|
+
- name: Install OpenCV and LLVM dependencies
|
|
116
|
+
run: |
|
|
117
|
+
sudo apt-get update
|
|
118
|
+
sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
|
|
119
|
+
# Install LLVM 18 which has the proper libclang.so symlink
|
|
120
|
+
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
|
|
121
|
+
# Set environment variables for LLVM 18
|
|
122
|
+
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
|
|
123
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
|
|
124
|
+
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
125
|
+
# Verify the key files exist
|
|
126
|
+
ls -la /usr/lib/llvm-18/lib/libclang.so
|
|
127
|
+
which llvm-config-18
|
|
128
|
+
|
|
129
|
+
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
|
|
130
|
+
echo "Building OpenCV 4.12 from source..."
|
|
131
|
+
cd /tmp
|
|
132
|
+
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
|
|
133
|
+
tar -xzf 4.12.0.tar.gz
|
|
134
|
+
cd opencv-4.12.0
|
|
135
|
+
mkdir build
|
|
136
|
+
cd build
|
|
137
|
+
cmake \
|
|
138
|
+
-DCMAKE_BUILD_TYPE=RELEASE \
|
|
139
|
+
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
140
|
+
-DWITH_CUDA=OFF \
|
|
141
|
+
-DWITH_OPENGL=OFF \
|
|
142
|
+
-DWITH_OPENCL=OFF \
|
|
143
|
+
-DWITH_TBB=OFF \
|
|
144
|
+
-DWITH_IPP=OFF \
|
|
145
|
+
-DWITH_1394=OFF \
|
|
146
|
+
-DWITH_V4L=OFF \
|
|
147
|
+
-DWITH_GTK=OFF \
|
|
148
|
+
-DBUILD_TESTS=OFF \
|
|
149
|
+
-DBUILD_PERF_TESTS=OFF \
|
|
150
|
+
-DBUILD_EXAMPLES=OFF \
|
|
151
|
+
-DBUILD_opencv_python2=OFF \
|
|
152
|
+
-DBUILD_opencv_python3=OFF \
|
|
153
|
+
-DBUILD_opencv_java=OFF \
|
|
154
|
+
-DOPENCV_GENERATE_PKGCONFIG=ON \
|
|
155
|
+
..
|
|
156
|
+
make -j$(nproc)
|
|
157
|
+
sudo make install
|
|
158
|
+
sudo ldconfig
|
|
159
|
+
|
|
160
|
+
# Set OpenCV environment variables
|
|
161
|
+
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
162
|
+
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
163
|
+
|
|
164
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
165
|
+
uses: actions/setup-python@v4
|
|
166
|
+
with:
|
|
167
|
+
python-version: ${{ matrix.python-version }}
|
|
168
|
+
|
|
169
|
+
- name: Install Rust toolchain
|
|
170
|
+
uses: dtolnay/rust-toolchain@master
|
|
171
|
+
with:
|
|
172
|
+
toolchain: 1.89
|
|
173
|
+
components: rustfmt, clippy
|
|
174
|
+
|
|
175
|
+
- name: Install maturin (Linux/macOS)
|
|
176
|
+
run: pip install maturin[patchelf]
|
|
177
|
+
|
|
178
|
+
- name: Build Python package (Linux)
|
|
179
|
+
if: runner.os == 'Linux'
|
|
180
|
+
run: |
|
|
181
|
+
mkdir -p dist
|
|
182
|
+
maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv
|
|
183
|
+
|
|
184
|
+
- name: Build Python package (macOS)
|
|
185
|
+
if: runner.os == 'macOS'
|
|
186
|
+
run: |
|
|
187
|
+
mkdir -p dist
|
|
188
|
+
maturin build --release --out dist --no-default-features --features python-bindings,simd,metal
|
|
189
|
+
|
|
190
|
+
- name: Install built package (Linux/macOS)
|
|
191
|
+
run: pip install dist/*.whl
|
|
192
|
+
|
|
193
|
+
- name: Install test dependencies
|
|
194
|
+
run: pip install pytest pytest-benchmark numpy pillow opencv-python
|
|
195
|
+
|
|
196
|
+
- name: Run Python tests
|
|
197
|
+
run: pytest tests/ -v
|
|
198
|
+
|
|
199
|
+
pre-commit:
|
|
200
|
+
name: Pre-commit hooks
|
|
201
|
+
runs-on: ubuntu-latest
|
|
202
|
+
|
|
203
|
+
steps:
|
|
204
|
+
- uses: actions/checkout@v4
|
|
205
|
+
|
|
206
|
+
- name: Install OpenCV and LLVM dependencies
|
|
207
|
+
run: |
|
|
208
|
+
sudo apt-get update
|
|
209
|
+
sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
|
|
210
|
+
# Install LLVM 18 which has the proper libclang.so symlink
|
|
211
|
+
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
|
|
212
|
+
# Set environment variables for LLVM 18
|
|
213
|
+
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
|
|
214
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
|
|
215
|
+
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
216
|
+
# Verify the key files exist
|
|
217
|
+
ls -la /usr/lib/llvm-18/lib/libclang.so
|
|
218
|
+
which llvm-config-18
|
|
219
|
+
|
|
220
|
+
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
|
|
221
|
+
echo "Building OpenCV 4.12 from source..."
|
|
222
|
+
cd /tmp
|
|
223
|
+
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
|
|
224
|
+
tar -xzf 4.12.0.tar.gz
|
|
225
|
+
cd opencv-4.12.0
|
|
226
|
+
mkdir build
|
|
227
|
+
cd build
|
|
228
|
+
cmake \
|
|
229
|
+
-DCMAKE_BUILD_TYPE=RELEASE \
|
|
230
|
+
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
231
|
+
-DWITH_CUDA=OFF \
|
|
232
|
+
-DWITH_OPENGL=OFF \
|
|
233
|
+
-DWITH_OPENCL=OFF \
|
|
234
|
+
-DWITH_TBB=OFF \
|
|
235
|
+
-DWITH_IPP=OFF \
|
|
236
|
+
-DWITH_1394=OFF \
|
|
237
|
+
-DWITH_V4L=OFF \
|
|
238
|
+
-DWITH_GTK=OFF \
|
|
239
|
+
-DBUILD_TESTS=OFF \
|
|
240
|
+
-DBUILD_PERF_TESTS=OFF \
|
|
241
|
+
-DBUILD_EXAMPLES=OFF \
|
|
242
|
+
-DBUILD_opencv_python2=OFF \
|
|
243
|
+
-DBUILD_opencv_python3=OFF \
|
|
244
|
+
-DBUILD_opencv_java=OFF \
|
|
245
|
+
-DOPENCV_GENERATE_PKGCONFIG=ON \
|
|
246
|
+
..
|
|
247
|
+
make -j$(nproc)
|
|
248
|
+
sudo make install
|
|
249
|
+
sudo ldconfig
|
|
250
|
+
|
|
251
|
+
# Set OpenCV environment variables
|
|
252
|
+
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
253
|
+
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
254
|
+
|
|
255
|
+
- name: Set up Python
|
|
256
|
+
uses: actions/setup-python@v4
|
|
257
|
+
with:
|
|
258
|
+
python-version: 3.11
|
|
259
|
+
|
|
260
|
+
- name: Install Rust toolchain
|
|
261
|
+
uses: dtolnay/rust-toolchain@master
|
|
262
|
+
with:
|
|
263
|
+
toolchain: 1.89
|
|
264
|
+
components: rustfmt, clippy
|
|
265
|
+
|
|
266
|
+
- name: Install cargo-audit
|
|
267
|
+
run: cargo install cargo-audit
|
|
268
|
+
|
|
269
|
+
- name: Install pre-commit
|
|
270
|
+
run: pip install pre-commit
|
|
271
|
+
|
|
272
|
+
- name: Run pre-commit
|
|
273
|
+
run: pre-commit run --all-files
|
|
274
|
+
|
|
275
|
+
build-wheels:
|
|
276
|
+
name: Build wheels
|
|
277
|
+
runs-on: ${{ matrix.os }}
|
|
278
|
+
strategy:
|
|
279
|
+
matrix:
|
|
280
|
+
os: [ubuntu-latest, macos-latest]
|
|
281
|
+
|
|
282
|
+
steps:
|
|
283
|
+
- uses: actions/checkout@v4
|
|
284
|
+
|
|
285
|
+
- name: Install OpenCV and LLVM dependencies (Ubuntu)
|
|
286
|
+
if: runner.os == 'Linux'
|
|
287
|
+
run: |
|
|
288
|
+
sudo apt-get update
|
|
289
|
+
sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
|
|
290
|
+
# Install LLVM 18 which has the proper libclang.so symlink
|
|
291
|
+
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
|
|
292
|
+
# Set environment variables for LLVM 18
|
|
293
|
+
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
|
|
294
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
|
|
295
|
+
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
296
|
+
# Verify the key files exist
|
|
297
|
+
ls -la /usr/lib/llvm-18/lib/libclang.so
|
|
298
|
+
which llvm-config-18
|
|
299
|
+
|
|
300
|
+
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
|
|
301
|
+
echo "Building OpenCV 4.12 from source..."
|
|
302
|
+
cd /tmp
|
|
303
|
+
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
|
|
304
|
+
tar -xzf 4.12.0.tar.gz
|
|
305
|
+
cd opencv-4.12.0
|
|
306
|
+
mkdir build
|
|
307
|
+
cd build
|
|
308
|
+
cmake \
|
|
309
|
+
-DCMAKE_BUILD_TYPE=RELEASE \
|
|
310
|
+
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
311
|
+
-DWITH_CUDA=OFF \
|
|
312
|
+
-DWITH_OPENGL=OFF \
|
|
313
|
+
-DWITH_OPENCL=OFF \
|
|
314
|
+
-DWITH_TBB=OFF \
|
|
315
|
+
-DWITH_IPP=OFF \
|
|
316
|
+
-DWITH_1394=OFF \
|
|
317
|
+
-DWITH_V4L=OFF \
|
|
318
|
+
-DWITH_GTK=OFF \
|
|
319
|
+
-DBUILD_TESTS=OFF \
|
|
320
|
+
-DBUILD_PERF_TESTS=OFF \
|
|
321
|
+
-DBUILD_EXAMPLES=OFF \
|
|
322
|
+
-DBUILD_opencv_python2=OFF \
|
|
323
|
+
-DBUILD_opencv_python3=OFF \
|
|
324
|
+
-DBUILD_opencv_java=OFF \
|
|
325
|
+
-DOPENCV_GENERATE_PKGCONFIG=ON \
|
|
326
|
+
..
|
|
327
|
+
make -j$(nproc)
|
|
328
|
+
sudo make install
|
|
329
|
+
sudo ldconfig
|
|
330
|
+
|
|
331
|
+
# Set OpenCV environment variables
|
|
332
|
+
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
333
|
+
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
- name: Set up Python
|
|
338
|
+
uses: actions/setup-python@v4
|
|
339
|
+
with:
|
|
340
|
+
python-version: 3.11
|
|
341
|
+
|
|
342
|
+
- name: Install Rust toolchain
|
|
343
|
+
uses: dtolnay/rust-toolchain@master
|
|
344
|
+
with:
|
|
345
|
+
toolchain: 1.89
|
|
346
|
+
|
|
347
|
+
- name: Install maturin (Linux/macOS)
|
|
348
|
+
run: pip install maturin[patchelf]
|
|
349
|
+
|
|
350
|
+
- name: Install OpenCV (macOS)
|
|
351
|
+
if: runner.os == 'macOS'
|
|
352
|
+
run: |
|
|
353
|
+
# Install OpenCV and LLVM via Homebrew
|
|
354
|
+
brew install opencv llvm
|
|
355
|
+
# Set up LLVM environment for opencv-rust bindings (keg-only installation)
|
|
356
|
+
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
|
|
357
|
+
echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
|
|
358
|
+
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
359
|
+
# Set up OpenCV environment
|
|
360
|
+
echo "OPENCV_LINK_LIBS=opencv_calib3d,opencv_core,opencv_dnn,opencv_features2d,opencv_flann,opencv_highgui,opencv_imgcodecs,opencv_imgproc,opencv_ml,opencv_objdetect,opencv_photo,opencv_stitching,opencv_video,opencv_videoio" >> $GITHUB_ENV
|
|
361
|
+
echo "OPENCV_LINK_PATHS=/opt/homebrew/lib" >> $GITHUB_ENV
|
|
362
|
+
echo "OPENCV_INCLUDE_PATHS=/opt/homebrew/include/opencv4" >> $GITHUB_ENV
|
|
363
|
+
|
|
364
|
+
- name: Build wheels (Linux)
|
|
365
|
+
if: runner.os == 'Linux'
|
|
366
|
+
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv
|
|
367
|
+
|
|
368
|
+
- name: Build wheels (macOS)
|
|
369
|
+
if: runner.os == 'macOS'
|
|
370
|
+
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv,metal
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
- name: Upload wheels
|
|
374
|
+
uses: actions/upload-artifact@v4
|
|
375
|
+
with:
|
|
376
|
+
name: wheels-${{ matrix.os }}
|
|
377
|
+
path: dist/
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
linux:
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
include:
|
|
15
|
+
# Ubuntu 22.04 (libc 2.35)
|
|
16
|
+
- os: ubuntu-22.04
|
|
17
|
+
target: x86_64
|
|
18
|
+
manylinux: manylinux_2_35
|
|
19
|
+
python: '3.11'
|
|
20
|
+
- os: ubuntu-22.04
|
|
21
|
+
target: x86_64
|
|
22
|
+
manylinux: manylinux_2_35
|
|
23
|
+
python: '3.12'
|
|
24
|
+
- os: ubuntu-22.04
|
|
25
|
+
target: x86_64
|
|
26
|
+
manylinux: manylinux_2_35
|
|
27
|
+
python: '3.13'
|
|
28
|
+
# Ubuntu 24.04 (libc 2.39)
|
|
29
|
+
- os: ubuntu-24.04
|
|
30
|
+
target: x86_64
|
|
31
|
+
manylinux: manylinux_2_39
|
|
32
|
+
python: '3.11'
|
|
33
|
+
- os: ubuntu-24.04
|
|
34
|
+
target: x86_64
|
|
35
|
+
manylinux: manylinux_2_39
|
|
36
|
+
python: '3.12'
|
|
37
|
+
- os: ubuntu-24.04
|
|
38
|
+
target: x86_64
|
|
39
|
+
manylinux: manylinux_2_39
|
|
40
|
+
python: '3.13'
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
- uses: actions/setup-python@v5
|
|
44
|
+
with:
|
|
45
|
+
python-version: ${{ matrix.python }}
|
|
46
|
+
|
|
47
|
+
- name: Cache static OpenCV
|
|
48
|
+
id: cache-opencv
|
|
49
|
+
uses: actions/cache@v4
|
|
50
|
+
with:
|
|
51
|
+
path: third_party/opencv-static
|
|
52
|
+
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}
|
|
53
|
+
|
|
54
|
+
- name: Install build dependencies
|
|
55
|
+
run: |
|
|
56
|
+
# Completely remove needrestart to eliminate hanging prompts
|
|
57
|
+
sudo apt-get remove -y needrestart || true
|
|
58
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
59
|
+
|
|
60
|
+
sudo apt-get update
|
|
61
|
+
# Install basic LLVM for opencv-rust bindings codegen
|
|
62
|
+
sudo apt-get install -y clang libclang-dev llvm-dev cmake curl wget software-properties-common nasm yasm pkg-config
|
|
63
|
+
|
|
64
|
+
# For Ubuntu 22.04, use the default LLVM 14 instead of PPA to avoid restart issues
|
|
65
|
+
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
|
|
66
|
+
echo "Using default LLVM 14 for Ubuntu 22.04"
|
|
67
|
+
sudo apt-get install -y llvm-14 llvm-14-dev llvm-14-tools libclang-14-dev
|
|
68
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-14" >> $GITHUB_ENV
|
|
69
|
+
else
|
|
70
|
+
# Ubuntu 24.04 has LLVM 18 by default
|
|
71
|
+
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
|
|
72
|
+
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Find the correct libclang.so path and set environment variables (search only LLVM directories)
|
|
76
|
+
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
|
|
77
|
+
LIBCLANG_PATH="/usr/lib/llvm-14/lib"
|
|
78
|
+
else
|
|
79
|
+
LIBCLANG_PATH="/usr/lib/llvm-18/lib"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Verify the file exists at the expected location
|
|
83
|
+
if [ ! -f "$LIBCLANG_PATH/libclang.so" ]; then
|
|
84
|
+
# Fallback to targeted search if expected location doesn't exist
|
|
85
|
+
LIBCLANG_PATH=$(find /usr/lib/llvm* -name "libclang.so" 2>/dev/null | head -1 | xargs dirname)
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
echo "LIBCLANG_PATH=$LIBCLANG_PATH" >> $GITHUB_ENV
|
|
89
|
+
echo "LD_LIBRARY_PATH=$LIBCLANG_PATH:$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
90
|
+
# Verify the key files exist
|
|
91
|
+
echo "Using libclang.so at: $LIBCLANG_PATH/libclang.so"
|
|
92
|
+
echo "LLVM config at: $(which llvm-config-14 2>/dev/null || which llvm-config-18 2>/dev/null)"
|
|
93
|
+
|
|
94
|
+
- name: Build static OpenCV
|
|
95
|
+
run: |
|
|
96
|
+
./scripts/build-opencv-static.sh
|
|
97
|
+
|
|
98
|
+
- name: Build wheels for multiple Python versions
|
|
99
|
+
uses: PyO3/maturin-action@v1
|
|
100
|
+
with:
|
|
101
|
+
target: ${{ matrix.target }}
|
|
102
|
+
args: --release --out dist --no-default-features --features python-bindings,simd,opencv
|
|
103
|
+
sccache: 'false'
|
|
104
|
+
container: off
|
|
105
|
+
manylinux: ${{ matrix.manylinux }}
|
|
106
|
+
env:
|
|
107
|
+
# Use stable ABI for forward compatibility
|
|
108
|
+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
|
|
109
|
+
# LLVM for opencv-rust bindings (from earlier install step)
|
|
110
|
+
LIBCLANG_PATH: ${{ env.LIBCLANG_PATH }}
|
|
111
|
+
LLVM_CONFIG_PATH: ${{ env.LLVM_CONFIG_PATH }}
|
|
112
|
+
# OpenCV static linking configuration
|
|
113
|
+
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
|
|
114
|
+
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
|
|
115
|
+
OPENCV_LINK_LIBS: static=opencv_world,static=avformat,static=avcodec,static=avfilter,static=swresample,static=swscale,static=avutil,static=jpeg,static=png,static=tiff,static=webp,static=z,static=jasper,static=stdc++
|
|
116
|
+
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
|
|
117
|
+
|
|
118
|
+
- name: Repair wheels
|
|
119
|
+
env:
|
|
120
|
+
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
|
|
121
|
+
run: |
|
|
122
|
+
./scripts/repair-wheel.sh dist/*.whl
|
|
123
|
+
- name: Prune unrepaired wheels
|
|
124
|
+
run: |
|
|
125
|
+
find dist -type f -name '*.linux_*.whl' -print -delete
|
|
126
|
+
|
|
127
|
+
- name: Upload wheels
|
|
128
|
+
uses: actions/upload-artifact@v4
|
|
129
|
+
with:
|
|
130
|
+
name: wheels-${{ matrix.os }}-${{ matrix.target }}-py${{ matrix.python }}
|
|
131
|
+
path: dist
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
macos:
|
|
135
|
+
runs-on: macos-latest
|
|
136
|
+
strategy:
|
|
137
|
+
matrix:
|
|
138
|
+
target: [aarch64]
|
|
139
|
+
python: ['3.11', '3.12', '3.13']
|
|
140
|
+
steps:
|
|
141
|
+
- uses: actions/checkout@v4
|
|
142
|
+
- uses: actions/setup-python@v5
|
|
143
|
+
with:
|
|
144
|
+
python-version: ${{ matrix.python }}
|
|
145
|
+
|
|
146
|
+
- name: Cache static OpenCV
|
|
147
|
+
id: cache-opencv
|
|
148
|
+
uses: actions/cache@v4
|
|
149
|
+
with:
|
|
150
|
+
path: third_party/opencv-static
|
|
151
|
+
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-macos-${{ runner.os }}-${{ runner.arch }}
|
|
152
|
+
|
|
153
|
+
- name: Install build dependencies
|
|
154
|
+
run: |
|
|
155
|
+
# Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
|
|
156
|
+
brew install llvm cmake nasm pkg-config
|
|
157
|
+
# Set up LLVM environment for opencv-rust bindings (keg-only installation)
|
|
158
|
+
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
|
|
159
|
+
echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
|
|
160
|
+
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
161
|
+
|
|
162
|
+
- name: Build static OpenCV
|
|
163
|
+
run: |
|
|
164
|
+
./scripts/build-opencv-static.sh
|
|
165
|
+
|
|
166
|
+
- name: Build wheels
|
|
167
|
+
uses: PyO3/maturin-action@v1
|
|
168
|
+
with:
|
|
169
|
+
target: ${{ matrix.target }}
|
|
170
|
+
args: --release --out dist -i python --no-default-features --features python-bindings,simd,opencv,metal
|
|
171
|
+
sccache: 'false'
|
|
172
|
+
env:
|
|
173
|
+
# Use stable ABI for forward compatibility
|
|
174
|
+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
|
|
175
|
+
# OpenCV static linking configuration
|
|
176
|
+
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
|
|
177
|
+
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
|
|
178
|
+
OPENCV_LINK_LIBS: static=opencv_world,static=avformat,static=avcodec,static=avfilter,static=swresample,static=swscale,static=avutil,static=jpeg,static=png,static=tiff,static=webp,static=jasper,framework=Accelerate,dylib=c++,framework=OpenCL,z
|
|
179
|
+
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
|
|
180
|
+
- name: Repair wheels
|
|
181
|
+
env:
|
|
182
|
+
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
|
|
183
|
+
run: |
|
|
184
|
+
./scripts/repair-wheel.sh dist/*.whl
|
|
185
|
+
- name: Upload wheels
|
|
186
|
+
uses: actions/upload-artifact@v4
|
|
187
|
+
with:
|
|
188
|
+
name: wheels-macos-latest-${{ matrix.target }}-py${{ matrix.python }}
|
|
189
|
+
path: dist
|
|
190
|
+
|
|
191
|
+
sdist:
|
|
192
|
+
runs-on: ubuntu-latest
|
|
193
|
+
steps:
|
|
194
|
+
- uses: actions/checkout@v4
|
|
195
|
+
- name: Build sdist
|
|
196
|
+
uses: PyO3/maturin-action@v1
|
|
197
|
+
with:
|
|
198
|
+
command: sdist
|
|
199
|
+
args: --out dist
|
|
200
|
+
- name: Upload sdist
|
|
201
|
+
uses: actions/upload-artifact@v4
|
|
202
|
+
with:
|
|
203
|
+
name: wheels-sdist
|
|
204
|
+
path: dist
|
|
205
|
+
|
|
206
|
+
smoketest:
|
|
207
|
+
runs-on: ${{ matrix.os }}
|
|
208
|
+
needs: [linux, macos]
|
|
209
|
+
strategy:
|
|
210
|
+
matrix:
|
|
211
|
+
include:
|
|
212
|
+
# Ubuntu 22.04 (libc 2.35)
|
|
213
|
+
- os: ubuntu-22.04
|
|
214
|
+
target: x86_64
|
|
215
|
+
manylinux: manylinux_2_35
|
|
216
|
+
python: '3.11'
|
|
217
|
+
- os: ubuntu-22.04
|
|
218
|
+
target: x86_64
|
|
219
|
+
manylinux: manylinux_2_35
|
|
220
|
+
python: '3.12'
|
|
221
|
+
- os: ubuntu-22.04
|
|
222
|
+
target: x86_64
|
|
223
|
+
manylinux: manylinux_2_35
|
|
224
|
+
python: '3.13'
|
|
225
|
+
# Ubuntu 24.04 (libc 2.39)
|
|
226
|
+
- os: ubuntu-24.04
|
|
227
|
+
target: x86_64
|
|
228
|
+
manylinux: manylinux_2_39
|
|
229
|
+
python: '3.11'
|
|
230
|
+
- os: ubuntu-24.04
|
|
231
|
+
target: x86_64
|
|
232
|
+
manylinux: manylinux_2_39
|
|
233
|
+
python: '3.12'
|
|
234
|
+
- os: ubuntu-24.04
|
|
235
|
+
target: x86_64
|
|
236
|
+
manylinux: manylinux_2_39
|
|
237
|
+
python: '3.13'
|
|
238
|
+
- os: macos-latest
|
|
239
|
+
target: aarch64
|
|
240
|
+
manylinux: ''
|
|
241
|
+
python: '3.11'
|
|
242
|
+
- os: macos-latest
|
|
243
|
+
target: aarch64
|
|
244
|
+
manylinux: ''
|
|
245
|
+
python: '3.12'
|
|
246
|
+
- os: macos-latest
|
|
247
|
+
target: aarch64
|
|
248
|
+
manylinux: ''
|
|
249
|
+
python: '3.13'
|
|
250
|
+
steps:
|
|
251
|
+
- uses: actions/download-artifact@v4
|
|
252
|
+
with:
|
|
253
|
+
pattern: wheels-${{ matrix.os }}-${{ matrix.target }}-py${{ matrix.python }}
|
|
254
|
+
path: dist
|
|
255
|
+
- uses: actions/setup-python@v5
|
|
256
|
+
with:
|
|
257
|
+
python-version: ${{ matrix.python }}
|
|
258
|
+
- run: |
|
|
259
|
+
set -euo pipefail
|
|
260
|
+
wheel="$(find "${{ github.workspace }}/dist" -type f -name '*.whl' | sort | head -n 1)"
|
|
261
|
+
if [ -z "${wheel}" ]; then
|
|
262
|
+
echo "No wheel files found under dist/"
|
|
263
|
+
find "${{ github.workspace }}/dist" -maxdepth 3 -type f || true
|
|
264
|
+
exit 1
|
|
265
|
+
fi
|
|
266
|
+
echo "Installing wheel: ${wheel}"
|
|
267
|
+
pip install "${wheel}"
|
|
268
|
+
python -c 'import trainingsample' || echo "Import failed"
|
|
269
|
+
|
|
270
|
+
release:
|
|
271
|
+
name: Release
|
|
272
|
+
runs-on: ubuntu-latest
|
|
273
|
+
needs: [smoketest, sdist]
|
|
274
|
+
steps:
|
|
275
|
+
- uses: actions/download-artifact@v4
|
|
276
|
+
with:
|
|
277
|
+
pattern: wheels-*
|
|
278
|
+
merge-multiple: true
|
|
279
|
+
path: dist
|
|
280
|
+
- name: List built wheels
|
|
281
|
+
run: |
|
|
282
|
+
echo "Built wheels:"
|
|
283
|
+
ls -la dist/
|
|
284
|
+
- name: Prune unsupported linux-tag wheels
|
|
285
|
+
run: |
|
|
286
|
+
find dist -type f -name '*.linux_*.whl' -print -delete
|
|
287
|
+
- name: Publish to PyPI
|
|
288
|
+
uses: pypa/gh-action-pypi-publish@v1.12.4
|
|
289
|
+
with:
|
|
290
|
+
user: __token__
|
|
291
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|