refactor: improve MaterialValueMap and update examples #663
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🐍 Bindings | |
| on: | |
| release: | |
| types: | |
| - published | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| type: boolean | |
| description: Publish on PyPi | |
| jobs: | |
| test-bindings: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| container: ghcr.io/viennatools/vienna-builder:cuda-suite-python | |
| - os: windows-latest | |
| - os: macos-latest | |
| runs-on: ${{ matrix.os }} | |
| container: ${{ matrix.container }} | |
| env: | |
| VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache | |
| name: "🐍 Test Bindings on ${{ matrix.os }}" | |
| steps: | |
| - name: 📥 Checkout | |
| uses: actions/checkout@v4 | |
| - name: 🖥️ Setup Environment | |
| uses: ./.github/actions/setup | |
| with: | |
| os: ${{ matrix.os }} | |
| - name: 📋 Install MacOS Dependencies | |
| if: ${{ matrix.os == 'macos-latest' }} | |
| run: brew install embree tbb vtk | |
| - name: Create vcpkg binary cache dir | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" | |
| - name: 🦥 Cache vcpkg binary | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} | |
| key: vcpkg-${{ matrix.os }}-Release | |
| - name: 🛠️ Build Dependencies (Windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| ./vcpkg/vcpkg install vtk embree | |
| - name: 🛠️ Enable GPU Bindings (Linux) | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| sed -i 's/\(DVIENNAPS_BUILD_PYTHON=ON"\)/\1,"-DVIENNAPS_USE_GPU=ON", "-DVIENNACORE_LINK_CUDA_DRIVER=OFF"/g' pyproject.toml | |
| cat pyproject.toml | |
| - name: 🐍 Build and check Python Module (Windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| run: | | |
| python -m venv venv | |
| $toolchain = "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake".Replace('\', '/') | |
| .\venv\Scripts\python -m pip install --upgrade pip | |
| .\venv\Scripts\python -m pip install . --config-settings=cmake.args="-DCMAKE_TOOLCHAIN_FILE=$toolchain" | |
| .\venv\Scripts\python -c "import viennaps; print(viennaps.__doc__)" | |
| - name: 🐍 Build and check Python Module (Other) | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: | | |
| python -m venv venv | |
| CMAKE_ARGS=-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF ./venv/bin/pip install . | |
| ./venv/bin/python -c "import viennaps; print(viennaps.__doc__)" | |
| - name: 📦 Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Pre-Built (${{ matrix.os }}) | |
| path: venv | |
| package: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' || github.event_name == 'workflow_dispatch' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| skip: "cp38-* cp39-* pp38-* pp39-* pp310-* *-manylinux_i686 *-musllinux_*" | |
| - os: windows-latest | |
| skip: "cp38-* cp39-* pp38-* pp39-* pp310-*" | |
| - os: macos-latest | |
| skip: "cp38-* cp39-* cp310-* pp38-* pp39-* pp310-*" | |
| runs-on: ${{ matrix.os }} | |
| name: "🐍 Package Bindings on ${{ matrix.os }}" | |
| steps: | |
| - name: 📥 Checkout | |
| uses: actions/checkout@v4 | |
| - name: 🖥️ Setup Environment | |
| uses: ./.github/actions/setup | |
| with: | |
| os: ${{ matrix.os }} | |
| - name: 🛞 CIBuildWheel | |
| run: pip install cibuildwheel==3.4.0 --break-system-packages | |
| - name: 🛠️ Use VTK-Python Libs | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| sed -i 's/\(DVIENNAPS_BUILD_PYTHON=ON"\)/\1,"-DVIENNAPS_PACKAGE_PYTHON=ON","-DVIENNAPS_IS_CI=ON"/g' pyproject.toml | |
| type pyproject.toml | |
| - name: 🛠️ Use VTK-Python Libs | |
| if: ${{ matrix.os == 'macos-latest' }} | |
| run: | | |
| sed -i .bak 's/\(DVIENNAPS_BUILD_PYTHON=ON"\)/\1,"-DVIENNAPS_PACKAGE_PYTHON=ON","-DVIENNAPS_IS_CI=ON"/g' pyproject.toml | |
| cat pyproject.toml | |
| - name: 🛠️ Use VTK-Python Libs | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| sed -i 's/\(DVIENNAPS_BUILD_PYTHON=ON"\)/\1,"-DVIENNAPS_PACKAGE_PYTHON=ON","-DVIENNAPS_IS_CI=ON", "-DVIENNAPS_USE_GPU=ON", "-DVIENNACORE_LINK_CUDA_DRIVER=OFF"/g' pyproject.toml | |
| cat pyproject.toml | |
| - name: 🏗️ Build Wheels (Linux) | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| env: | |
| CIBW_SKIP: ${{ matrix.skip }} | |
| CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/viennatools/vienna-builder:cuda-python | |
| - name: 🏗️ Build Wheels (Other) | |
| if: ${{ matrix.os != 'ubuntu-latest' }} | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| env: | |
| CIBW_SKIP: ${{ matrix.skip }} | |
| CIBW_ARCHS_WINDOWS: auto64 | |
| - name: 📦 Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| deploy: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' }} | |
| needs: [package] | |
| permissions: | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| name: "🐍 Publish Bindings" | |
| steps: | |
| - name: 📦 Download Wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - name: 🚀 Publish Wheels | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |