-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from AppliedMathematicsANU/scikit_build_with_vcpkg
Build using scikit-build and cmake vcpkg. Let's vcpkg take care of the embree3 dependency.
- Loading branch information
Showing
11 changed files
with
393 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Python Test (vcpkg build) | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
|
||
python: | ||
name: ${{ github.workflow }} Python package on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ["3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Install OS tools | ||
shell: bash | ||
run: | | ||
if [ "$RUNNER_OS" == "macOS" ]; then | ||
brew install autoconf automake libtool | ||
fi | ||
- uses: lukka/get-cmake@latest | ||
name: Install cmake and ninja (via get-cmake) | ||
|
||
- name: Dump the content of $RUNNER_TEMP | ||
run: find $RUNNER_TEMP | ||
shell: bash | ||
- name: Dump the content of $RUNNER_WORKSPACE | ||
run: find $RUNNER_WORKSPACE | ||
shell: bash | ||
|
||
- name: Restore artifacts, or setup vcpkg for building artifacts | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
# This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch. | ||
vcpkgDirectory: '${{ runner.workspace }}/vcpkg' | ||
# The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule. | ||
vcpkgGitCommitId: "c8696863d371ab7f46e213d8f5ca923c4aef2a00" | ||
# The vcpkg.json file, which will be part of cache key computation. | ||
vcpkgJsonGlob: '**/vcpkg.json' | ||
id: runvcpkg | ||
|
||
- name: Prints output of run-vcpkg's action. | ||
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}' " | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install python dependencies | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install cmake setuptools scikit-build wheel 'versioneer[toml]' | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Build and install with pip | ||
env: | ||
VCPKG_ROOT: ${{ runner.workspace }}/vcpkg | ||
run: python -m pip install --user ${{ github.workspace }} | ||
|
||
- name: Debug pyemblite install | ||
shell: bash | ||
run: | | ||
cd ~ | ||
echo $(pwd) | ||
python -c 'import os; import pyemblite; print(os.listdir(os.path.dirname(pyemblite.__file__)))' | ||
python -c 'import pyemblite; print(f"pyemblite.__file__={pyemblite.__file__}"); print(dir(pyemblite))' | ||
- name: Test | ||
shell: bash | ||
run: | | ||
cd ~ | ||
python -m pyemblite.test -fv |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
name: Python Wheels (vcpkg build) | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
jobs: | ||
|
||
build_wheels: | ||
name: ${{ github.workflow }} Python build wheel on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ["3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install OS tools | ||
shell: bash | ||
run: | | ||
if [ "$RUNNER_OS" == "macOS" ]; then | ||
brew install autoconf automake libtool | ||
fi | ||
- uses: lukka/get-cmake@latest | ||
name: Install cmake and ninja (via get-cmake) | ||
|
||
- name: Restore artifacts, or setup vcpkg for building artifacts | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
# This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch. | ||
vcpkgDirectory: '${{ runner.workspace }}/vcpkg' | ||
# The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule. | ||
vcpkgGitCommitId: "c8696863d371ab7f46e213d8f5ca923c4aef2a00" | ||
# The vcpkg.json file, which will be part of cache key computation. | ||
vcpkgJsonGlob: '**/vcpkg.json' | ||
id: runvcpkg | ||
|
||
- name: Prints output of run-vcpkg's action. | ||
run: | | ||
echo "VCPKG_ROOT=${VCPKG_ROOT}" | ||
echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}' " | ||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install cibuildwheel | ||
run: python -m pip install cibuildwheel==2.16.2 | ||
|
||
- name: Build wheels | ||
shell: bash | ||
run: | | ||
echo "VCPKG_ROOT=${VCPKG_ROOT}" | ||
python -m cibuildwheel --output-dir wheelhouse | ||
env: | ||
CIBW_ENVIRONMENT_LINUX: "CMAKE_FETCH_VCPKG=ON" | ||
# vcpkg does not support i686 nor aarch64 | ||
CIBW_ARCHS: "auto64" | ||
# Skip musllinux builds | ||
CIBW_SKIP: "*-musllinux_*" | ||
# CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" | ||
CIBW_BUILD: "cp310-*" | ||
# Don't repair macOS wheels | ||
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" | ||
CIBW_BEFORE_BUILD_WINDOWS: "python -m pip install cmake" | ||
CIBW_BEFORE_ALL_LINUX: "/usr/bin/yum install --assumeyes --verbose zip unzip tar cmake" | ||
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28" | ||
# Run the package tests using `pytest` | ||
CIBW_TEST_COMMAND: "python -m pyemblite.test -fv" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
# name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
name: cibw-wheels-${{ matrix.os }} | ||
path: ./wheelhouse/*.whl | ||
retention-days: 10 | ||
|
||
build_sdist: | ||
name: Build python sdist | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: lukka/get-cmake@latest | ||
name: Install cmake and ninja (via get-cmake) | ||
|
||
- name: Restore artifacts, or setup vcpkg for building artifacts | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
# This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch. | ||
vcpkgDirectory: '${{ runner.workspace }}/vcpkg' | ||
# The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule. | ||
vcpkgGitCommitId: "c8696863d371ab7f46e213d8f5ca923c4aef2a00" | ||
# The vcpkg.json file, which will be part of cache key computation. | ||
vcpkgJsonGlob: '**/vcpkg.json' | ||
id: runvcpkg | ||
|
||
- name: Prints output of run-vcpkg's action. | ||
run: | | ||
echo "VCPKG_ROOT=${VCPKG_ROOT}" | ||
echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}' " | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install sdist build dependencies | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install "setuptools>=42" "versioneer[toml]" "scikit-build" "cmake" "ninja" | ||
- name: Create python sdist | ||
run: python setup.py sdist --formats=gztar,zip | ||
|
||
- name: Upload python sdist | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-sdist | ||
path: ./dist/* | ||
|
||
release: | ||
name: Make a Release | ||
needs: [build_sdist, build_wheels] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Download python sdist and wheels | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: cibw-* | ||
path: ./release_artifacts/ | ||
merge-multiple: true | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: ./release_artifacts/* |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.project | ||
.pydevproject | ||
build | ||
_skbuild | ||
dist | ||
pyemblite.egg-info | ||
pyemblite/*.c | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 3.21) | ||
|
||
IF (NOT CMAKE_BUILD_TYPE) | ||
SET(CMAKE_BUILD_TYPE Release) | ||
ENDIF() | ||
|
||
if(DEFINED CMAKE_TOOLCHAIN_FILE) # Print toolchain information | ||
message(STATUS "Using toolchain: ${CMAKE_TOOLCHAIN_FILE}") | ||
elseif(DEFINED ENV{CMAKE_TOOLCHAIN_FILE}) | ||
message(STATUS "Using toolchain: $ENV{CMAKE_TOOLCHAIN_FILE}") | ||
set(CMAKE_TOOLCHAIN_FILE | ||
"$ENV{CMAKE_TOOLCHAIN_FILE}" | ||
CACHE FILEPATH "" | ||
) | ||
elseif(DEFINED ENV{VCPKG_ROOT}) | ||
message(STATUS "Using vcpkg installed in $ENV{VCPKG_ROOT}") | ||
set(CMAKE_TOOLCHAIN_FILE | ||
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" | ||
CACHE FILEPATH "" | ||
) | ||
elseif(CMAKE_FETCH_VCPKG OR DEFINED ENV{CMAKE_FETCH_VCPKG}) | ||
message(STATUS "Fetching vcpkg") | ||
include(FetchContent) | ||
FetchContent_Declare(vcpkg | ||
GIT_REPOSITORY https://github.com/microsoft/vcpkg/ | ||
GIT_TAG 2023.12.12 | ||
) | ||
FetchContent_MakeAvailable(vcpkg) | ||
set(CMAKE_TOOLCHAIN_FILE | ||
"${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" | ||
CACHE FILEPATH "" | ||
) | ||
message(STATUS "Fetching vcpkg -- done") | ||
else() | ||
message(STATUS "No VCPKG_ROOT or CMAKE_TOOLCHAIN_FILE defined, skipping vcpkg use.") | ||
endif() | ||
|
||
enable_language(CXX) | ||
|
||
MESSAGE(STATUS "Finding Python...") | ||
FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module REQUIRED) | ||
MESSAGE(STATUS "Finding Cython...") | ||
FIND_PACKAGE(Cython REQUIRED) | ||
MESSAGE(STATUS "Finding NumPy...") | ||
FIND_PACKAGE(NumPy REQUIRED) | ||
MESSAGE(STATUS "Finding embree3...") | ||
find_package(embree 3 CONFIG REQUIRED) | ||
MESSAGE(STATUS "Finding PythonExtensions...") | ||
SET(Python_ADDITIONAL_VERSIONS "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") | ||
FIND_PACKAGE(PythonExtensions REQUIRED) | ||
|
||
PROJECT(pyemblite) | ||
|
||
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) | ||
INCLUDE_DIRECTORIES(${NumPy_INCLUDE_DIRS}) | ||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pyemblite) | ||
|
||
MESSAGE(STATUS "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") | ||
|
||
SET( | ||
PYTHON_SITE_PACKAGES_INSTALL_DIR | ||
${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages | ||
) | ||
SET( | ||
PCSR_PYTHON_SITE_PACKAGES_INSTALL_DIR | ||
${PYTHON_SITE_PACKAGES_INSTALL_DIR}/pcsr | ||
) | ||
|
||
IF (DEFINED VCPKG_INSTALLED_DIR) | ||
# List `vcpkg` dependencies from VCPKG_INSTALLED_DIR so we can install them | ||
# together with the python API. | ||
FILE( | ||
GLOB VCPKG_DEPENDENCIES | ||
RELATIVE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/" | ||
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/*" | ||
) | ||
ENDIF() | ||
|
||
foreach (cymod rtcore rtcore_scene mesh_construction test_scene) | ||
add_cython_target(${cymod} pyemblite/${cymod}.pyx) | ||
add_library(${cymod} MODULE ${cymod}) | ||
PYTHON_EXTENSION_MODULE(${cymod}) | ||
target_link_libraries(${cymod} embree) | ||
INSTALL( | ||
TARGETS ${cymod} | ||
RUNTIME_DEPENDENCIES | ||
PRE_INCLUDE_REGEXES ${VCPKG_DEPENDENCIES} | ||
PRE_EXCLUDE_REGEXES ".*" | ||
DESTINATION pyemblite | ||
) | ||
endforeach() | ||
|
Oops, something went wrong.