image3kit 0.0.1a0__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 (89) hide show
  1. image3kit-0.0.1a0/.clangd +17 -0
  2. image3kit-0.0.1a0/.editorconfig +22 -0
  3. image3kit-0.0.1a0/.github/CONTRIBUTING.md +16 -0
  4. image3kit-0.0.1a0/.github/dependabot.yml +11 -0
  5. image3kit-0.0.1a0/.github/workflows/cibw-cc.yaml +65 -0
  6. image3kit-0.0.1a0/.github/workflows/conda.yml +44 -0
  7. image3kit-0.0.1a0/.github/workflows/pip.yml +46 -0
  8. image3kit-0.0.1a0/.github/workflows/wheels.yml +125 -0
  9. image3kit-0.0.1a0/.gitignore +24 -0
  10. image3kit-0.0.1a0/.pre-commit-config.yaml +65 -0
  11. image3kit-0.0.1a0/CMakeLists.txt +173 -0
  12. image3kit-0.0.1a0/LICENSE +38 -0
  13. image3kit-0.0.1a0/Makefile +44 -0
  14. image3kit-0.0.1a0/PKG-INFO +41 -0
  15. image3kit-0.0.1a0/README.md +24 -0
  16. image3kit-0.0.1a0/conda.recipe/meta.yaml +47 -0
  17. image3kit-0.0.1a0/pkgs/README.md +10 -0
  18. image3kit-0.0.1a0/pkgs/optim/cmaes.h +2316 -0
  19. image3kit-0.0.1a0/pkgs/optim/primitives/Tnsr.h +2554 -0
  20. image3kit-0.0.1a0/pkgs/optim/primitives/Vctr.h +1343 -0
  21. image3kit-0.0.1a0/pkgs/optim/primitives/main.cpp +11 -0
  22. image3kit-0.0.1a0/pkgs/pybind11/LICENSE +36 -0
  23. image3kit-0.0.1a0/pkgs/stb/stb_image.h +7988 -0
  24. image3kit-0.0.1a0/pkgs/stb/stb_image_write.h +1724 -0
  25. image3kit-0.0.1a0/pkgs/svplot/README.md +49 -0
  26. image3kit-0.0.1a0/pkgs/svplot/example/demo_svplot.cpp +165 -0
  27. image3kit-0.0.1a0/pkgs/svplot/example/makefile +5 -0
  28. image3kit-0.0.1a0/pkgs/svplot/makefile +9 -0
  29. image3kit-0.0.1a0/pkgs/svplot/svg_color.hpp +407 -0
  30. image3kit-0.0.1a0/pkgs/svplot/svg_elements.hpp +1242 -0
  31. image3kit-0.0.1a0/pkgs/svplot/svg_elements_extra.hpp +787 -0
  32. image3kit-0.0.1a0/pkgs/svplot/svgraphic.hpp +583 -0
  33. image3kit-0.0.1a0/pkgs/svplot/svplot.hpp +522 -0
  34. image3kit-0.0.1a0/pkgs/svplot/svplot_axes.hpp +191 -0
  35. image3kit-0.0.1a0/pkgs/svplot/svplot_axis_x.hpp +573 -0
  36. image3kit-0.0.1a0/pkgs/svplot/svplot_axis_y.hpp +559 -0
  37. image3kit-0.0.1a0/pkgs/svplot/svplot_chain_set.hpp +1106 -0
  38. image3kit-0.0.1a0/pkgs/svplot/svplot_draw.hpp +1159 -0
  39. image3kit-0.0.1a0/pkgs/svplot/svplot_elems.hpp +800 -0
  40. image3kit-0.0.1a0/pkgs/svplot/theme.hpp +9 -0
  41. image3kit-0.0.1a0/pkgs/svplot/trash.hpp +485 -0
  42. image3kit-0.0.1a0/pkgs/zlib/zfstream.h +944 -0
  43. image3kit-0.0.1a0/pyproject.toml +106 -0
  44. image3kit-0.0.1a0/src/VxlImgXX.hpp +290 -0
  45. image3kit-0.0.1a0/src/_include/CMakeLists.txt +27 -0
  46. image3kit-0.0.1a0/src/_include/IOUtils.h +39 -0
  47. image3kit-0.0.1a0/src/_include/InputFile.h +313 -0
  48. image3kit-0.0.1a0/src/_include/README.md +79 -0
  49. image3kit-0.0.1a0/src/_include/SiRun.cpp +525 -0
  50. image3kit-0.0.1a0/src/_include/SiRun.h +102 -0
  51. image3kit-0.0.1a0/src/_include/globals.h +104 -0
  52. image3kit-0.0.1a0/src/_include/profilers.h +95 -0
  53. image3kit-0.0.1a0/src/_include/test_input.cpp +67 -0
  54. image3kit-0.0.1a0/src/_include/test_sirun.cpp +21 -0
  55. image3kit-0.0.1a0/src/_include/typses.h +874 -0
  56. image3kit-0.0.1a0/src/_include/utest.h +1718 -0
  57. image3kit-0.0.1a0/src/_voxlib/CMakeLists.txt +15 -0
  58. image3kit-0.0.1a0/src/_voxlib/Makefile +32 -0
  59. image3kit-0.0.1a0/src/_voxlib/VxlStrips.cpp +365 -0
  60. image3kit-0.0.1a0/src/_voxlib/VxlStrips.h +143 -0
  61. image3kit-0.0.1a0/src/_voxlib/shapeToVoxel.h +344 -0
  62. image3kit-0.0.1a0/src/_voxlib/voxelEndian.h +28 -0
  63. image3kit-0.0.1a0/src/_voxlib/voxelImage.cpp +374 -0
  64. image3kit-0.0.1a0/src/_voxlib/voxelImage.h +418 -0
  65. image3kit-0.0.1a0/src/_voxlib/voxelImageCutOutside.h +112 -0
  66. image3kit-0.0.1a0/src/_voxlib/voxelImageI.h +1933 -0
  67. image3kit-0.0.1a0/src/_voxlib/voxelImageML.h +1604 -0
  68. image3kit-0.0.1a0/src/_voxlib/voxelImageProcess.cpp +88 -0
  69. image3kit-0.0.1a0/src/_voxlib/voxelImageProcess.h +901 -0
  70. image3kit-0.0.1a0/src/_voxlib/voxelImageRegister.h +510 -0
  71. image3kit-0.0.1a0/src/_voxlib/voxelNoise.h +133 -0
  72. image3kit-0.0.1a0/src/_voxlib/voxelPng_stbi.h +381 -0
  73. image3kit-0.0.1a0/src/_voxlib/voxelRegions.h +272 -0
  74. image3kit-0.0.1a0/src/_voxlib/voxelTiff.h +221 -0
  75. image3kit-0.0.1a0/src/_voxlib/voxelTime.h +56 -0
  76. image3kit-0.0.1a0/src/_voxlib/vxlPro.cpp +531 -0
  77. image3kit-0.0.1a0/src/_voxlib/vxlPro1.cpp +77 -0
  78. image3kit-0.0.1a0/src/_voxlib/vxlPro2.cpp +12 -0
  79. image3kit-0.0.1a0/src/image3d_core.cpp +132 -0
  80. image3kit-0.0.1a0/src/image3kit/__init__.py +18 -0
  81. image3kit-0.0.1a0/src/image3kit/__init__.pyi +22 -0
  82. image3kit-0.0.1a0/src/image3kit/_core/__init__.pyi +10 -0
  83. image3kit-0.0.1a0/src/image3kit/_core/sirun.pyi +66 -0
  84. image3kit-0.0.1a0/src/image3kit/_core/voxlib.pyi +1854 -0
  85. image3kit-0.0.1a0/tests/piskelapp.png +0 -0
  86. image3kit-0.0.1a0/tests/test_2to3d.py +29 -0
  87. image3kit-0.0.1a0/tests/test_basic.py +42 -0
  88. image3kit-0.0.1a0/tests/test_operators.py +31 -0
  89. image3kit-0.0.1a0/tests/test_tiff.py +26 -0
@@ -0,0 +1,17 @@
1
+ # Portable clangd config
2
+ CompileFlags:
3
+ # CompilationDatabase: .
4
+ Add:
5
+ - "-DVMMLIB"
6
+ - "-DSVG"
7
+ - "-DLPNG"
8
+ - "-DTIFLIB"
9
+ - "-DZLIB"
10
+ - "-DOpenMP"
11
+ - "-DDUMMY=1"
12
+ - "-std=c++23"
13
+
14
+
15
+ # Indexing settings
16
+ Index:
17
+ Background: Build
@@ -0,0 +1,22 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+ trim_trailing_whitespace = true
7
+ charset = utf-8
8
+
9
+ [*.{cpp,h,cc,hpp,c}]
10
+ indent_style = space
11
+ indent_size = 2
12
+
13
+ [*.{java,js,ts}]
14
+ indent_style = space
15
+ indent_size = 2
16
+
17
+ [*.py]
18
+ indent_style = space
19
+ indent_size = 4
20
+
21
+ [Makefile]
22
+ indent_style = tab
@@ -0,0 +1,16 @@
1
+ * This is a work in progress and not ready for public use, but you are welcome to try it out or help improving it.
2
+
3
+ * **Code of conduct:** Priority is given to a clean commit history and saving time over user convenience:
4
+ * Commits are pushed directly to `master` and `main` branches.
5
+ * Developers may force-push/rebase recently published commits.
6
+ * **You may need the CLI to sync forks.**
7
+ * **The commit history of contributions (PRs) will be preserved.**
8
+ * Tags/releases will be added when the code stabilizes.
9
+
10
+ * LLM-generated code/docs are allowed but require human review.
11
+
12
+ * Documentation is sparse. Refer to [tests/](../tests/) and code snippets. Help is welcome.
13
+
14
+ * **Branches:**
15
+ * `main`: Documentation and releases. Expected to pass CI, though currently unstable and not fully tested.
16
+ * `master`: CI/CD testing ([workflows](.github/workflows/)). May be unstable or out-of-sync with `main`.
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain dependencies for GitHub Actions
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ groups:
9
+ actions:
10
+ patterns:
11
+ - "*"
@@ -0,0 +1,65 @@
1
+ name: CIBW cross-compile
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ branches:
7
+ - master
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+
14
+ jobs:
15
+ build:
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ include:
20
+ - platform: android
21
+ os: ubuntu-latest
22
+ - platform: android
23
+ os: macos-latest
24
+ - platform: ios
25
+ os: macos-latest
26
+ archs: all
27
+ - platform: pyodide
28
+ os: ubuntu-latest
29
+
30
+ name: ${{ matrix.platform }} on ${{ matrix.os }}
31
+ runs-on: ${{ matrix.os }}
32
+
33
+ steps:
34
+ - uses: actions/checkout@v6
35
+
36
+ - uses: actions/setup-python@v6
37
+
38
+ - if: matrix.platform == 'ios'
39
+ run: brew upgrade cmake
40
+
41
+ # GitHub Actions can't currently run the Android emulator on macOS.
42
+ - name: Skip Android tests on macOS
43
+ if: runner.os == 'macOS'
44
+ run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV"
45
+
46
+ # https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
47
+ - name: Enable KVM for Android emulator
48
+ if: runner.os == 'Linux' && matrix.platform == 'android'
49
+ run: |
50
+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
51
+ sudo udevadm control --reload-rules
52
+ sudo udevadm trigger --name-match=kvm
53
+
54
+ - if: matrix.platform == 'android'
55
+ run: pipx install patchelf
56
+
57
+ - uses: pypa/cibuildwheel@v3.3
58
+ env:
59
+ CIBW_PLATFORM: ${{ matrix.platform }}
60
+ CIBW_ARCHS: ${{ matrix.archs || 'auto' }}
61
+
62
+ - uses: actions/upload-artifact@v6
63
+ with:
64
+ name: wheels-${{ matrix.platform }}-${{ matrix.os }}
65
+ path: dist/*.whl
@@ -0,0 +1,44 @@
1
+ name: Conda
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - master
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ platform: [ubuntu-latest]
16
+ python-version: ["3.12", "3.14"]
17
+
18
+ runs-on: ${{ matrix.platform }}
19
+
20
+ # The setup-miniconda action needs this to activate miniconda
21
+ defaults:
22
+ run:
23
+ shell: "bash -l {0}"
24
+
25
+ steps:
26
+ - uses: actions/checkout@v6
27
+
28
+ - name: Get conda
29
+ uses: conda-incubator/setup-miniconda@v3.3.0
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+ channels: conda-forge
33
+
34
+ - name: Prepare
35
+ run: conda install conda-build conda-verify pytest numpy
36
+
37
+ - name: Build
38
+ run: conda build conda.recipe
39
+
40
+ - name: Install
41
+ run: conda install -c ${CONDA_PREFIX}/conda-bld/ image3kit
42
+
43
+ - name: Test
44
+ run: pytest tests
@@ -0,0 +1,46 @@
1
+ name: "Pip"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - master
9
+
10
+ jobs:
11
+ build:
12
+ name: Build with Pip
13
+ runs-on: ${{ matrix.platform }}
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ platform: [windows-latest, macos-latest, ubuntu-latest]
18
+ python-version: ["3.12", "3.14"] # "pypy-3.10" worked (on Win_x86_64 only)
19
+
20
+
21
+ steps:
22
+ - uses: actions/checkout@v6
23
+
24
+ - uses: actions/setup-python@v6
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+ allow-prereleases: true
28
+
29
+ - name: Install dependencies (macOS)
30
+ if: runner.os == 'macOS'
31
+ run: |
32
+ brew install libomp
33
+ echo "OpenMP_ROOT=$(brew --prefix libomp)" >> $GITHUB_ENV
34
+
35
+ - name: Install dependencies (Windows)
36
+ if: runner.os == 'Windows'
37
+ run: |
38
+ vcpkg install zlib:x64-windows
39
+ echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
40
+ echo "SKBUILD_CMAKE_ARGS=-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
41
+
42
+ - name: Build and install
43
+ run: pip install --verbose . --group test
44
+
45
+ - name: Test
46
+ run: pytest
@@ -0,0 +1,125 @@
1
+ name: Wheels
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - master
9
+ release:
10
+ types:
11
+ - published
12
+
13
+ env:
14
+ FORCE_COLOR: 3
15
+
16
+ concurrency:
17
+ group: ${{ github.workflow }}-${{ github.ref }}
18
+ cancel-in-progress: true
19
+
20
+ jobs:
21
+ build_sdist:
22
+ name: Build SDist
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v6
26
+ with:
27
+ submodules: true
28
+
29
+ - name: Build SDist
30
+ run: pipx run build --sdist
31
+
32
+ - name: Check metadata
33
+ run: pipx run twine check dist/*
34
+
35
+ - uses: actions/upload-artifact@v6
36
+ with:
37
+ name: cibw-sdist
38
+ path: dist/*.tar.gz
39
+
40
+
41
+ build_wheels:
42
+ name: Wheels on ${{ matrix.os }}
43
+ runs-on: ${{ matrix.os }}
44
+ strategy:
45
+ fail-fast: false
46
+ matrix:
47
+ os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, windows-11-arm]
48
+
49
+ steps:
50
+ - uses: actions/checkout@v6
51
+ with:
52
+ submodules: true
53
+
54
+ - uses: astral-sh/setup-uv@v7
55
+
56
+ - name: Install dependencies (macOS)
57
+ if: runner.os == 'macOS'
58
+ run: |
59
+ brew install libomp
60
+ echo "OpenMP_ROOT=$(brew --prefix libomp)" >> $GITHUB_ENV
61
+
62
+ - name: Install dependencies (Windows)
63
+ if: runner.os == 'Windows'
64
+ run: |
65
+ vcpkg install zlib:${{ matrix.os == 'windows-11-arm' && 'arm64' || 'x64' }}-windows
66
+ echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
67
+
68
+ - name: Find correct LLVM OpenMP DLL (Windows ARM64)
69
+ if: matrix.os == 'windows-11-arm'
70
+ run: |
71
+ $libomp = Get-ChildItem -Path "C:\Program Files" -Filter libomp140.aarch64.dll -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
72
+ if ($libomp) {
73
+ echo "LIBOMP_DIR=$($libomp.DirectoryName)" >> $env:GITHUB_ENV
74
+ echo "Found libomp at $($libomp.DirectoryName)"
75
+ echo ('CIBW_REPAIR_WHEEL_COMMAND_WINDOWS=delvewheel repair -w {dest_dir} {wheel} --add-path "' + $libomp.DirectoryName + '"') >> $env:GITHUB_ENV
76
+ } else {
77
+ echo "::warning ::libomp140.aarch64.dll not found!"
78
+ }
79
+ shell: pwsh
80
+
81
+ - uses: pypa/cibuildwheel@v3.3
82
+ env:
83
+ CIBW_ENABLE: cpython-prerelease
84
+ CIBW_ARCHS_WINDOWS: ${{ matrix.os == 'windows-11-arm' && 'ARM64' || 'auto' }}
85
+ MACOSX_DEPLOYMENT_TARGET: "15.0"
86
+ CIBW_ENVIRONMENT_WINDOWS: SKBUILD_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
87
+ CIBW_ENVIRONMENT_MACOS: OpenMP_ROOT=$OpenMP_ROOT
88
+
89
+ - name: Verify clean directory
90
+ run: git diff --exit-code
91
+ shell: bash
92
+
93
+ - uses: actions/upload-artifact@v6
94
+ with:
95
+ name: cibw-wheels-${{ matrix.os }}
96
+ path: wheelhouse/*.whl
97
+
98
+
99
+ upload_all:
100
+ name: Upload if release
101
+ needs: [build_wheels, build_sdist]
102
+ runs-on: ubuntu-latest
103
+ if: github.event_name == 'release' && github.event.action == 'published'
104
+ environment: pypi
105
+ permissions:
106
+ id-token: write
107
+ attestations: write
108
+
109
+ steps:
110
+ - uses: actions/setup-python@v6
111
+ with:
112
+ python-version: "3.x"
113
+
114
+ - uses: actions/download-artifact@v7
115
+ with:
116
+ pattern: cibw-*
117
+ merge-multiple: true
118
+ path: dist
119
+
120
+ - name: Generate artifact attestation for sdist and wheels
121
+ uses: actions/attest-build-provenance@v3
122
+ with:
123
+ subject-path: "dist/*"
124
+
125
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,24 @@
1
+ # Using https://github.com/github/gitignore/blob/master/Python.gitignore
2
+
3
+ # IDE/language servers
4
+ compile_commands.json
5
+ .vscode/
6
+
7
+ # Byte-compiled / optimized / DLL files
8
+ __pycache__/
9
+
10
+ # Distribution / packaging
11
+ build/
12
+
13
+ # Test artifacts
14
+ fig/
15
+
16
+ # Environments
17
+ .env
18
+ .venv
19
+ env/
20
+ venv/
21
+
22
+ # Cache directories
23
+ .cache/
24
+ *_cache/
@@ -0,0 +1,65 @@
1
+ # To use:
2
+ #
3
+ # pre-commit run -a
4
+ #
5
+ # Or:
6
+ #
7
+ # pre-commit install # (runs every time you commit in git)
8
+ #
9
+ # To update this file:
10
+ #
11
+ # pre-commit autoupdate
12
+ #
13
+ # See https://github.com/pre-commit/pre-commit
14
+
15
+ ci:
16
+ autoupdate_commit_msg: "chore: update pre-commit hooks"
17
+ autofix_commit_msg: "style: pre-commit fixes"
18
+
19
+ repos:
20
+ # Standard hooks
21
+ - repo: https://github.com/pre-commit/pre-commit-hooks
22
+ rev: v6.0.0
23
+ hooks:
24
+ - id: check-added-large-files
25
+ - id: check-case-conflict
26
+ - id: check-merge-conflict
27
+ - id: check-symlinks
28
+ - id: check-yaml
29
+ exclude: ^conda\.recipe/meta\.yaml$
30
+ - id: debug-statements
31
+ - id: end-of-file-fixer
32
+ - id: mixed-line-ending
33
+ - id: requirements-txt-fixer
34
+ - id: trailing-whitespace
35
+
36
+ # Check linting and style issues
37
+ - repo: https://github.com/astral-sh/ruff-pre-commit
38
+ rev: "v0.14.5"
39
+ hooks:
40
+ - id: ruff
41
+ args: ["--fix", "--show-fixes"]
42
+ - id: ruff-format
43
+ exclude: ^(docs)
44
+
45
+ # Changes tabs to spaces
46
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
47
+ rev: v1.5.5
48
+ hooks:
49
+ - id: remove-tabs
50
+ exclude: ^(docs/|.*akefile)
51
+
52
+ # CMake formatting
53
+ - repo: https://github.com/cheshirekow/cmake-format-precommit
54
+ rev: v0.6.13
55
+ hooks:
56
+ - id: cmake-format
57
+ additional_dependencies: [pyyaml]
58
+ types: [file]
59
+ files: (\.cmake|CMakeLists.txt)(.in)?$
60
+
61
+ # Suggested hook if you add a .clang-format file
62
+ # - repo: https://github.com/pre-commit/mirrors-clang-format
63
+ # rev: v13.0.0
64
+ # hooks:
65
+ # - id: clang-format
@@ -0,0 +1,173 @@
1
+ # Require CMake 3.15+ (matching scikit-build-core) Use new versions of all
2
+ # policies up to CMake 4.0
3
+ cmake_minimum_required(VERSION 3.15...4.0)
4
+
5
+ # Disable C++20 module dependency scanning (requires clang-scan-deps)
6
+ set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
7
+
8
+ # Scikit-build-core sets these values, provide fallbacks for standalone builds
9
+ if(NOT DEFINED SKBUILD_PROJECT_NAME)
10
+ set(SKBUILD_PROJECT_NAME "image3kit")
11
+ endif()
12
+ if(NOT DEFINED SKBUILD_PROJECT_VERSION)
13
+ set(SKBUILD_PROJECT_VERSION "0.0.0")
14
+ endif()
15
+
16
+ project(
17
+ ${SKBUILD_PROJECT_NAME}
18
+ VERSION ${SKBUILD_PROJECT_VERSION}
19
+ LANGUAGES CXX)
20
+
21
+ # Find Python first (required for pybind11 fallback, for IDEs)
22
+ find_package(
23
+ Python
24
+ COMPONENTS Interpreter Development.Module
25
+ REQUIRED)
26
+
27
+ if(MSVC)
28
+ add_compile_definitions(NOMINMAX)
29
+ endif()
30
+
31
+ include(FetchContent)
32
+
33
+ # Find pybind11 and Python
34
+ find_package(pybind11 CONFIG QUIET)
35
+ if(NOT pybind11_FOUND)
36
+ FetchContent_Declare(
37
+ pybind11
38
+ URL https://github.com/pybind/pybind11/archive/refs/tags/v3.0.1.tar.gz)
39
+ FetchContent_MakeAvailable(pybind11)
40
+ endif()
41
+
42
+ find_package(ZLIB)
43
+ if(NOT ZLIB_FOUND)
44
+ message(STATUS "ZLIB not found, fetching from source...")
45
+ FetchContent_Declare(
46
+ ZLIB
47
+ URL https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz
48
+ EXCLUDE_FROM_ALL)
49
+ FetchContent_MakeAvailable(ZLIB)
50
+ if(NOT TARGET ZLIB::ZLIB)
51
+ if(TARGET zlibstatic)
52
+ add_library(ZLIB::ZLIB ALIAS zlibstatic)
53
+ elseif(TARGET zlib)
54
+ add_library(ZLIB::ZLIB ALIAS zlib)
55
+ endif()
56
+ endif()
57
+ endif()
58
+
59
+ if(APPLE)
60
+ if(NOT DEFINED OpenMP_ROOT AND DEFINED ENV{OpenMP_ROOT})
61
+ set(OpenMP_ROOT $ENV{OpenMP_ROOT})
62
+ endif()
63
+
64
+ find_package(OpenMP)
65
+
66
+ if(NOT OpenMP_FOUND)
67
+ # Hint for Homebrew libomp
68
+ set(OpenMP_CXX_FLAGS -Xpreprocessor -fopenmp)
69
+ set(OpenMP_CXX_LIB_NAMES "omp")
70
+ if(EXISTS "${OpenMP_ROOT}/lib/libomp.dylib")
71
+ set(OpenMP_omp_LIBRARY "${OpenMP_ROOT}/lib/libomp.dylib")
72
+ elseif(EXISTS "/opt/homebrew/opt/libomp/lib/libomp.dylib")
73
+ set(OpenMP_omp_LIBRARY "/opt/homebrew/opt/libomp/lib/libomp.dylib")
74
+ elseif(EXISTS "/usr/local/opt/libomp/lib/libomp.dylib")
75
+ set(OpenMP_omp_LIBRARY "/usr/local/opt/libomp/lib/libomp.dylib")
76
+ endif()
77
+
78
+ if(DEFINED OpenMP_omp_LIBRARY)
79
+ message(STATUS "Manual config for OpenMP: ${OpenMP_omp_LIBRARY}")
80
+ set(OpenMP_FOUND TRUE)
81
+ add_library(OpenMP::OpenMP_CXX UNKNOWN IMPORTED)
82
+ set_target_properties(
83
+ OpenMP::OpenMP_CXX
84
+ PROPERTIES IMPORTED_LOCATION "${OpenMP_omp_LIBRARY}"
85
+ INTERFACE_COMPILE_OPTIONS "${OpenMP_CXX_FLAGS}"
86
+ INTERFACE_LINK_LIBRARIES "${OpenMP_omp_LIBRARY}")
87
+ endif()
88
+ endif()
89
+ endif()
90
+
91
+ if(NOT OpenMP_FOUND)
92
+ find_package(OpenMP REQUIRED)
93
+ endif()
94
+ FetchContent_Declare(
95
+ TIFF
96
+ URL https://gitlab.com/libtiff/libtiff/-/archive/v4.6.0/libtiff-v4.6.0.tar.gz
97
+ EXCLUDE_FROM_ALL)
98
+ set(tiff-tools
99
+ OFF
100
+ CACHE BOOL "Build libtiff tools")
101
+ set(tiff-tests
102
+ OFF
103
+ CACHE BOOL "Build libtiff tests")
104
+ set(tiff-contrib
105
+ OFF
106
+ CACHE BOOL "Build libtiff contrib")
107
+ set(tiff-docs
108
+ OFF
109
+ CACHE BOOL "Build libtiff docs")
110
+ set(BUILD_SHARED_LIBS
111
+ OFF
112
+ CACHE BOOL "Build shared libraries" FORCE)
113
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
114
+ set(CMAKE_WARN_DEPRECATED
115
+ OFF
116
+ CACHE BOOL "" FORCE)
117
+ FetchContent_MakeAvailable(TIFF)
118
+ set(CMAKE_WARN_DEPRECATED
119
+ ON
120
+ CACHE BOOL "" FORCE)
121
+
122
+ # Add a library using FindPython's tooling (pybind11 also provides a helper like
123
+ # this)
124
+ file(GLOB PyBind_SRCS CONFIGURE_DEPENDS "src/*.cpp")
125
+ set(VOXLIB_SRC
126
+ src/_voxlib/voxelImage.cpp src/_voxlib/vxlPro.cpp src/_voxlib/vxlPro1.cpp
127
+ src/_voxlib/vxlPro2.cpp src/_voxlib/VxlStrips.cpp)
128
+ python_add_library(_core MODULE ${VOXLIB_SRC} ${PyBind_SRCS} WITH_SOABI)
129
+ target_compile_definitions(
130
+ _core
131
+ PRIVATE SVG
132
+ LPNG
133
+ TIFLIB
134
+ ZLIB
135
+ OpenMP
136
+ VMMLIB
137
+ DUMMY=1)
138
+ # find_package(pybind11 CONFIG REQUIRED PATHS ./build)
139
+ target_link_libraries(_core PRIVATE pybind11::headers)
140
+
141
+ target_include_directories(_core PRIVATE src/_include)
142
+ target_include_directories(_core PRIVATE src/_voxlib)
143
+ target_include_directories(_core PRIVATE pkgs/optim)
144
+ target_include_directories(_core PRIVATE pkgs/optim/primitives)
145
+ target_include_directories(_core PRIVATE pkgs/stb)
146
+ target_include_directories(_core PRIVATE pkgs/zlib)
147
+ target_include_directories(_core PRIVATE pkgs/svplot)
148
+
149
+ target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
150
+
151
+ set_property(TARGET _core PROPERTY CXX_STANDARD 23)
152
+ # Toolset: gcc-linux:
153
+
154
+ if(MSVC)
155
+ target_compile_options(_core PRIVATE /openmp:llvm /diagnostics:caret /bigobj
156
+ )# /W4
157
+ target_compile_definitions(_core PRIVATE NOMINMAX)
158
+ else()
159
+ target_compile_options(_core PRIVATE -Wall -Wextra -Wpedantic)
160
+ # target_compile_options(_core PRIVATE -Werror)
161
+ endif()
162
+
163
+ target_link_libraries(_core PRIVATE Python::Module ZLIB::ZLIB TIFF::tiff
164
+ OpenMP::OpenMP_CXX)
165
+
166
+ # The install directory is the output (wheel) directory
167
+ install(TARGETS _core DESTINATION image3kit)
168
+
169
+ # Add targets for local includes to ensure they appear in compile_commands.json
170
+ # This fixes tooling errors in headers like typses.h
171
+ add_subdirectory(src/_include)
172
+ add_subdirectory(src/_voxlib)
173
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # use .clangd instead
@@ -0,0 +1,38 @@
1
+
2
+ Copyright (2026) Heriot-Watt University DigiPoreFlow and Eco-AI teams
3
+ Copyright (2025) Ali Q. Raeini
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ You are under no obligation whatsoever to provide any bug fixes, patches, or
31
+ upgrades to the features, functionality or performance of the source code
32
+ ("Enhancements") to anyone; however, if you choose to make your Enhancements
33
+ available either publicly, or directly to the author of this software, without
34
+ imposing a separate written license agreement for such Enhancements, then you
35
+ hereby grant the following license: a non-exclusive, royalty-free perpetual
36
+ license to install, use, modify, prepare derivative works, incorporate into
37
+ other computer software, distribute, and sublicense such enhancements or
38
+ derivative works thereof, in binary and source code form.
@@ -0,0 +1,44 @@
1
+
2
+ PY=
3
+ help:
4
+ @echo "Install prerequisite using commands:"
5
+ @echo " python -m venv ./.venv"
6
+ @echo " source .venv/bin/activate"
7
+ @echo " pip install pybind11-stubgen numpy pytest"
8
+ @echo
9
+ @echo "Available target commands:"
10
+ @echo " make all # Install and update pybind11 stubs"
11
+ @echo " make install # Install the package"
12
+ @echo " make test # Run tests"
13
+
14
+ all: setup_venv
15
+ .venv/bin/pip install .
16
+ @$(MAKE) test
17
+ @$(MAKE) stubgen
18
+ @$(MAKE) pre-commit
19
+
20
+ stubgen:
21
+ @[ -f .venv/bin/pybind11-stubgen ] || (set -x && .venv/bin/pip install pybind11-stubgen)
22
+ .venv/bin/pybind11-stubgen image3kit --output-dir src
23
+
24
+ install_global:
25
+ pip install .
26
+
27
+ test:
28
+ @[ -f .venv/bin/pytest ] || (set -x && .venv/bin/pip install pytest)
29
+ .venv/bin/pytest
30
+
31
+ .PHONY: setup_venv clean build tests
32
+
33
+
34
+ setup_venv:
35
+ python3 -m venv .venv
36
+ .venv/bin/pip install cmake pre-commit
37
+ .venv/bin/cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
38
+ ln -sf build/compile_commands.json ./
39
+
40
+ clean:
41
+ rm -rf build compile_commands.json
42
+
43
+ pre-commit:
44
+ .venv/bin/pre-commit run -a || .venv/bin/pre-commit run -a