trainingsample 0.2.1__tar.gz → 0.2.3__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.
Files changed (40) hide show
  1. trainingsample-0.2.3/.cargo/config.toml +7 -0
  2. {trainingsample-0.2.1 → trainingsample-0.2.3}/.github/workflows/ci.yml +154 -11
  3. {trainingsample-0.2.1 → trainingsample-0.2.3}/.github/workflows/publish.yml +48 -14
  4. {trainingsample-0.2.1 → trainingsample-0.2.3}/.gitignore +4 -0
  5. {trainingsample-0.2.1 → trainingsample-0.2.3}/Cargo.lock +82 -71
  6. {trainingsample-0.2.1 → trainingsample-0.2.3}/PKG-INFO +1 -1
  7. {trainingsample-0.2.1 → trainingsample-0.2.3}/docs/API_COMPAT_CV2.md +3 -24
  8. trainingsample-0.2.3/docs/BUILDING_STATIC_OPENCV.md +103 -0
  9. {trainingsample-0.2.1 → trainingsample-0.2.3}/pyproject.toml +1 -1
  10. trainingsample-0.2.3/rust-toolchain.toml +4 -0
  11. trainingsample-0.2.3/scripts/build-opencv-static.sh +89 -0
  12. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/lib.rs +0 -6
  13. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/opencv_ops.rs +2 -7
  14. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/python_bindings.rs +11 -61
  15. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/tests.rs +0 -11
  16. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/true_batch_ops.rs +2 -5
  17. {trainingsample-0.2.1 → trainingsample-0.2.3}/.envrc +0 -0
  18. {trainingsample-0.2.1 → trainingsample-0.2.3}/.pre-commit-config.yaml +0 -0
  19. {trainingsample-0.2.1 → trainingsample-0.2.3}/.rustfmt.toml +0 -0
  20. {trainingsample-0.2.1 → trainingsample-0.2.3}/BENCHMARKS.md +0 -0
  21. {trainingsample-0.2.1 → trainingsample-0.2.3}/Cargo.toml +0 -0
  22. {trainingsample-0.2.1 → trainingsample-0.2.3}/LICENSE +0 -0
  23. {trainingsample-0.2.1 → trainingsample-0.2.3}/README.md +0 -0
  24. {trainingsample-0.2.1 → trainingsample-0.2.3}/clippy.toml +0 -0
  25. {trainingsample-0.2.1 → trainingsample-0.2.3}/scripts/run_competitive_benchmarks.sh +0 -0
  26. {trainingsample-0.2.1 → trainingsample-0.2.3}/setup-env.sh +0 -0
  27. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/core.rs +0 -0
  28. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/cropping.rs +0 -0
  29. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/cv_batch_ops.rs +0 -0
  30. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/cv_batch_ops_optimized.rs +0 -0
  31. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/cv_compat.rs +0 -0
  32. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/format_conversion_simd.rs +0 -0
  33. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/loading.rs +0 -0
  34. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/luminance.rs +0 -0
  35. {trainingsample-0.2.1 → trainingsample-0.2.3}/src/luminance_simd.rs +0 -0
  36. {trainingsample-0.2.1 → trainingsample-0.2.3}/tests/__init__.py +0 -0
  37. {trainingsample-0.2.1 → trainingsample-0.2.3}/tests/comprehensive_tests.rs +0 -0
  38. {trainingsample-0.2.1 → trainingsample-0.2.3}/tests/test_comprehensive.py +0 -0
  39. {trainingsample-0.2.1 → trainingsample-0.2.3}/tests/test_performance_benchmarks.py +0 -0
  40. {trainingsample-0.2.1 → trainingsample-0.2.3}/tests/test_python_bindings.py +0 -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.
@@ -13,9 +13,6 @@ jobs:
13
13
  rust-tests:
14
14
  name: Rust Tests
15
15
  runs-on: ubuntu-latest
16
- strategy:
17
- matrix:
18
- rust: [stable, beta]
19
16
 
20
17
  steps:
21
18
  - uses: actions/checkout@v4
@@ -23,7 +20,7 @@ jobs:
23
20
  - name: Install OpenCV and LLVM dependencies
24
21
  run: |
25
22
  sudo apt-get update
26
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
23
+ sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
27
24
  # Install LLVM 18 which has the proper libclang.so symlink
28
25
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
29
26
  # Set environment variables for LLVM 18
@@ -34,10 +31,45 @@ jobs:
34
31
  ls -la /usr/lib/llvm-18/lib/libclang.so
35
32
  which llvm-config-18
36
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
+
37
69
  - name: Install Rust toolchain
38
70
  uses: dtolnay/rust-toolchain@master
39
71
  with:
40
- toolchain: ${{ matrix.rust }}
72
+ toolchain: 1.85
41
73
  components: rustfmt, clippy
42
74
 
43
75
  - name: Cache cargo registry
@@ -83,7 +115,7 @@ jobs:
83
115
  - name: Install OpenCV and LLVM dependencies
84
116
  run: |
85
117
  sudo apt-get update
86
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
118
+ sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
87
119
  # Install LLVM 18 which has the proper libclang.so symlink
88
120
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
89
121
  # Set environment variables for LLVM 18
@@ -94,13 +126,51 @@ jobs:
94
126
  ls -la /usr/lib/llvm-18/lib/libclang.so
95
127
  which llvm-config-18
96
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
+
97
164
  - name: Set up Python ${{ matrix.python-version }}
98
165
  uses: actions/setup-python@v4
99
166
  with:
100
167
  python-version: ${{ matrix.python-version }}
101
168
 
102
169
  - name: Install Rust toolchain
103
- uses: dtolnay/rust-toolchain@stable
170
+ uses: dtolnay/rust-toolchain@master
171
+ with:
172
+ toolchain: 1.85
173
+ components: rustfmt, clippy
104
174
 
105
175
  - name: Install maturin (Linux/macOS)
106
176
  run: pip install maturin[patchelf]
@@ -136,7 +206,7 @@ jobs:
136
206
  - name: Install OpenCV and LLVM dependencies
137
207
  run: |
138
208
  sudo apt-get update
139
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
209
+ sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
140
210
  # Install LLVM 18 which has the proper libclang.so symlink
141
211
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
142
212
  # Set environment variables for LLVM 18
@@ -147,14 +217,50 @@ jobs:
147
217
  ls -la /usr/lib/llvm-18/lib/libclang.so
148
218
  which llvm-config-18
149
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
+
150
255
  - name: Set up Python
151
256
  uses: actions/setup-python@v4
152
257
  with:
153
258
  python-version: 3.11
154
259
 
155
260
  - name: Install Rust toolchain
156
- uses: dtolnay/rust-toolchain@stable
261
+ uses: dtolnay/rust-toolchain@master
157
262
  with:
263
+ toolchain: 1.85
158
264
  components: rustfmt, clippy
159
265
 
160
266
  - name: Install cargo-audit
@@ -180,7 +286,7 @@ jobs:
180
286
  if: runner.os == 'Linux'
181
287
  run: |
182
288
  sudo apt-get update
183
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
289
+ sudo apt-get install -y pkg-config clang libclang-dev llvm-dev wget cmake build-essential
184
290
  # Install LLVM 18 which has the proper libclang.so symlink
185
291
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
186
292
  # Set environment variables for LLVM 18
@@ -191,6 +297,41 @@ jobs:
191
297
  ls -la /usr/lib/llvm-18/lib/libclang.so
192
298
  which llvm-config-18
193
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
+
194
335
 
195
336
 
196
337
  - name: Set up Python
@@ -199,7 +340,9 @@ jobs:
199
340
  python-version: 3.11
200
341
 
201
342
  - name: Install Rust toolchain
202
- uses: dtolnay/rust-toolchain@stable
343
+ uses: dtolnay/rust-toolchain@master
344
+ with:
345
+ toolchain: 1.85
203
346
 
204
347
  - name: Install maturin (Linux/macOS)
205
348
  run: pip install maturin[patchelf]
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  tags:
6
6
  - 'v*'
7
+ workflow_dispatch:
7
8
 
8
9
  jobs:
9
10
  linux:
@@ -17,11 +18,18 @@ jobs:
17
18
  with:
18
19
  python-version: '3.11'
19
20
 
20
- - name: Install OpenCV and LLVM dependencies
21
+ - name: Cache static OpenCV
22
+ id: cache-opencv
23
+ uses: actions/cache@v4
24
+ with:
25
+ path: third_party/opencv-static
26
+ key: opencv-static-4.12.0-no-itt-linux-${{ runner.os }}-${{ runner.arch }}
27
+
28
+ - name: Install build dependencies
21
29
  run: |
22
30
  sudo apt-get update
23
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
24
- # Install LLVM 18 which has the proper libclang.so symlink
31
+ # Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
32
+ sudo apt-get install -y clang libclang-dev llvm-dev cmake curl
25
33
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
26
34
  # Set environment variables for LLVM 18
27
35
  echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
@@ -31,16 +39,29 @@ jobs:
31
39
  ls -la /usr/lib/llvm-18/lib/libclang.so
32
40
  which llvm-config-18
33
41
 
42
+ - name: Build static OpenCV
43
+ if: steps.cache-opencv.outputs.cache-hit != 'true'
44
+ run: |
45
+ ./scripts/build-opencv-static.sh
46
+
34
47
  - name: Build wheels
35
48
  uses: PyO3/maturin-action@v1
36
49
  with:
37
50
  target: ${{ matrix.target }}
38
- args: --release --out dist --find-interpreter --zig --no-default-features --features python-bindings,simd,opencv
39
- sccache: 'true'
40
- manylinux: auto
51
+ args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv
52
+ sccache: 'false'
53
+ container: off
41
54
  env:
42
55
  # Use stable ABI for forward compatibility
43
56
  PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
57
+ # LLVM for opencv-rust bindings (from earlier install step)
58
+ LIBCLANG_PATH: /usr/lib/llvm-18/lib
59
+ LLVM_CONFIG_PATH: /usr/bin/llvm-config-18
60
+ # OpenCV static linking configuration
61
+ OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
62
+ OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
63
+ OPENCV_LINK_LIBS: static=opencv_world,static=stdc++
64
+ OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
44
65
 
45
66
  - name: Upload wheels
46
67
  uses: actions/upload-artifact@v4
@@ -60,28 +81,41 @@ jobs:
60
81
  with:
61
82
  python-version: '3.11'
62
83
 
63
- - name: Install OpenCV (macOS)
84
+ - name: Cache static OpenCV
85
+ id: cache-opencv
86
+ uses: actions/cache@v4
87
+ with:
88
+ path: third_party/opencv-static
89
+ key: opencv-static-4.12.0-no-itt-macos-${{ runner.os }}-${{ runner.arch }}
90
+
91
+ - name: Install build dependencies
64
92
  run: |
65
- # Install OpenCV and LLVM via Homebrew
66
- brew install opencv llvm
93
+ # Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
94
+ brew install llvm cmake
67
95
  # Set up LLVM environment for opencv-rust bindings (keg-only installation)
68
96
  echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
69
97
  echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
70
98
  echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
71
- # Set up OpenCV environment
72
- 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
73
- echo "OPENCV_LINK_PATHS=/opt/homebrew/lib" >> $GITHUB_ENV
74
- echo "OPENCV_INCLUDE_PATHS=/opt/homebrew/include/opencv4" >> $GITHUB_ENV
99
+
100
+ - name: Build static OpenCV
101
+ if: steps.cache-opencv.outputs.cache-hit != 'true'
102
+ run: |
103
+ ./scripts/build-opencv-static.sh
75
104
 
76
105
  - name: Build wheels
77
106
  uses: PyO3/maturin-action@v1
78
107
  with:
79
108
  target: ${{ matrix.target }}
80
109
  args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv,metal
81
- sccache: 'true'
110
+ sccache: 'false'
82
111
  env:
83
112
  # Use stable ABI for forward compatibility
84
113
  PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
114
+ # OpenCV static linking configuration
115
+ OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
116
+ OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
117
+ OPENCV_LINK_LIBS: static=opencv_world,framework=Accelerate,dylib=c++
118
+ OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
85
119
  - name: Upload wheels
86
120
  uses: actions/upload-artifact@v4
87
121
  with:
@@ -49,6 +49,10 @@ Thumbs.db
49
49
  target/
50
50
  Cargo.lock
51
51
 
52
+ # Static OpenCV bundle (built in CI, not committed)
53
+ third_party/
54
+ opencv-build-tmp/
55
+
52
56
  files.tbz
53
57
  */config/auth.json
54
58
  work