Skip to content

Commit

Permalink
stable ABI support
Browse files Browse the repository at this point in the history
  • Loading branch information
dvicini committed Dec 25, 2024
1 parent 775033f commit b99c800
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
python: [cp38, cp39, cp310, cp311, cp312, cp313]
python: [cp38, cp39, cp310, cp311, cp312, cp312_stable, cp313]
exclude:
# The first Python version to target Apple arm64 architectures is 3.9
- os: macos-14
Expand Down Expand Up @@ -56,14 +56,14 @@ jobs:
run: |
stable_cp=$(echo ${{ matrix.python }} | cut -d_ -f1) &&
echo "CIBW_BUILD=${stable_cp}-*" >> $GITHUB_ENV &&
echo "CIBW_CONFIG_SETTINGS=\"wheel.py-api=cp312\" \"cmake.args=-DDRJIT_STABLE_ABI=ON\"" >> $GITHUB_ENV
echo "CIBW_CONFIG_SETTINGS=\"wheel.py-api=cp312\" \"cmake.args=-DFASTSWEEP_STABLE_ABI=ON\"" >> $GITHUB_ENV
- name: Prepare cibuildwheel environment for stable ABI wheel (Windows)
if: ${{ endsWith(matrix.python, '_stable') && runner.os == 'Windows' }}
run: |
$stable_cp = '${{ matrix.python }}' -split '_'
echo "CIBW_BUILD=$($stable_cp[0])-*" >> $env:GITHUB_ENV
echo "CIBW_CONFIG_SETTINGS=wheel.py-api=cp312 cmake.args=-DDRJIT_STABLE_ABI=ON" >> $env:GITHUB_ENV
echo "CIBW_CONFIG_SETTINGS=wheel.py-api=cp312 cmake.args=-DFASTSWEEP_STABLE_ABI=ON" >> $env:GITHUB_ENV
#########################
# Build and store wheels
Expand Down
27 changes: 23 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15...3.19)

project(fastsweep DESCRIPTION "Fast sweep solver")

option(FASTWEEPING_USE_CUDA "Use high-performance CUDA kernels instead of
Dr.Jit's GPU mode" ON)
option(FASTSWEEP_USE_CUDA "Use high-performance CUDA kernels instead of
Dr.Jit's GPU mode" ON)
option(FASTSWEEP_STABLE_ABI "Build Python extension using the CPython stable ABI?
(Only relevant when using scikit-build)" OFF)
mark_as_advanced(FASTSWEEP_STABLE_ABI)

if (NOT SKBUILD)
message(WARNING "\
Expand Down Expand Up @@ -49,11 +52,27 @@ endif()
list(APPEND CMAKE_PREFIX_PATH "${FASTSWEEP_DRJIT_CMAKE_DIR}")
find_package(drjit CONFIG REQUIRED)

if (FASTWEEPING_USE_CUDA)
if (FASTSWEEP_USE_CUDA)
add_definitions(-DFASTSWEEPING_USE_CUDA)
endif()

nanobind_add_module(fastsweep_ext NB_DOMAIN drjit NB_STATIC src/main.cpp src/distance_marcher.cpp)
if (SKBUILD)
# Enable LTO only for release builds targeting PyPI (~5% binary size reduction)
set(FASTSWEEP_DIST_FLAGS LTO)
if (FASTSWEEP_STABLE_ABI)
list(APPEND FASTSWEEP_DIST_FLAGS STABLE_ABI)
endif()
endif()

nanobind_add_module(
fastsweep_ext
NB_DOMAIN
drjit
NB_STATIC
${FASTSWEEP_DIST_FLAGS}
src/main.cpp
src/distance_marcher.cpp
)

target_link_libraries(fastsweep_ext PUBLIC drjit-core)
target_compile_features(fastsweep_ext PRIVATE cxx_std_17)
Expand Down

0 comments on commit b99c800

Please sign in to comment.