| 1 |
name: PyCOLMAP |
| 2 |
|
| 3 |
concurrency: |
| 4 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 6 |
|
| 7 |
on: |
| 8 |
workflow_dispatch: |
| 9 |
push: |
| 10 |
branches: |
| 11 |
- main |
| 12 |
- release/* |
| 13 |
pull_request: |
| 14 |
types: [ assigned, opened, synchronize, reopened ] |
| 15 |
release: |
| 16 |
types: [ published, edited ] |
| 17 |
|
| 18 |
jobs: |
| 19 |
build: |
| 20 |
name: ${{ matrix.config.os }} ${{ matrix.config.arch }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} |
| 21 |
runs-on: ${{ matrix.config.os }} |
| 22 |
strategy: |
| 23 |
matrix: |
| 24 |
config: [ |
| 25 |
{os: ubuntu-24.04, cudaEnabled: false, ccacheMaxSize: 800M}, |
| 26 |
{os: macos-14, arch: arm64, deploymentTarget: 14.0, cudaEnabled: false, ccacheMaxSize: 350M}, |
| 27 |
{os: windows-2025-vs2026, cudaEnabled: false, ccacheMaxSize: 1000M}, |
| 28 |
{os: ubuntu-24.04, cudaEnabled: true, ccacheMaxSize: 850M}, |
| 29 |
] |
| 30 |
env: |
| 31 |
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache |
| 32 |
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache |
| 33 |
CCACHE_BASEDIR: ${{ github.workspace }} |
| 34 |
CACHE_PLATFORM: ${{ matrix.config.os }}-arch_${{ matrix.config.arch || 'x64' }}-cuda_${{ matrix.config.cudaEnabled }}-deployment_${{ matrix.config.deploymentTarget || 'default' }} |
| 35 |
# cibuildwheel creates a different temporary build directory for every |
| 36 |
# wheel and run. Do not include that directory in compiler cache keys. |
| 37 |
CCACHE_NOHASHDIR: "true" |
| 38 |
# Hosted runner compiler mtimes can change even when their contents do |
| 39 |
# not, which would otherwise invalidate the cache. |
| 40 |
CCACHE_COMPILERCHECK: content |
| 41 |
# Keep enough history for the COLMAP and pycolmap objects without |
| 42 |
# exhausting the repository-wide GitHub Actions cache quota. |
| 43 |
CCACHE_MAXSIZE: ${{ matrix.config.ccacheMaxSize }} |
| 44 |
FETCHCONTENT_CACHE_DIR: ${{ github.workspace }}/fetchcontent-cache |
| 45 |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.config.deploymentTarget }} |
| 46 |
# For faster builds in PRs, build only two Python versions instead of all: |
| 47 |
# the oldest supported one, so that version-specific breakage does not |
| 48 |
# reach main, and cp312, the oldest version supported by the pinned Sphinx |
| 49 |
# used in the docs job, which reuses this wheel. |
| 50 |
PULL_REQUEST_CIBW_BUILD: cp3{10,12}-{macosx,manylinux,win}* |
| 51 |
steps: |
| 52 |
- name: Free disk space |
| 53 |
if: runner.os == 'Linux' && matrix.config.cudaEnabled |
| 54 |
uses: jlumbroso/[email protected] |
| 55 |
with: |
| 56 |
tool-cache: false |
| 57 |
android: true |
| 58 |
dotnet: true |
| 59 |
haskell: true |
| 60 |
large-packages: true |
| 61 |
docker-images: true |
| 62 |
swap-storage: true |
| 63 |
|
| 64 |
- uses: actions/checkout@v7 |
| 65 |
|
| 66 |
- name: Restore compiler cache |
| 67 |
uses: ./.github/actions/compiler-cache |
| 68 |
id: cache-compiler |
| 69 |
with: |
| 70 |
mode: restore |
| 71 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 72 |
key-prefix: pycolmap-compiler |
| 73 |
key-suffix: ${{ env.CACHE_PLATFORM }} |
| 74 |
|
| 75 |
- name: Select Python |
| 76 |
if: github.event_name == 'pull_request' && runner.os != 'Windows' |
| 77 |
run: | |
| 78 |
echo "CIBW_BUILD=${PULL_REQUEST_CIBW_BUILD}" >> "$GITHUB_ENV" |
| 79 |
- name: Select Python |
| 80 |
if: ${{ github.event_name == 'pull_request' && runner.os == 'Windows' }} |
| 81 |
shell: pwsh |
| 82 |
run: | |
| 83 |
echo "CIBW_BUILD=${env:PULL_REQUEST_CIBW_BUILD}" >> "${env:GITHUB_ENV}" |
| 84 |
|
| 85 |
- name: Set env (macOS) |
| 86 |
if: runner.os == 'macOS' |
| 87 |
run: | |
| 88 |
VCPKG_TARGET_TRIPLET="arm64-osx-release" |
| 89 |
echo "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" >> "$GITHUB_ENV" |
| 90 |
|
| 91 |
VCPKG_INSTALLATION_ROOT="/Users/runner/work/vcpkg" |
| 92 |
CMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" |
| 93 |
CMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} |
| 94 |
echo "VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV" |
| 95 |
echo "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" >> "$GITHUB_ENV" |
| 96 |
echo "CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}" >> "$GITHUB_ENV" |
| 97 |
echo "ARCHFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES}" >> "$GITHUB_ENV" |
| 98 |
|
| 99 |
# Fix: cibuildhweel cannot interpolate env variables. |
| 100 |
CONFIG_SETTINGS="cmake.define.CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" |
| 101 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" |
| 102 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.VCPKG_INSTALLED_DIR=${{ github.workspace }}/build/vcpkg_installed" |
| 103 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}" |
| 104 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.pybind11_DIR=${COMPILER_CACHE_DIR}/build-requirements/pybind11/share/cmake/pybind11" |
| 105 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.WERROR_ENABLED=ON" |
| 106 |
echo "CIBW_CONFIG_SETTINGS_MACOS=${CONFIG_SETTINGS}" >> "$GITHUB_ENV" |
| 107 |
|
| 108 |
echo "FETCHCONTENT_BASE_DIR=${FETCHCONTENT_CACHE_DIR}" >> "$GITHUB_ENV" |
| 109 |
|
| 110 |
# vcpkg binary caching |
| 111 |
# !!!PLEASE!!! be nice and don't use this cache for your own purposes. This is only meant for CI purposes in this repository. |
| 112 |
VCPKG_BINARY_SOURCES="clear;x-azblob,https://colmap.blob.core.windows.net/github-actions-cache,sp=r&st=2024-12-10T17:29:32Z&se=2030-12-31T01:29:32Z&spr=https&sv=2022-11-02&sr=c&sig=bWydkilTMjRn3LHKTxLgdWrFpV4h%2Finzoe9QCOcPpYQ%3D,read" |
| 113 |
if [ -n "${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }}" ]; then |
| 114 |
# The secrets are only accessible in runs triggered from within the target repository and not forks. |
| 115 |
VCPKG_BINARY_SOURCES="${VCPKG_BINARY_SOURCES};x-azblob,${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }},${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_SAS }},write" |
| 116 |
fi |
| 117 |
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "$GITHUB_ENV" |
| 118 |
|
| 119 |
- name: Set env (Windows) |
| 120 |
if: runner.os == 'Windows' |
| 121 |
shell: pwsh |
| 122 |
run: | |
| 123 |
echo "${{ env.COMPILER_CACHE_DIR }}/bin" >> "${env:GITHUB_PATH}" |
| 124 |
|
| 125 |
# The Visual Studio generator ignores CMake compiler launchers. Use |
| 126 |
# Ninja for wheel builds and persist the MSVC developer environment |
| 127 |
# that Ninja needs into the following cibuildwheel step. |
| 128 |
& "./scripts/shell/enter_vs_dev_shell.ps1" |
| 129 |
echo "PATH=${env:PATH}" >> "${env:GITHUB_ENV}" |
| 130 |
echo "INCLUDE=${env:INCLUDE}" >> "${env:GITHUB_ENV}" |
| 131 |
echo "LIB=${env:LIB}" >> "${env:GITHUB_ENV}" |
| 132 |
echo "LIBPATH=${env:LIBPATH}" >> "${env:GITHUB_ENV}" |
| 133 |
|
| 134 |
$VCPKG_INSTALLATION_ROOT = "${{ github.workspace }}/vcpkg" |
| 135 |
echo "VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "${env:GITHUB_ENV}" |
| 136 |
$CMAKE_TOOLCHAIN_FILE = "${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" |
| 137 |
echo "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" >> "${env:GITHUB_ENV}" |
| 138 |
$VCPKG_TARGET_TRIPLET = "x64-windows-release" |
| 139 |
echo "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" >> "${env:GITHUB_ENV}" |
| 140 |
|
| 141 |
# Fix: cibuildhweel cannot interpolate env variables. |
| 142 |
$CMAKE_TOOLCHAIN_FILE = $CMAKE_TOOLCHAIN_FILE.replace('\', '/') |
| 143 |
$VCPKG_INSTALLED_DIR = "${{ github.workspace }}/build/vcpkg_installed" |
| 144 |
$VCPKG_INSTALLED_DIR = $VCPKG_INSTALLED_DIR.replace('\', '/') |
| 145 |
$CONFIG_SETTINGS = "cmake.define.CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" |
| 146 |
$CONFIG_SETTINGS = "${CONFIG_SETTINGS} cmake.define.VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" |
| 147 |
$CONFIG_SETTINGS = "${CONFIG_SETTINGS} cmake.define.VCPKG_INSTALLED_DIR=${VCPKG_INSTALLED_DIR}" |
| 148 |
$PYBIND11_DIR = "${env:COMPILER_CACHE_DIR}/build-requirements/pybind11/share/cmake/pybind11".replace('\', '/') |
| 149 |
$CONFIG_SETTINGS = "${CONFIG_SETTINGS} cmake.define.pybind11_DIR=${PYBIND11_DIR}" |
| 150 |
$CONFIG_SETTINGS = "${CONFIG_SETTINGS} cmake.args=-GNinja" |
| 151 |
echo "CIBW_CONFIG_SETTINGS_WINDOWS=${CONFIG_SETTINGS}" >> "${env:GITHUB_ENV}" |
| 152 |
$CCACHE_DIR = "${env:CCACHE_DIR}".replace('\', '/') |
| 153 |
$CCACHE_BASEDIR = "${env:CCACHE_BASEDIR}".replace('\', '/') |
| 154 |
$CIBW_ENVIRONMENT = "BUILD_CUDA_ENABLED=${{ matrix.config.cudaEnabled }}" |
| 155 |
$CIBW_ENVIRONMENT = "${CIBW_ENVIRONMENT} CCACHE_DIR=${CCACHE_DIR}" |
| 156 |
$CIBW_ENVIRONMENT = "${CIBW_ENVIRONMENT} CCACHE_BASEDIR=${CCACHE_BASEDIR}" |
| 157 |
$CIBW_ENVIRONMENT = "${CIBW_ENVIRONMENT} CCACHE_NOHASHDIR=${env:CCACHE_NOHASHDIR}" |
| 158 |
$CIBW_ENVIRONMENT = "${CIBW_ENVIRONMENT} CCACHE_COMPILERCHECK=${env:CCACHE_COMPILERCHECK}" |
| 159 |
$CIBW_ENVIRONMENT = "${CIBW_ENVIRONMENT} CCACHE_MAXSIZE=${env:CCACHE_MAXSIZE}" |
| 160 |
echo "CIBW_ENVIRONMENT_WINDOWS=${CIBW_ENVIRONMENT}" >> "${env:GITHUB_ENV}" |
| 161 |
$CIBW_REPAIR_WHEEL_COMMAND = "delvewheel repair -v --add-path ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin -w {dest_dir} {wheel}" |
| 162 |
echo "CIBW_REPAIR_WHEEL_COMMAND_WINDOWS=${CIBW_REPAIR_WHEEL_COMMAND}" >> "${env:GITHUB_ENV}" |
| 163 |
|
| 164 |
$FETCHCONTENT_BASE_DIR = "${env:FETCHCONTENT_CACHE_DIR}".replace('\', '/') |
| 165 |
echo "FETCHCONTENT_BASE_DIR=${FETCHCONTENT_BASE_DIR}" >> "${env:GITHUB_ENV}" |
| 166 |
|
| 167 |
# vcpkg binary caching |
| 168 |
# !!!PLEASE!!! be nice and don't use this cache for your own purposes. This is only meant for CI purposes in this repository. |
| 169 |
$VCPKG_BINARY_SOURCES = "clear;x-azblob,https://colmap.blob.core.windows.net/github-actions-cache,sp=r&st=2024-12-10T17:29:32Z&se=2030-12-31T01:29:32Z&spr=https&sv=2022-11-02&sr=c&sig=bWydkilTMjRn3LHKTxLgdWrFpV4h%2Finzoe9QCOcPpYQ%3D,read" |
| 170 |
if ("${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }}") { |
| 171 |
# The secrets are only accessible in runs triggered from within the target repository and not forks. |
| 172 |
$VCPKG_BINARY_SOURCES += ";x-azblob,${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }},${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_SAS }},write" |
| 173 |
} |
| 174 |
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "${env:GITHUB_ENV}" |
| 175 |
|
| 176 |
- name: Set env (Linux) |
| 177 |
if: runner.os == 'Linux' |
| 178 |
run: | |
| 179 |
VCPKG_TARGET_TRIPLET="x64-linux-release" |
| 180 |
echo "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" >> "$GITHUB_ENV" |
| 181 |
|
| 182 |
VCPKG_INSTALLATION_ROOT="${{ github.workspace }}/vcpkg" |
| 183 |
CMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" |
| 184 |
echo "VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV" |
| 185 |
echo "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" >> "$GITHUB_ENV" |
| 186 |
|
| 187 |
# Fix: cibuildhweel cannot interpolate env variables. |
| 188 |
CONFIG_SETTINGS="cmake.define.CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" |
| 189 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" |
| 190 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.VCPKG_INSTALLED_DIR=/project/build/vcpkg_installed" |
| 191 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.pybind11_DIR=/compiler-cache/build-requirements/pybind11/share/cmake/pybind11" |
| 192 |
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.WERROR_ENABLED=ON" |
| 193 |
echo "CIBW_CONFIG_SETTINGS_LINUX=${CONFIG_SETTINGS}" >> "$GITHUB_ENV" |
| 194 |
|
| 195 |
# Remap caching paths to the container |
| 196 |
CONTAINER_COMPILER_CACHE_DIR="/compiler-cache" |
| 197 |
CONTAINER_FETCHCONTENT_CACHE_DIR="/fetchcontent-cache" |
| 198 |
CIBW_CONTAINER_ENGINE="docker; create_args: -v ${COMPILER_CACHE_DIR}:${CONTAINER_COMPILER_CACHE_DIR} -v ${FETCHCONTENT_CACHE_DIR}:${CONTAINER_FETCHCONTENT_CACHE_DIR}" |
| 199 |
echo "CIBW_CONTAINER_ENGINE=${CIBW_CONTAINER_ENGINE}" >> "$GITHUB_ENV" |
| 200 |
echo "CONTAINER_COMPILER_CACHE_DIR=${CONTAINER_COMPILER_CACHE_DIR}" >> "$GITHUB_ENV" |
| 201 |
echo "CCACHE_DIR=${CONTAINER_COMPILER_CACHE_DIR}/ccache" >> "$GITHUB_ENV" |
| 202 |
echo "CCACHE_BASEDIR=/project" >> "$GITHUB_ENV" |
| 203 |
echo "FETCHCONTENT_BASE_DIR=${CONTAINER_FETCHCONTENT_CACHE_DIR}" >> "$GITHUB_ENV" |
| 204 |
|
| 205 |
# vcpkg binary caching |
| 206 |
# !!!PLEASE!!! be nice and don't use this cache for your own purposes. This is only meant for CI purposes in this repository. |
| 207 |
VCPKG_BINARY_SOURCES="clear;x-azblob,https://colmap.blob.core.windows.net/github-actions-cache,sp=r&st=2024-12-10T17:29:32Z&se=2030-12-31T01:29:32Z&spr=https&sv=2022-11-02&sr=c&sig=bWydkilTMjRn3LHKTxLgdWrFpV4h%2Finzoe9QCOcPpYQ%3D,read" |
| 208 |
if [ -n "${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }}" ]; then |
| 209 |
# The secrets are only accessible in runs triggered from within the target repository and not forks. |
| 210 |
VCPKG_BINARY_SOURCES="${VCPKG_BINARY_SOURCES};x-azblob,${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }},${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_SAS }},write" |
| 211 |
fi |
| 212 |
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "$GITHUB_ENV" |
| 213 |
|
| 214 |
CIBW_ENVIRONMENT_PASS_LINUX="VCPKG_TARGET_TRIPLET VCPKG_INSTALLATION_ROOT CMAKE_TOOLCHAIN_FILE VCPKG_BINARY_SOURCES CONTAINER_COMPILER_CACHE_DIR CCACHE_DIR CCACHE_BASEDIR CCACHE_NOHASHDIR CCACHE_COMPILERCHECK CCACHE_MAXSIZE FETCHCONTENT_BASE_DIR" |
| 215 |
echo "CIBW_ENVIRONMENT_PASS_LINUX=${CIBW_ENVIRONMENT_PASS_LINUX}" >> "$GITHUB_ENV" |
| 216 |
|
| 217 |
if [ "${{ matrix.config.cudaEnabled }}" = "true" ]; then |
| 218 |
CIBW_MANYLINUX_X86_64_IMAGE="pytorch/manylinux2_28-builder:cuda12.9" |
| 219 |
CIBW_REPAIR_WHEEL_COMMAND="auditwheel repair --exclude libcudart* --exclude libcurand* -w {dest_dir} {wheel}" |
| 220 |
echo "CIBW_REPAIR_WHEEL_COMMAND=${CIBW_REPAIR_WHEEL_COMMAND}" >> "$GITHUB_ENV" |
| 221 |
# Edit pyproject.toml to change package name to pycolmap-cuda12 and add CUDA Runtime native Libraries and CURAND native runtime libraries to dependencies |
| 222 |
pip install tomlkit |
| 223 |
python python/ci/update_pyproject_toml.py --name "pycolmap-cuda12" --add-deps "cuda-toolkit[cudart,curand]>=12,<13" |
| 224 |
else |
| 225 |
CIBW_MANYLINUX_X86_64_IMAGE="quay.io/pypa/manylinux_2_28_x86_64" |
| 226 |
fi |
| 227 |
|
| 228 |
echo "CIBW_MANYLINUX_X86_64_IMAGE=${CIBW_MANYLINUX_X86_64_IMAGE}" >> "$GITHUB_ENV" |
| 229 |
|
| 230 |
|
| 231 |
- name: Build wheels |
| 232 |
uses: pypa/[email protected] |
| 233 |
with: |
| 234 |
package-dir: ./ |
| 235 |
env: |
| 236 |
CIBW_ARCHS_MACOS: ${{ matrix.config.arch }} |
| 237 |
CIBW_ENVIRONMENT: > |
| 238 |
BUILD_CUDA_ENABLED=${{ matrix.config.cudaEnabled }} |
| 239 |
|
| 240 |
- name: Show compiler cache stats (Linux/macOS) |
| 241 |
if: always() && runner.os != 'Windows' |
| 242 |
shell: bash |
| 243 |
run: | |
| 244 |
if [ "${RUNNER_OS}" = "Linux" ] && [ -x "${COMPILER_CACHE_DIR}/bin/ccache" ]; then |
| 245 |
export CCACHE_DIR="${COMPILER_CACHE_DIR}/ccache" |
| 246 |
CCACHE="${COMPILER_CACHE_DIR}/bin/ccache" |
| 247 |
elif command -v ccache >/dev/null 2>&1; then |
| 248 |
CCACHE=ccache |
| 249 |
else |
| 250 |
echo "ccache is unavailable" |
| 251 |
exit 0 |
| 252 |
fi |
| 253 |
"${CCACHE}" --cleanup |
| 254 |
"${CCACHE}" --show-stats --verbose |
| 255 |
|
| 256 |
- name: Show compiler cache stats (Windows) |
| 257 |
if: always() && runner.os == 'Windows' |
| 258 |
shell: pwsh |
| 259 |
run: | |
| 260 |
$ccache = "${env:COMPILER_CACHE_DIR}/bin/ccache.exe" |
| 261 |
if (!(Test-Path -PathType Leaf $ccache)) { |
| 262 |
Write-Output "ccache is unavailable" |
| 263 |
exit 0 |
| 264 |
} |
| 265 |
& $ccache --cleanup |
| 266 |
& $ccache --show-stats --verbose |
| 267 |
|
| 268 |
- name: Archive wheels |
| 269 |
uses: actions/upload-artifact@v7 |
| 270 |
with: |
| 271 |
name: pycolmap-${{ matrix.config.os }}-${{ matrix.config.arch }}${{ matrix.config.cudaEnabled && '-CUDA' || '' }} |
| 272 |
path: wheelhouse/pycolmap*.whl |
| 273 |
|
| 274 |
- name: Save compiler cache |
| 275 |
uses: ./.github/actions/compiler-cache |
| 276 |
with: |
| 277 |
mode: save |
| 278 |
key: ${{ steps.cache-compiler.outputs.key }} |
| 279 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 280 |
cache-hit: ${{ steps.cache-compiler.outputs.cache-hit }} |
| 281 |
ccache-dir: ${{ env.COMPILER_CACHE_DIR }}/ccache |
| 282 |
|
| 283 |
pypi-publish: |
| 284 |
name: Publish wheels to PyPI |
| 285 |
needs: build |
| 286 |
runs-on: ubuntu-latest |
| 287 |
environment: |
| 288 |
name: pypi |
| 289 |
# This URL is only for display in the GitHub UI |
| 290 |
url: https://pypi.org/p/pycolmap |
| 291 |
permissions: |
| 292 |
id-token: write |
| 293 |
# We publish the wheel to pypi when a new tag is pushed, |
| 294 |
# either by creating a new GitHub release or explicitly with `git tag` |
| 295 |
if: ${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags') }} |
| 296 |
steps: |
| 297 |
- name: Download wheels |
| 298 |
uses: actions/download-artifact@v8 |
| 299 |
with: |
| 300 |
path: ./artifacts/ |
| 301 |
- name: Move wheels |
| 302 |
run: mkdir ./wheelhouse && mv ./artifacts/**/*.whl ./wheelhouse/ |
| 303 |
- name: Publish package |
| 304 |
uses: pypa/[email protected] |
| 305 |
with: |
| 306 |
skip-existing: true |
| 307 |
packages-dir: ./wheelhouse/ |
| 308 |
|
| 309 |
docs: |
| 310 |
name: Build and deploy documentation |
| 311 |
needs: build |
| 312 |
runs-on: ubuntu-24.04 |
| 313 |
steps: |
| 314 |
- uses: actions/checkout@v7 # conf.py's get_git_revision() needs a git checkout |
| 315 |
|
| 316 |
# Detect whether docs-relevant files changed (gates the deploy/preview steps). |
| 317 |
- uses: dorny/paths-filter@v3 |
| 318 |
id: filter |
| 319 |
with: |
| 320 |
filters: | |
| 321 |
docs: |
| 322 |
- 'doc/**' |
| 323 |
- 'CHANGELOG.rst' |
| 324 |
- 'python/**' # pycolmap bindings feed the autodoc API pages |
| 325 |
|
| 326 |
- uses: actions/setup-python@v5 |
| 327 |
with: |
| 328 |
python-version: '3.12' # Sphinx 9.1 needs >=3.12; matches the cp312 wheel |
| 329 |
|
| 330 |
- uses: actions/setup-node@v6 |
| 331 |
with: |
| 332 |
node-version: '24' |
| 333 |
cache: npm |
| 334 |
cache-dependency-path: doc/package-lock.json |
| 335 |
|
| 336 |
# Wheel from the `build` job (same run) so autodoc introspects a pycolmap |
| 337 |
# that matches the commit. |
| 338 |
- uses: actions/download-artifact@v8 |
| 339 |
with: |
| 340 |
name: pycolmap-ubuntu-24.04- |
| 341 |
path: wheelhouse |
| 342 |
|
| 343 |
- name: Install pycolmap + Sphinx deps |
| 344 |
run: | |
| 345 |
python -m pip install --upgrade pip |
| 346 |
pip install wheelhouse/pycolmap-*cp312*manylinux*_x86_64.whl |
| 347 |
pip install -r doc/requirements.txt |
| 348 |
|
| 349 |
- name: Install and test viewer |
| 350 |
run: | |
| 351 |
npm ci --prefix doc |
| 352 |
npm run typecheck --prefix doc |
| 353 |
python doc/tests/camera_models_registry_test.py |
| 354 |
npm test --prefix doc |
| 355 |
npx --prefix doc playwright install --with-deps chromium |
| 356 |
npm run test:browser --prefix doc |
| 357 |
|
| 358 |
- name: Build docs |
| 359 |
run: make -C doc html # -> doc/_build/html |
| 360 |
|
| 361 |
# PR dry-run: publish the generated HTML as a downloadable artifact |
| 362 |
# (no deploy) so reviewers can inspect the rendered docs. |
| 363 |
- name: Upload docs preview artifact |
| 364 |
if: github.event_name == 'pull_request' && steps.filter.outputs.docs == 'true' |
| 365 |
uses: actions/upload-artifact@v7 |
| 366 |
with: |
| 367 |
name: docs-preview |
| 368 |
path: doc/_build/html |
| 369 |
|
| 370 |
- name: Deploy to colmap.github.io |
| 371 |
if: >- |
| 372 |
github.event_name == 'push' && |
| 373 |
github.ref == 'refs/heads/main' && |
| 374 |
steps.filter.outputs.docs == 'true' |
| 375 |
uses: peaceiris/actions-gh-pages@v4 |
| 376 |
with: |
| 377 |
deploy_key: ${{ secrets.COLMAP_GITHUB_IO_DEPLOY_KEY }} |
| 378 |
external_repository: colmap/colmap.github.io |
| 379 |
publish_branch: master |
| 380 |
publish_dir: ./doc/_build/html |
| 381 |
keep_files: true |
| 382 |
commit_message: "Update docs from colmap@${{ github.sha }}" |
| 383 |
full_commit_message: "Update docs from colmap@${{ github.sha }}" |