Skip to content

Commit

Permalink
Merge pull request #27 from paulsengroup/ci/refactor
Browse files Browse the repository at this point in the history
- Build all wheels using cibuildwheels
- Build third-party libraries with static linking
- Use scikit-build-core as build backend
  • Loading branch information
robomics authored Feb 13, 2024
2 parents 78c2cfc + c795e36 commit 40152b6
Show file tree
Hide file tree
Showing 11 changed files with 731 additions and 396 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.7", "3.11"] #, 3.12
python-version: ["3.8", "3.12"]

runs-on: ${{ matrix.platform }}

Expand Down Expand Up @@ -91,7 +91,6 @@ jobs:
path: ${{ env.CONAN_HOME }}

- name: Test
if: matrix.platform != 'windows-latest'
run: python -m pytest test -v


Expand Down
156 changes: 21 additions & 135 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,169 +70,55 @@ jobs:
path: dist/*.tar.gz


build-wheels-linux:
name: Wheels on Linux
runs-on: ubuntu-latest
build-wheels:
name: Build Wheels
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04, macos-12, macos-14, windows-2019]
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
if: matrix.os == 'ubuntu-22.04'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
- name: Build wheels (PR)
uses: pypa/[email protected]
if: github.event_name == 'pull_request'
env:
CIBW_ARCHS_LINUX: x86_64

- name: Verify clean directory
run: git diff --exit-code

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: wheelhouse/*.whl

build-wheels-macos:
name: Wheels on macOS
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Generate cache key
id: cache-key
run: |
hash="${{ hashFiles('conanfile.txt') }}"
echo "conan-key=conan-macos-$hash" >> $GITHUB_OUTPUT
- name: Restore Conan cache
id: cache-conan
uses: actions/cache/restore@v4
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ARCHS_WINDOWS: "AMD64"

- name: Build wheels
uses: pypa/[email protected]
if: github.event_name != 'pull_request'
env:
MACOSX_DEPLOYMENT_TARGET: '10.15'
run: pip wheel . -vv --no-deps

- name: Save Conan cache
uses: actions/cache/save@v4
if: steps.cache-conan.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}

- name: Fix wheels
run: |
pip install delocate
CIBW_ARCHS_LINUX: "x86_64 aarch64"
CIBW_ARCHS_WINDOWS: "AMD64"

mkdir lib/
find "$CONAN_HOME/p/" -name '*.dylib' -exec cp '{}' lib/ \;
DYLD_LIBRARY_PATH="$PWD/lib/:/usr/local/lib:/usr/lib" \
delocate-wheel --check-archs -v hictkpy*.whl
- name: Test wheels
run: |
wheel=(hictkpy*.whl)
pip install "${wheel[@]}[test]"
pytest test -v
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-py${{ matrix.python-version }}
path: ./*.whl

build-wheels-windows:
name: Wheels on Windows
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ] #, '3.12' ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Generate cache key
id: cache-key
run: |
hash="${{ hashFiles('conanfile.txt') }}"
echo "conan-key=conan-windows-$hash" >> $GITHUB_OUTPUT
- name: Restore Conan cache
id: cache-conan
uses: actions/cache/restore@v4
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}

- name: Build wheels
run: pip wheel . -vv --no-deps

- name: Save Conan cache
uses: actions/cache/save@v4
if: steps.cache-conan.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}

- name: Fix wheels
run: |
pip install delvewheel
mkdir dlls/
find "$CONAN_HOME/p/" -type f -name '*.dll' -exec cp '{}' dlls/ \;
delvewheel repair --add-path ./dlls/ hictkpy*.whl
- name: Test wheels
run: |
wheel=(wheelhouse/hictkpy*.whl)
pip install "${wheel[@]}[test]"
pytest test -v
- name: Verify clean directory
run: git diff --exit-code

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-py${{ matrix.python-version }}
name: "wheels-${{ matrix.os }}"
path: wheelhouse/*.whl

package-artifacts:
name: Package artifacts
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels-linux
- build-wheels-macos
- build-wheels-windows
- build-wheels

steps:
- name: Download artifacts
Expand Down
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ FetchContent_Declare(
URL_HASH "SHA256=c003924e92a9957a0cf43b85ae9ede29392be5227f427ca2fab9e420ea8217c9"
SYSTEM)

set(BUILD_SHARED_LIBS ON)
set(HICTK_ENABLE_TESTING OFF)
set(HICTK_BUILD_EXAMPLES OFF)
set(HICTK_BUILD_BENCHMARKS OFF)
Expand All @@ -50,13 +49,13 @@ endif()

add_library(hictkpy_project_warnings INTERFACE)
target_compile_options(
hictkpy_project_warnings
INTERFACE # C++ warnings
$<$<COMPILE_LANGUAGE:CXX>:${HICTKPY_PROJECT_WARNINGS_CXX}>
# C warnings
$<$<COMPILE_LANGUAGE:C>:${HICTKPY_PROJECT_WARNINGS_C}>
# Cuda warnings
$<$<COMPILE_LANGUAGE:CUDA>:${HICTKPY_PROJECT_WARNINGS_CUDA}>)
hictkpy_project_warnings
INTERFACE # C++ warnings
$<$<COMPILE_LANGUAGE:CXX>:${HICTKPY_PROJECT_WARNINGS_CXX}>
# C warnings
$<$<COMPILE_LANGUAGE:C>:${HICTKPY_PROJECT_WARNINGS_C}>
# Cuda warnings
$<$<COMPILE_LANGUAGE:CUDA>:${HICTKPY_PROJECT_WARNINGS_CUDA}>)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
Expand Down
Loading

0 comments on commit 40152b6

Please sign in to comment.