libstb 0.4.0__tar.gz → 0.6.0__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 (206) hide show
  1. libstb-0.6.0/.github/workflows/cmake.yml +138 -0
  2. {libstb-0.4.0 → libstb-0.6.0}/.github/workflows/orchestrator.yml +38 -0
  3. libstb-0.6.0/.github/workflows/wheels.yml +137 -0
  4. libstb-0.6.0/CHANGELOG.md +140 -0
  5. {libstb-0.4.0 → libstb-0.6.0}/CMakeLists.txt +40 -14
  6. libstb-0.6.0/PKG-INFO +391 -0
  7. libstb-0.6.0/README.md +360 -0
  8. libstb-0.6.0/benchmarks/.gitignore +1 -0
  9. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/CMakeLists.txt +12 -5
  10. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/README.md +16 -9
  11. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/cmake/FetchRealCorpus.cmake +4 -6
  12. libstb-0.6.0/benchmarks/outputs/benchmark.json +1 -0
  13. libstb-0.6.0/benchmarks/outputs/index.html +7726 -0
  14. libstb-0.6.0/benchmarks/outputs/results/fonts.json +259 -0
  15. libstb-0.6.0/benchmarks/outputs/results/scaling.json +639 -0
  16. libstb-0.6.0/benchmarks/outputs/results/sizes.json +120 -0
  17. libstb-0.6.0/benchmarks/outputs/results/system_info.json +10 -0
  18. libstb-0.6.0/benchmarks/outputs/results/throughput.json +17180 -0
  19. libstb-0.6.0/benchmarks/outputs/results/throughput_memory.json +13273 -0
  20. libstb-0.6.0/benchmarks/outputs/results/verify.json +6 -0
  21. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/CMakeLists.txt +4 -2
  22. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_fonts.py +5 -5
  23. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_sizes.py +1 -1
  24. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/runners.py +91 -15
  25. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/verify.py +28 -2
  26. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/report/CMakeLists.txt +17 -18
  27. libstb-0.6.0/benchmarks/report/gather.py +436 -0
  28. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/report/generate_report.py +57 -3
  29. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/report/template.html.jinja2 +22 -22
  30. libstb-0.6.0/cmake/FixLCovPaths.cmake +9 -0
  31. libstb-0.6.0/cmake/GenerateIframe.cmake +23 -0
  32. libstb-0.6.0/cmake/coverage_iframe.html.in +152 -0
  33. libstb-0.6.0/docs/CMakeLists.txt +194 -0
  34. libstb-0.6.0/docs/CreateDocs.cmake +53 -0
  35. libstb-0.6.0/docs/InjectComment.cmake +85 -0
  36. libstb-0.6.0/docs/assets/bench-teaser.js +66 -0
  37. libstb-0.6.0/docs/assets/libstb-docs.css +295 -0
  38. libstb-0.6.0/docs/cpp/CreateDocs.cmake +87 -0
  39. libstb-0.6.0/docs/cpp/Doxyfile.in +61 -0
  40. libstb-0.6.0/docs/cpp/footer.html.in +21 -0
  41. libstb-0.6.0/docs/cpp/index-docs.json +8 -0
  42. libstb-0.6.0/docs/cpp/index-example.txt +15 -0
  43. libstb-0.6.0/docs/cpp/index-install.txt +11 -0
  44. libstb-0.6.0/docs/cpp/libstb-doxygen.css +74 -0
  45. libstb-0.6.0/docs/cpp/mainpage.md +51 -0
  46. libstb-0.6.0/docs/cpp/topbar.html.in +19 -0
  47. libstb-0.6.0/docs/generate_index.py +192 -0
  48. libstb-0.6.0/docs/images/libstb-logo.png +0 -0
  49. libstb-0.6.0/docs/images/libstb-sq.png +0 -0
  50. libstb-0.6.0/docs/images/libstb-sq.svg +1 -0
  51. libstb-0.6.0/docs/images/libstb-sq.txt +4 -0
  52. libstb-0.6.0/docs/images/libstb-theme.svg +1 -0
  53. libstb-0.6.0/docs/index.html.in +247 -0
  54. libstb-0.6.0/docs/initial_comment.in +15 -0
  55. libstb-0.6.0/docs/make_showcase.py +60 -0
  56. libstb-0.6.0/docs/python/CreateDocs.cmake +59 -0
  57. libstb-0.6.0/docs/python/index-docs.json +8 -0
  58. libstb-0.6.0/docs/python/index-example.txt +11 -0
  59. libstb-0.6.0/docs/python/index-install.txt +2 -0
  60. libstb-0.6.0/docs/python/source/_themes/libstb/layout.html +154 -0
  61. libstb-0.6.0/docs/python/source/_themes/libstb/libstb-nav.html +14 -0
  62. libstb-0.6.0/docs/python/source/_themes/libstb/page.html +2 -0
  63. libstb-0.6.0/docs/python/source/_themes/libstb/static/libstb-docs.css +418 -0
  64. libstb-0.6.0/docs/python/source/_themes/libstb/static/libstb-sphinx.css +102 -0
  65. libstb-0.6.0/docs/python/source/_themes/libstb/theme.toml +9 -0
  66. libstb-0.6.0/docs/python/source/conf.py +98 -0
  67. libstb-0.6.0/docs/python/source/errors.rst +10 -0
  68. libstb-0.6.0/docs/python/source/font.rst +30 -0
  69. libstb-0.6.0/docs/python/source/image.rst +34 -0
  70. libstb-0.6.0/docs/python/source/index.rst +35 -0
  71. libstb-0.6.0/docs/python/source/resizer.rst +14 -0
  72. libstb-0.6.0/docs/python/source/simd.rst +19 -0
  73. libstb-0.6.0/docs/supported_langs.json +31 -0
  74. libstb-0.6.0/examples/cpp/.gitignore +8 -0
  75. libstb-0.6.0/examples/notebooks/.gitignore +5 -0
  76. libstb-0.6.0/examples/notebooks/01_getting_started.ipynb +210 -0
  77. libstb-0.6.0/examples/notebooks/02_resize_filters.ipynb +144 -0
  78. libstb-0.6.0/examples/notebooks/03_font_rendering.ipynb +127 -0
  79. libstb-0.6.0/examples/notebooks/04_edit_and_orient.ipynb +187 -0
  80. libstb-0.6.0/examples/notebooks/requirements.txt +4 -0
  81. libstb-0.6.0/examples/python/.gitignore +4 -0
  82. libstb-0.6.0/examples/python/01_open_and_inspect.py +51 -0
  83. libstb-0.6.0/examples/python/02_encode_formats.py +47 -0
  84. libstb-0.6.0/examples/python/03_resize_filters.py +48 -0
  85. libstb-0.6.0/examples/python/04_numpy_interop.py +49 -0
  86. libstb-0.6.0/examples/python/05_font_render.py +55 -0
  87. libstb-0.6.0/examples/python/06_imread_imwrite.py +37 -0
  88. libstb-0.6.0/examples/python/07_dlpack.py +76 -0
  89. libstb-0.6.0/examples/python/08_geometry.py +61 -0
  90. libstb-0.6.0/examples/python/09_channels_and_alpha.py +52 -0
  91. libstb-0.6.0/examples/python/10_exif_orientation.py +81 -0
  92. libstb-0.6.0/examples/python/11_pillow.py +46 -0
  93. libstb-0.6.0/examples/python/requirements.txt +4 -0
  94. libstb-0.6.0/include/stb/env.hpp +31 -0
  95. {libstb-0.4.0 → libstb-0.6.0}/include/stb/image.hpp +106 -0
  96. {libstb-0.4.0 → libstb-0.6.0}/include/stb.h +2 -1
  97. {libstb-0.4.0 → libstb-0.6.0}/pyproject.toml +12 -8
  98. libstb-0.6.0/requirements-dev.txt +21 -0
  99. libstb-0.6.0/src/bindings/python/bind_image.cpp +661 -0
  100. libstb-0.6.0/src/bindings/python/libstb/__init__.py +142 -0
  101. libstb-0.6.0/src/bindings/python/libstb/image.py +98 -0
  102. libstb-0.6.0/src/core/exif.cpp +127 -0
  103. {libstb-0.4.0 → libstb-0.6.0}/src/core/image.cpp +10 -2
  104. libstb-0.6.0/src/core/image_kernels.hpp +153 -0
  105. libstb-0.6.0/src/core/image_kernels_scalar.cpp +37 -0
  106. libstb-0.6.0/src/core/image_kernels_sse2.cpp +107 -0
  107. libstb-0.6.0/src/core/image_ops.cpp +372 -0
  108. libstb-0.6.0/src/core/simd.cpp +142 -0
  109. libstb-0.6.0/src/core/simd.hpp +24 -0
  110. libstb-0.6.0/tests/CMakeLists.txt +139 -0
  111. libstb-0.6.0/tests/coverage_dashboard.html.in +600 -0
  112. libstb-0.6.0/tests/cpp/CMakeLists.txt +112 -0
  113. libstb-0.6.0/tests/cpp/test_edit.cpp +628 -0
  114. libstb-0.6.0/tests/cpp/test_env.cpp +50 -0
  115. libstb-0.6.0/tests/cpp/test_exif.cpp +192 -0
  116. libstb-0.6.0/tests/genhtml.css +241 -0
  117. libstb-0.6.0/tests/python/CMakeLists.txt +88 -0
  118. libstb-0.6.0/tests/python/conftest.py +24 -0
  119. libstb-0.6.0/tests/python/test_array_interface.py +163 -0
  120. libstb-0.6.0/tests/python/test_channels.py +193 -0
  121. libstb-0.6.0/tests/python/test_dlpack.py +176 -0
  122. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_encode.py +13 -13
  123. libstb-0.6.0/tests/python/test_errors.py +25 -0
  124. libstb-0.6.0/tests/python/test_exif.py +112 -0
  125. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_font.py +14 -14
  126. libstb-0.6.0/tests/python/test_functional.py +138 -0
  127. libstb-0.6.0/tests/python/test_gc.py +106 -0
  128. libstb-0.6.0/tests/python/test_geometry.py +192 -0
  129. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_image.py +32 -32
  130. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_lossless_exact.py +14 -13
  131. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_lossy_tolerance.py +8 -7
  132. libstb-0.6.0/tests/python/test_memory.py +194 -0
  133. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_no_numpy.py +31 -17
  134. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_oop.py +36 -36
  135. libstb-0.6.0/tests/python/test_pillow_convert.py +168 -0
  136. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_pillow_parity.py +31 -30
  137. {libstb-0.4.0 → libstb-0.6.0}/tests/python/test_resizer.py +21 -21
  138. libstb-0.6.0/tests/python/test_simd.py +200 -0
  139. libstb-0.6.0/tests/python/test_torch.py +180 -0
  140. libstb-0.4.0/.github/workflows/cmake.yml +0 -39
  141. libstb-0.4.0/.github/workflows/wheels.yml +0 -70
  142. libstb-0.4.0/PKG-INFO +0 -225
  143. libstb-0.4.0/README.md +0 -197
  144. libstb-0.4.0/requirements-dev.txt +0 -14
  145. libstb-0.4.0/src/bindings/python/bind_image.cpp +0 -310
  146. libstb-0.4.0/src/bindings/python/libstb/__init__.py +0 -62
  147. libstb-0.4.0/src/bindings/python/libstb/image.py +0 -42
  148. libstb-0.4.0/tests/CMakeLists.txt +0 -13
  149. libstb-0.4.0/tests/cpp/CMakeLists.txt +0 -24
  150. libstb-0.4.0/tests/python/CMakeLists.txt +0 -26
  151. libstb-0.4.0/tests/python/test_errors.py +0 -25
  152. {libstb-0.4.0 → libstb-0.6.0}/.github/workflows/release_template.md +0 -0
  153. {libstb-0.4.0 → libstb-0.6.0}/.gitignore +0 -0
  154. {libstb-0.4.0 → libstb-0.6.0}/LICENSE.txt +0 -0
  155. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/cmake/Download.cmake +0 -0
  156. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/corpus/.gitignore +0 -0
  157. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_op_memory_driver.py +0 -0
  158. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_op_memory_one.py +0 -0
  159. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_scaling.py +0 -0
  160. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/bench_throughput.py +0 -0
  161. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/corpus.py +0 -0
  162. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/real_corpus_manifest.py +0 -0
  163. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/requirements.txt +0 -0
  164. {libstb-0.4.0 → libstb-0.6.0}/benchmarks/python/system_info.py +0 -0
  165. {libstb-0.4.0 → libstb-0.6.0}/cmake/DynamicVersion.cmake +0 -0
  166. {libstb-0.4.0 → libstb-0.6.0}/cmake/Optimize.cmake +0 -0
  167. {libstb-0.4.0 → libstb-0.6.0}/cmake/Startup.cmake +0 -0
  168. {libstb-0.4.0 → libstb-0.6.0}/cmake/libstbConfig.cmake.in +0 -0
  169. {libstb-0.4.0 → libstb-0.6.0}/include/stb/error.hpp +0 -0
  170. {libstb-0.4.0 → libstb-0.6.0}/include/stb/font.hpp +0 -0
  171. {libstb-0.4.0 → libstb-0.6.0}/include/stb/resizer.hpp +0 -0
  172. {libstb-0.4.0 → libstb-0.6.0}/include/stb/utf8.hpp +0 -0
  173. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/CMakeLists.txt +0 -0
  174. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/bind_font.cpp +0 -0
  175. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/bind_resizer.cpp +0 -0
  176. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/binding.cpp +0 -0
  177. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/binding.hpp +0 -0
  178. {libstb-0.4.0 → libstb-0.6.0}/src/bindings/python/libstb/font.py +0 -0
  179. {libstb-0.4.0 → libstb-0.6.0}/src/core/file.hpp +0 -0
  180. {libstb-0.4.0 → libstb-0.6.0}/src/core/font.cpp +0 -0
  181. {libstb-0.4.0 → libstb-0.6.0}/src/core/resizer.cpp +0 -0
  182. {libstb-0.4.0 → libstb-0.6.0}/src/core/utf8.cpp +0 -0
  183. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/README.md +0 -0
  184. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/stb/stb_image.h +0 -0
  185. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/stb/stb_image_resize2.h +0 -0
  186. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/stb/stb_image_write.h +0 -0
  187. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/stb/stb_rect_pack.h +0 -0
  188. {libstb-0.4.0 → libstb-0.6.0}/src/third_party/stb/stb_truetype.h +0 -0
  189. {libstb-0.4.0 → libstb-0.6.0}/tests/cmake/CMakeLists.txt +0 -0
  190. {libstb-0.4.0 → libstb-0.6.0}/tests/cmake/consumer_project/CMakeLists.txt +0 -0
  191. {libstb-0.4.0 → libstb-0.6.0}/tests/cmake/consumer_project/main.cpp +0 -0
  192. {libstb-0.4.0 → libstb-0.6.0}/tests/cmake/run_consumer_test.cmake +0 -0
  193. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_common.hpp +0 -0
  194. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_encode.cpp +0 -0
  195. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_font.cpp +0 -0
  196. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_image.cpp +0 -0
  197. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_resizer.cpp +0 -0
  198. {libstb-0.4.0 → libstb-0.6.0}/tests/cpp/test_utf8.cpp +0 -0
  199. {libstb-0.4.0 → libstb-0.6.0}/tests/data/libstb-test.ttf +0 -0
  200. {libstb-0.4.0 → libstb-0.6.0}/tests/data/make_test_font.py +0 -0
  201. {libstb-0.4.0 → libstb-0.6.0}/tests/python/tolerances.py +0 -0
  202. {libstb-0.4.0 → libstb-0.6.0}/tests/tools/jpeg_vs_upstream.py +0 -0
  203. {libstb-0.4.0 → libstb-0.6.0}/tests/tools/zlib_fuzz.py +0 -0
  204. {libstb-0.4.0 → libstb-0.6.0}/tests/utest/utest.h +0 -0
  205. {libstb-0.4.0 → libstb-0.6.0}/tests/utest/utest_main.cxx +0 -0
  206. {libstb-0.4.0 → libstb-0.6.0}/version.py +0 -0
@@ -0,0 +1,138 @@
1
+ name: cmake stuff
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build-and-test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest, windows-latest]
14
+
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v6
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v6
23
+ with:
24
+ python-version: "3.11"
25
+ cache: "pip"
26
+
27
+ - name: Install python deps
28
+ run: pip install -r requirements-dev.txt
29
+
30
+ - name: Configure Project
31
+ run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLIBSTB_BUILD_TESTS=ON -DLIBSTB_BUILD_PYTHON=ON
32
+
33
+ - name: Build
34
+ run: cmake --build build -j4 --config Release
35
+
36
+ # C++ tests, Python tests (pytest against the freshly built package) and
37
+ # the find_package consumer test all run under ctest.
38
+ - name: Run tests
39
+ run: ctest --test-dir build -C Release --output-on-failure
40
+
41
+
42
+ build-docs:
43
+ needs: build-and-test
44
+ runs-on: ubuntu-latest
45
+
46
+ steps:
47
+ - name: Checkout repository
48
+ uses: actions/checkout@v6
49
+
50
+ - name: Install apt dependencies
51
+ run: |
52
+ sudo apt-get update
53
+ sudo apt-get install -y doxygen graphviz
54
+
55
+ - name: Set up Python
56
+ uses: actions/setup-python@v6
57
+ with:
58
+ python-version: "3.11"
59
+ cache: "pip"
60
+
61
+ - name: Install python deps
62
+ run: pip install -r requirements-dev.txt
63
+
64
+ # The Sphinx build imports the freshly built extension, so the Python binding is needed.
65
+ - name: Configure CMake
66
+ run: |
67
+ cmake -S . -B build \
68
+ -DCMAKE_BUILD_TYPE=Release \
69
+ -DLIBSTB_BUILD_TESTS=OFF \
70
+ -DLIBSTB_BUILD_PYTHON=ON \
71
+ -DLIBSTB_BUILD_DOCS=ON
72
+
73
+ - name: Build documentation
74
+ run: cmake --build build --target libstb_docs
75
+
76
+ - name: List docs directory
77
+ run: tree --du -shaC build/docs/out
78
+
79
+ - name: Upload documentation artifacts
80
+ uses: actions/upload-artifact@v7
81
+ with:
82
+ name: cmake-documentation
83
+ path: build/docs/out
84
+ retention-days: 5
85
+
86
+ build-coverage:
87
+ runs-on: ubuntu-latest
88
+
89
+ steps:
90
+ - name: Checkout repository
91
+ uses: actions/checkout@v6
92
+
93
+ - name: Set up Python
94
+ uses: actions/setup-python@v6
95
+ with:
96
+ python-version: "3.11"
97
+ cache: "pip"
98
+
99
+ - name: Install python dependencies
100
+ run: pip install -r requirements-dev.txt
101
+
102
+ # torch is not a test dependency: tests/python/test_torch.py skips itself without it. The CPU
103
+ # wheel (a few hundred MB, instead of several GB of CUDA libraries) makes the DLPack tests run
104
+ # here, so they count towards the coverage report.
105
+ - name: Install torch (CPU)
106
+ run: pip install torch --index-url https://download.pytorch.org/whl/cpu
107
+
108
+ - name: Install coverage tools
109
+ run: |
110
+ sudo apt-get update
111
+ sudo apt-get install -y lcov
112
+
113
+ - name: Configure CMake
114
+ run: |
115
+ cmake -S . -B build \
116
+ -DLIBSTB_BUILD_TESTS=ON \
117
+ -DLIBSTB_BUILD_PYTHON=ON \
118
+ -DLIBSTB_BUILD_DOCS=OFF
119
+
120
+ # C++ (lcov), Python (coverage.py) and the merged total.
121
+ - name: Generate coverage report
122
+ run: cmake --build build --target libstb_coverage
123
+
124
+ - name: Upload coverage to Codecov
125
+ uses: codecov/codecov-action@v5
126
+ with:
127
+ files: build/coverage/total/coverage.lcov
128
+ flags: unittests
129
+ name: codecov-umbrella
130
+ fail_ci_if_error: false
131
+ verbose: true
132
+
133
+ - name: Upload coverage artifacts
134
+ uses: actions/upload-artifact@v7
135
+ with:
136
+ name: cmake-coverage-report
137
+ path: build/coverage/
138
+ retention-days: 5
@@ -87,3 +87,41 @@ jobs:
87
87
  with:
88
88
  password: ${{ secrets.PYPI_PASSWORD }}
89
89
  user: ${{ secrets.PYPI_USERNAME }}
90
+
91
+ # Publishes the docs site with the coverage dashboard under /coverage. Needs GitHub Pages
92
+ # enabled in the repository settings (Source: GitHub Actions).
93
+ deploy-pages:
94
+ needs: [cmake]
95
+ runs-on: ubuntu-latest
96
+ permissions:
97
+ contents: write
98
+ pages: write
99
+ id-token: write
100
+
101
+ steps:
102
+ - name: Download documentation artifact
103
+ uses: actions/download-artifact@v8
104
+ with:
105
+ name: cmake-documentation
106
+ path: ./pages
107
+
108
+ - name: Download coverage artifact
109
+ uses: actions/download-artifact@v8
110
+ with:
111
+ name: cmake-coverage-report
112
+ path: ./pages/coverage
113
+
114
+ - name: List pages directory
115
+ run: tree --du -shaC pages
116
+
117
+ - name: Setup Pages
118
+ uses: actions/configure-pages@v4
119
+
120
+ - name: Upload artifact
121
+ uses: actions/upload-pages-artifact@v3
122
+ with:
123
+ path: ./pages
124
+
125
+ - name: Deploy to GitHub Pages
126
+ id: deployment
127
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,137 @@
1
+ name: python build wheels
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ env:
10
+ FORCE_COLOR: 3
11
+
12
+ concurrency:
13
+ group: wheels-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ build_sdist:
18
+ name: Build SDist
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+
23
+ - uses: actions/setup-python@v6
24
+ with:
25
+ python-version: "3.11"
26
+ cache: "pip"
27
+
28
+ - name: Build SDist
29
+ run: pipx run build --sdist
30
+
31
+ - name: Check metadata
32
+ run: pipx run twine check dist/*
33
+
34
+ - uses: actions/upload-artifact@v7
35
+ with:
36
+ name: wheelhouse-sdist
37
+ path: dist/*.tar.gz
38
+ overwrite: true
39
+
40
+ build_wheels:
41
+ name: Wheels on ${{ matrix.os }}
42
+ runs-on: ${{ matrix.os }}
43
+ strategy:
44
+ # One platform failing must not hide how the others do: each of them is its own wheel set.
45
+ fail-fast: false
46
+ matrix:
47
+ # ubuntu-latest / windows-latest are x86-64; the *-arm runners are native arm64 (no
48
+ # emulation, so the wheels are built and tested on the real architecture). macos-latest
49
+ # is arm64 and builds the universal2 wheel (x86-64 + arm64) for both.
50
+ os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest, windows-11-arm]
51
+
52
+ steps:
53
+ - uses: actions/checkout@v6
54
+
55
+ - name: Build wheels
56
+ uses: pypa/cibuildwheel@v3.4.1
57
+ env:
58
+ # C++17 runtime on macOS.
59
+ MACOSX_DEPLOYMENT_TARGET: "10.15"
60
+ CIBW_ARCHS_MACOS: universal2
61
+ # 3.9-3.11: normal per-version wheels (nanobind has no stable-ABI
62
+ # support below 3.12; it silently builds a regular extension there).
63
+ # 3.12: built once and tagged cp312-abi3 (see [[tool.scikit-build.overrides]] in
64
+ # pyproject.toml), and that single wheel covers every newer interpreter too, so 3.13+
65
+ # is skipped here to avoid building a redundant duplicate wheel.
66
+ CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*"
67
+ CIBW_SKIP: pp*
68
+
69
+ - uses: actions/upload-artifact@v7
70
+ with:
71
+ name: wheelhouse-${{ matrix.os }}
72
+ path: wheelhouse/*.whl
73
+ overwrite: false
74
+
75
+ # The Linux wheel carries AVX2 kernels next to the portable ones and picks one at run
76
+ # time from the CPU it finds (backends: avx2, sse2, scalar; see libstb.simd_backends()). The
77
+ # runners that build and test the wheels all have AVX2,
78
+ # so this job runs the very same wheel on emulated CPUs (QEMU user mode): one without AVX
79
+ # (Nehalem: SSE4.2 only), where it must fall back to the portable kernels and pass every
80
+ # test, and one with AVX2 (Haswell), where it must pick the AVX2 ones.
81
+ emulate:
82
+ name: emulate
83
+ needs: build_wheels
84
+ runs-on: ubuntu-latest
85
+ timeout-minutes: 20
86
+ env:
87
+ # pytest-memray (installed by the [test] extra) does not run under QEMU user mode.
88
+ LIBSTB_NO_MEMRAY: "1"
89
+ steps:
90
+ - uses: actions/checkout@v6
91
+
92
+ - uses: actions/setup-python@v6
93
+ with:
94
+ python-version: "3.12"
95
+
96
+ - uses: actions/download-artifact@v8
97
+ with:
98
+ name: wheelhouse-ubuntu-latest
99
+ path: wheelhouse
100
+
101
+ - name: Install QEMU user-mode emulation
102
+ run: |
103
+ sudo apt-get update -qq
104
+ sudo apt-get install -y -qq qemu-user
105
+
106
+ - name: Install the manylinux wheel (3.12, abi3) with its test dependencies
107
+ run: |
108
+ echo "wheelhouse contains:"; find wheelhouse -type f | sort
109
+ mapfile -t wheels < <(find wheelhouse -type f -name 'libstb-*-cp312-abi3-manylinux*x86_64*.whl')
110
+ [ ${#wheels[@]} -eq 1 ] || { echo "expected exactly one manylinux cp312-abi3 x86_64 wheel, found ${#wheels[@]}: ${wheels[*]}"; exit 1; }
111
+ python -m venv venv
112
+ venv/bin/pip install "${wheels[0]}[test]"
113
+
114
+ - name: No AVX (Nehalem) - only the portable backends may be offered
115
+ run: |
116
+ qemu-x86_64 -cpu Nehalem venv/bin/python - <<'PY'
117
+ import libstb
118
+ print("simd_backends:", libstb.simd_backends(), "| in use:", libstb.simd_name())
119
+ assert libstb.simd_backends() == ["sse2", "scalar"], libstb.simd_backends()
120
+ assert libstb.simd_name() == "sse2", libstb.simd_name()
121
+ PY
122
+
123
+ - name: No AVX (Nehalem) - the whole test suite (covers the sse2 and scalar backends)
124
+ working-directory: ${{ runner.temp }}
125
+ run: qemu-x86_64 -cpu Nehalem ${{ github.workspace }}/venv/bin/python -m pytest ${{ github.workspace }}/tests/python -q -p no:cacheprovider
126
+
127
+ - name: AVX2 (Haswell) - avx2 must be offered and picked, and equal the other backends
128
+ working-directory: ${{ runner.temp }}
129
+ run: |
130
+ qemu-x86_64 -cpu Haswell ${{ github.workspace }}/venv/bin/python - <<'PY' 2>&1 | grep -v "TCG doesn't support"
131
+ import libstb
132
+ print("simd_backends:", libstb.simd_backends(), "| in use:", libstb.simd_name())
133
+ assert libstb.simd_backends() == ["avx2", "sse2", "scalar"], libstb.simd_backends()
134
+ assert libstb.simd_name() == "avx2", libstb.simd_name()
135
+ PY
136
+ qemu-x86_64 -cpu Haswell ${{ github.workspace }}/venv/bin/python -m pytest ${{ github.workspace }}/tests/python/test_simd.py -q -p no:cacheprovider 2>&1 | grep -v "TCG doesn't support"
137
+ exit "${PIPESTATUS[0]}"
@@ -0,0 +1,140 @@
1
+ # Changelog
2
+
3
+ All notable changes to libstb are listed here, newest first. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Dates are commit dates.
5
+
6
+ This file was generated from the git history (42 commits, tags `v0.3.0`, `v0.4.0`, `v0.5.0`).
7
+
8
+ ## [Unreleased] (after 0.5.0)
9
+
10
+ ### Breaking
11
+ - `Image.rotate90(turns=1)` (C++: `stb::image::rotate90`) now turns **counter-clockwise**, like
12
+ `numpy.rot90` and Pillow. A negative `turns` turns clockwise. Before, positive meant clockwise.
13
+ `orient()` (EXIF) is unchanged.
14
+
15
+ ### Added
16
+ - Image editing API on `Image` and `stb::image`: `crop`, `flip_horizontal`, `flip_vertical`,
17
+ `rotate90`, `transpose`, `orient`, `pad`, `thumbnail`, `convert`, `split`, `Image.merge`,
18
+ `composite`, `flatten`. Every operation returns a new image.
19
+ - EXIF orientation support (`exif_orientation`, `orient`).
20
+ - Channel and alpha handling (gray, RGB, RGBA conversion and compositing).
21
+ - `libstb.imresize(array, width, height, resizer=None)`: ndarray in, ndarray out.
22
+ - Runtime SIMD backend selection: `simd_backends()`, `simd_name()`, `set_simd()`, the `LIBSTB_SIMD`
23
+ environment variable (an unknown or unavailable name prints one line on stderr and falls back to
24
+ auto), and a per-thread override: `with libstb.simd("scalar"):` (C++: `stb::simd_scope`).
25
+ - Hand-written SSE2 kernels (RGB/RGBA to gray, RGBA over RGB), bit identical to the scalar backend.
26
+ - `stb::env()` in `include/stb/env.hpp`: cross-platform, copy-returning environment variable reader
27
+ (uses `_dupenv_s` on MSVC).
28
+ - `Image.to_pil()` / `Image.from_pil()`. Pillow is loaded only when these are called
29
+ (`pip install "libstb[pillow]"`). Only 8-bit L/RGBA modes are supported, others raise `TypeError`.
30
+ - Examples 08 to 11 (geometry, channels and alpha, EXIF orientation, Pillow) and the notebook
31
+ `04_edit_and_orient`.
32
+ - Tests: edit, EXIF, channels, geometry, SIMD, array interface, functional, Pillow conversion,
33
+ garbage collection (`test_gc.py`) and allocation checks with `pytest-memray` (`test_memory.py`).
34
+ - `tests/python/test_torch.py`: DLPack in both directions with real torch (CPU). torch is not a
35
+ test dependency: the module is skipped when it cannot be imported.
36
+ - Documentation site: `-DLIBSTB_BUILD_DOCS=ON`, then `cmake --build build --target libstb_docs` builds the
37
+ C++ reference (Doxygen), the Python reference (Sphinx) and a landing page into `build/docs/out`.
38
+ - Coverage: `cmake --build build --target libstb_coverage` builds an lcov report for the C++ core, a
39
+ coverage.py report for the Python layer, a merged total and a dashboard in `build/coverage` (needs
40
+ `lcov` and `coverage`). The C++ tests compile the core sources into the test executable, so
41
+ coverage is just a few flags on that target; the shipped `libstb::core` and the Python extension are
42
+ unchanged.
43
+ - CI: QEMU user-mode job (`emulate`) that checks the fallback to portable SIMD backends on a CPU
44
+ without AVX2 (Nehalem) and the use of AVX2 kernels when available (Haswell).
45
+ - CI: native ARM64 runners (Linux and Windows) in the wheel matrix.
46
+ - CI: `build-docs` and `build-coverage` jobs in `cmake.yml` (coverage is also sent to Codecov), and a
47
+ `deploy-pages` job in the orchestrator that publishes the docs with the coverage dashboard under
48
+ `/coverage`. The coverage job installs the CPU build of torch so `test_torch.py` runs there.
49
+
50
+ ### Changed
51
+ - The scalar backend is compiled without compiler auto-vectorization, so it is really scalar.
52
+ - Wheel matrix runs with `fail-fast: false`.
53
+ - Python examples, notebooks, tests, benchmarks, README and docs import the package as
54
+ `import libstb as stb` and write `stb.Image`, `stb.imread`, ... (the package name is still `libstb`).
55
+ - Python 3.12+ builds use the stable ABI: `wheel.py-api = "cp312"` is set in `pyproject.toml`, giving
56
+ one `cp312-abi3` wheel for 3.12 and newer.
57
+ - `pytest-memray` is only required on x86_64 and arm64, and not on Windows. `numpy` is not required
58
+ for the test extra on Windows ARM64 with Python < 3.11; the test modules use
59
+ `pytest.importorskip` for numpy and Pillow.
60
+ - Benchmarks: new `imresize` and editing runners (`crop`, `rotate90`, `flip_horizontal`,
61
+ `convert_gray`, `composite`).
62
+ - README: image manipulation, EXIF, SIMD diagnosis, memory checks and GC support are documented.
63
+
64
+ ### Fixed
65
+ - `nanobind: leaked 1 instances!` at interpreter exit. An `Image` that views a Python object holds a
66
+ reference the GC cannot see, which could form an uncollectable cycle. `Image` now implements
67
+ `tp_traverse` / `tp_clear` and the keep-alive deleter reports the object it holds
68
+ (`image::owner_deleter<D>()` in `image.hpp`).
69
+ - Windows build: a test variable named `small` collided with the `small` macro from Windows headers
70
+ (renamed to `tiny`).
71
+ - `test_simd.py`: emulator backend detection in an assertion.
72
+
73
+ ## [0.5.0] - 2026-10-07
74
+
75
+ ### Added
76
+ - DLPack interop (`Image.from_dlpack`, `__dlpack__`) and image I/O helpers `imread` / `imwrite`.
77
+ - Examples `06_imread_imwrite.py` and `07_dlpack.py`, and updated notebooks.
78
+ - Tests for DLPack and the functional API.
79
+
80
+ ### Changed
81
+ - Legacy DLPack behavior on numpy < 2.1 (read-only views, no `copy=` / `device=` arguments) is
82
+ handled and documented; the affected tests are skipped on those versions.
83
+ - README API examples updated.
84
+
85
+ ## [0.4.0] - 2026-10-04
86
+
87
+ ### Added
88
+ - Standalone benchmark suite (`benchmarks/`) with its own build system and an HTML report, with
89
+ LaTeX formulas rendered by KaTeX (inlined, so the report stays self-contained).
90
+ - Pillow as a test-only dependency, with image format parity tests.
91
+ - Exhaustive PNG roundtrip exactness tests (noise, flat, gradient, tiled, sparse, photo-like,
92
+ degenerate sizes, more than 64K deflate tokens), a lossy tolerance test and a JPEG golden test.
93
+ - `Font.open()` accepts a file path and uses memory mapping on Unix and macOS.
94
+ - Getting Started, resize filters and font rendering example notebooks and the first Python examples
95
+ (`01` to `05`).
96
+
97
+ ### Changed
98
+ - Faster font loading (memory mapping, fast integer conversion).
99
+ - Faster JPEG encoding on GCC/Clang (`-fno-trapping-math` enables vectorized float to int
100
+ conversion) and a faster PNG encoder in the bundled `stb_image_write.h`. The default PNG
101
+ compression level is 8 (was 6).
102
+ - libdeflate was vendored and then removed again within this cycle; the PNG path uses the optimized
103
+ `stb_image_write.h`.
104
+ - Lossy tolerances in tests are standardized; benchmarks and `verify.py` use normalized mean
105
+ absolute error (NMAE).
106
+ - Documentation states that the optimized JPEG encoder is not guaranteed to be byte-identical across
107
+ compilers and flags (rare rounding ties, for example Apple clang on ARM64 or x86 with `-mfma`).
108
+ A tool, `tests/tools/jpeg_vs_upstream.py`, checks equivalence for identical build settings.
109
+
110
+ ## [0.3.0] - 2026-09-30
111
+
112
+ ### Added
113
+ - Python binding: errors map OS error codes to `FileNotFoundError`, `PermissionError` and similar;
114
+ the GIL is released during font rendering (`render_glyph`, `render`, `make_atlas`).
115
+
116
+ ### Changed
117
+ - C++ namespace and headers renamed from `libstb` to `stb` (`include/libstb.h` became
118
+ `include/stb.h`, `include/libstb/` became `include/stb/`). The Python package is still `libstb`.
119
+ - The abstract encoder hierarchy (`PngEncoder`, `JpegEncoder`, ...) was removed in favor of direct
120
+ methods on the image type (`to_png`, `write_jpg`, ...).
121
+ - `save()` was replaced by `write()`; the format is detected from the file extension
122
+ (case-insensitive).
123
+ - Resize accepts a filter by name (for example `"cubic"`).
124
+ - Documentation clarifies the move-only semantics of `stb::image` and pixel memory ownership, and
125
+ the difference between numpy views and copies.
126
+
127
+ ### Fixed
128
+ - Windows: `utest.h` macro collision, and the `NOMINMAX` / `WIN32_LEAN_AND_MEAN` guards in the test
129
+ headers.
130
+
131
+ ## Initial commit - 2026-09-28 (tag `__beta__`)
132
+
133
+ First state: C++17 core over the stb single-header libraries with image decoding and
134
+ encoding (PNG, JPEG, BMP, TGA), resizing with selectable filters, TrueType font rendering, and a
135
+ nanobind Python binding.
136
+
137
+ [Unreleased]: https://github.com/mohammadraziei/libstb/compare/v0.5.0...HEAD
138
+ [0.5.0]: https://github.com/mohammadraziei/libstb/compare/v0.4.0...v0.5.0
139
+ [0.4.0]: https://github.com/mohammadraziei/libstb/compare/v0.3.0...v0.4.0
140
+ [0.3.0]: https://github.com/mohammadraziei/libstb/compare/__beta__...v0.3.0
@@ -21,6 +21,7 @@ include(Optimize)
21
21
 
22
22
  option(LIBSTB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
23
23
  option(LIBSTB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
24
+ option(LIBSTB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
24
25
 
25
26
  # --- libstb C++ core ---
26
27
  # stb headers are vendored (committed) under src/third_party/stb and are only
@@ -59,21 +60,41 @@ target_include_directories(libstb_core
59
60
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
60
61
  $<INSTALL_INTERFACE:${_libstb_inc_dest}>
61
62
  )
62
- # SYSTEM: vendored headers we don't control - their internal warnings are not
63
- # ours to fix under our own -Wall/-Wextra/-W4.
64
- target_include_directories(libstb_core SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/third_party/stb)
63
+ # Everything that decides how the core sources are compiled lives in this function, so a target
64
+ # that compiles them itself (tests/cpp does, to attach coverage flags) gets exactly the same
65
+ # settings as libstb_core.
66
+ function(libstb_apply_core_build_settings target)
67
+ # SYSTEM: vendored headers we don't control - their internal warnings are not
68
+ # ours to fix under our own -Wall/-Wextra/-W4.
69
+ target_include_directories(${target} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/third_party/stb)
65
70
 
66
- target_compile_options(libstb_core PRIVATE
67
- $<$<CXX_COMPILER_ID:MSVC>:/W4 /EHsc>
68
- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
69
- )
70
- # -fno-trapping-math: lets GCC/Clang vectorize float->int conversions in the JPEG encoder's
71
- # quantization (about 2x faster JPEG). It only means FP operations are not required to
72
- # raise hardware traps (nothing here enables or reads them); results are unchanged.
73
- target_compile_options(libstb_core PRIVATE
74
- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-trapping-math>
75
- )
76
- apply_optimization_flags(libstb_core)
71
+ target_compile_options(${target} PRIVATE
72
+ $<$<CXX_COMPILER_ID:MSVC>:/W4 /EHsc>
73
+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
74
+ )
75
+ # -fno-trapping-math: lets GCC/Clang vectorize float->int conversions in the JPEG encoder's
76
+ # quantization (about 2x faster JPEG). It only means FP operations are not required to
77
+ # raise hardware traps (nothing here enables or reads them); results are unchanged.
78
+ target_compile_options(${target} PRIVATE
79
+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-trapping-math>
80
+ )
81
+ apply_optimization_flags(${target})
82
+
83
+ # image_kernels_scalar.cpp is the "scalar" SIMD backend: the same pixel loops with the
84
+ # compiler's auto-vectoriser off. (MSVC has no such switch: there it may still vectorise,
85
+ # with identical results.) TARGET_DIRECTORY: source file properties are per directory scope.
86
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
87
+ set_source_files_properties(${PROJECT_SOURCE_DIR}/src/core/image_kernels_scalar.cpp
88
+ TARGET_DIRECTORY ${target}
89
+ PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-fno-tree-slp-vectorize")
90
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
91
+ set_source_files_properties(${PROJECT_SOURCE_DIR}/src/core/image_kernels_scalar.cpp
92
+ TARGET_DIRECTORY ${target}
93
+ PROPERTIES COMPILE_OPTIONS "-fno-vectorize;-fno-slp-vectorize")
94
+ endif()
95
+ endfunction()
96
+
97
+ libstb_apply_core_build_settings(libstb_core)
77
98
 
78
99
  # --- install (find_package(libstb) -> libstb::core) ---
79
100
  include(CMakePackageConfigHelpers)
@@ -109,3 +130,8 @@ if(LIBSTB_BUILD_TESTS)
109
130
  set(CMAKE_CTEST_ARGUMENTS "--output-on-failure" "-V")
110
131
  add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
111
132
  endif()
133
+
134
+ # Documentation (Doxygen + Sphinx). Needs the Python extension: the Sphinx build imports it.
135
+ if(LIBSTB_BUILD_DOCS)
136
+ add_subdirectory(${PROJECT_SOURCE_DIR}/docs)
137
+ endif()