Skip to content

Commit fad5aad

Browse files
authored
Convert build system to scikit-build-core (#22)
* Convert build system to scikit-build-core - Replace meson files with cmake - Build a stand-alone compiled library and header which are installed to python environment lib / include dirs - Update test and wheel matrix to include python-3.14 and drop support for python-3.9 * Restore workaround for Python.h include of crypt.h * Bump manylinux docker version * Fix wheel builds * create compiled test * Move verify function into tests * generate version with setuptools_scm. Propagate that to python and C. * Fix sdist exclusion * Add flacarray_config script * Add external C link test. Update generation of the flacarray_config script * Update docs. Fix flacarray_config and cmake tests. * Revert tweak to conditional thread use * Small tweaks to the compiled test program * Fix message typo * Enable rebuild on import for editable installs * Add new unit tests for arbitrary custom MPI distribution on load in conjunction with a keep array. Fix corner case typo that caused these to fail. * Clean up flacarray_config and Findflacarray.cmake macro * Add sdist to wheel upload. Bump artifact action versions.
1 parent bfe8738 commit fad5aad

50 files changed

Lines changed: 1993 additions & 445 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,10 @@ jobs:
5555
&& popd >/dev/null 2>&1
5656
5757
- name: Install Docs Dependencies
58-
# AttributeError: 'MathBlockParser' object has no attribute 'parse_axt_heading'
59-
# https://github.com/jupyter/nbconvert/issues/2198
60-
# mistune = "<3.1"
6158
run: |
6259
source ~/conda/etc/profile.d/conda.sh \
6360
&& conda activate docs \
64-
&& conda install --yes \
65-
mkdocs \
66-
mkdocstrings \
67-
mkdocstrings-python \
68-
mkdocs-material \
69-
mkdocs-material-extensions \
70-
mkdocs-jupyter \
71-
"mistune<3.1" \
72-
&& pip install mkdocs-print-site-plugin \
61+
&& ./docs/install_requirements.sh \
7362
&& git config user.name 'github-actions[bot]' \
7463
&& git config user.email 'github-actions[bot]@users.noreply.github.com'
7564

.github/workflows/test.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ jobs:
2929
matrix:
3030
include:
3131
- os: ubuntu-latest
32-
python: "3.9"
32+
python: "3.10"
3333
arch: Linux-x86_64
3434
ompdisable: 0
3535
- os: ubuntu-latest
36-
python: "3.11"
36+
python: "3.12"
3737
arch: Linux-x86_64
3838
ompdisable: 0
3939
- os: ubuntu-latest
40-
python: "3.13"
40+
python: "3.14"
4141
arch: Linux-x86_64
4242
ompdisable: 0
43-
- os: macos-latest
43+
- os: macos-15-intel
4444
python: "3.10"
4545
arch: MacOSX-x86_64
4646
ompdisable: 1
47-
- os: macos-latest
47+
- os: macos-15-intel
4848
python: "3.13"
4949
arch: MacOSX-x86_64
5050
ompdisable: 1
51-
- os: macos-latest
51+
- os: macos-15
5252
python: "3.10"
5353
arch: MacOSX-arm64
5454
ompdisable: 1
55-
- os: macos-latest
55+
- os: macos-15
5656
python: "3.13"
5757
arch: MacOSX-arm64
5858
ompdisable: 1
@@ -85,7 +85,7 @@ jobs:
8585
&& conda create --yes -n test python==${{ matrix.python }} \
8686
&& conda activate test \
8787
&& conda install --yes --file packaging/conda_build_requirements.txt
88-
if test ${{ matrix.python }} = "3.9"; then conda install libxcrypt; fi
88+
if test ${{ matrix.python }} = "3.10"; then conda install libxcrypt; fi
8989
9090
- name: Install
9191
run: |
@@ -123,3 +123,21 @@ jobs:
123123
&& pushd test >/dev/null 2>&1 \
124124
&& mpirun -np 2 python -m mpi4py -c 'import flacarray.tests; flacarray.tests.run()' \
125125
&& popd >/dev/null 2>&1
126+
127+
- name: External C Link Tests (Dynamic)
128+
run: |
129+
source ~/conda/etc/profile.d/conda.sh \
130+
&& conda activate test \
131+
&& export OMP_NUM_THREADS=2 \
132+
&& cmake -S packaging/test_c_link -B build_c_link \
133+
&& cmake --build build_c_link \
134+
&& ctest --test-dir build_c_link
135+
136+
- name: External C Link Tests (Static)
137+
run: |
138+
source ~/conda/etc/profile.d/conda.sh \
139+
&& conda activate test \
140+
&& export OMP_NUM_THREADS=2 \
141+
&& cmake -S packaging/test_c_link -B build_c_link_static \
142+
&& cmake --build build_c_link_static \
143+
&& ctest --test-dir build_c_link_static

.github/workflows/wheels.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14+
build_sdist:
15+
name: Build source distribution
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
persist-credentials: false
21+
22+
- name: Build sdist
23+
run: pipx run build --sdist
24+
25+
- uses: actions/upload-artifact@v7
26+
with:
27+
name: cibw-sdist
28+
path: dist/*.tar.gz
29+
1430
build_wheels:
1531
name: Build wheel for cp${{ matrix.python }}-${{ matrix.builder }}_${{ matrix.arch }}
1632
runs-on: ${{ matrix.os }}
@@ -21,10 +37,6 @@ jobs:
2137
matrix:
2238
include:
2339
# Linux 64 bit manylinux
24-
- os: ubuntu-latest
25-
arch: x86_64
26-
python: 39
27-
builder: manylinux
2840
- os: ubuntu-latest
2941
arch: x86_64
3042
python: 310
@@ -41,48 +53,54 @@ jobs:
4153
arch: x86_64
4254
python: 313
4355
builder: manylinux
56+
- os: ubuntu-latest
57+
arch: x86_64
58+
python: 314
59+
builder: manylinux
4460

45-
# MacOS x86_64. The macos-13 runner is the last
46-
# Intel-based runner version. At some point we'll
47-
# need to switch to macos-latest and test cross compiling.
48-
- os: macos-13
61+
# MacOS x86_64.
62+
- os: macos-15-intel
4963
arch: x86_64
5064
python: 310
5165
builder: macosx
52-
- os: macos-13
66+
- os: macos-15-intel
5367
arch: x86_64
5468
python: 311
5569
builder: macosx
56-
- os: macos-13
70+
- os: macos-15-intel
5771
arch: x86_64
5872
python: 312
5973
builder: macosx
60-
- os: macos-13
74+
- os: macos-15-intel
6175
arch: x86_64
6276
python: 313
6377
builder: macosx
6478

6579
# MacOS arm64
66-
- os: macos-latest
80+
- os: macos-15
6781
arch: arm64
6882
python: 310
6983
builder: macosx
70-
- os: macos-latest
84+
- os: macos-15
7185
arch: arm64
7286
python: 311
7387
builder: macosx
74-
- os: macos-latest
88+
- os: macos-15
7589
arch: arm64
7690
python: 312
7791
builder: macosx
78-
- os: macos-latest
92+
- os: macos-15
7993
arch: arm64
8094
python: 313
8195
builder: macosx
96+
- os: macos-15
97+
arch: arm64
98+
python: 314
99+
builder: macosx
82100
env:
83101
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.builder }}_${{ matrix.arch }}
84-
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.builder }}2014
85-
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.builder }}2014
102+
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.builder }}_2_28
103+
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.builder }}_2_28
86104
CIBW_BUILD_VERBOSITY: 3
87105
CIBW_ENVIRONMENT_LINUX: >
88106
CC=gcc
@@ -100,19 +118,19 @@ jobs:
100118
- uses: actions/setup-python@v6
101119
name: Install Python
102120
with:
103-
python-version: '3.11'
121+
python-version: '3.13'
104122

105123
- name: Install cibuildwheel
106124
run: |
107-
python -m pip install cibuildwheel==2.22.0
125+
python -m pip install cibuildwheel==3.3.1
108126
109127
- name: Build wheel
110128
run: |
111129
python -m cibuildwheel --output-dir wheelhouse
112130
113-
- uses: actions/upload-artifact@v6
131+
- uses: actions/upload-artifact@v7
114132
with:
115-
name: flacarray-cp${{ matrix.python }}-${{ matrix.builder }}_${{ matrix.arch }}
133+
name: cibw-wheels_cp${{ matrix.python }}-${{ matrix.builder }}_${{ matrix.arch }}
116134
path: ./wheelhouse/flacarray*cp${{ matrix.python }}-${{ matrix.builder }}*${{ matrix.arch }}*.whl
117135

118136
upload_pypi:
@@ -122,10 +140,10 @@ jobs:
122140
id-token: write
123141
if: github.event_name == 'release' && github.event.action == 'published'
124142
steps:
125-
- uses: actions/download-artifact@v7
143+
- uses: actions/download-artifact@v8
126144
with:
127145
# Unpacks all artifacts into dist/
128-
pattern: flacarray-*
146+
pattern: cibw-*
129147
path: dist
130148
merge-multiple: true
131149

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Generated files
2+
src/flacarray/_version.py
3+
src/flacarray/libflacarray/version.c
4+
15
# Byte-compiled / optimized / DLL files
26
__pycache__/
37
*.py[cod]

CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
# Warn if the user invokes CMake directly
4+
if (NOT SKBUILD)
5+
message(WARNING "\
6+
This CMake file is meant to be executed using 'scikit-build-core'.
7+
Running it directly will almost certainly not produce the desired
8+
result. If you are a user trying to install this package, use the
9+
command below, which will install all necessary build dependencies,
10+
compile the package in an isolated environment, and then install it.
11+
12+
$ pip install .
13+
14+
")
15+
endif()
16+
17+
message(STATUS "CMAKE_BUILD_TYPE set to '${CMAKE_BUILD_TYPE}'")
18+
19+
# Auxiliary files
20+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
21+
22+
# Define the project with name and version from pyproject.toml
23+
project(${SKBUILD_PROJECT_NAME} LANGUAGES C VERSION ${SKBUILD_PROJECT_VERSION})
24+
25+
# We are building libraries that will eventually be linked into shared
26+
# modules. All code should be built with PIC.
27+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
28+
29+
# Use modern C
30+
set(CMAKE_C_STANDARD 11)
31+
32+
# For installing the stand-alone library and header
33+
include(GNUInstallDirs)
34+
35+
# OpenMP
36+
if(NOT DISABLE_OPENMP)
37+
find_package(OpenMP)
38+
endif()
39+
40+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
41+
include(UseCython)
42+
43+
execute_process(
44+
COMMAND "${Python_EXECUTABLE}" -c "import numpy; print(numpy.get_include(), end='')"
45+
OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
46+
)
47+
48+
find_package(FLAC REQUIRED)
49+
50+
if(DEFINED FLAC_VERSION)
51+
if(FLAC_VERSION STREQUAL "")
52+
message(STATUS "Cannot determine FLAC version- assuming it is >= 1.4.0")
53+
else()
54+
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\..*" "\\1"
55+
FLAC_MAJ_VERSION "${FLAC_VERSION}")
56+
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\..*" "\\1"
57+
FLAC_MIN_VERSION "${FLAC_VERSION}")
58+
if(FLAC_MAJ_VERSION GREATER 1)
59+
# Future proofing
60+
message(STATUS "Found FLAC version ${FLAC_VERSION}")
61+
else()
62+
if(FLAC_MIN_VERSION GREATER_EQUAL 4)
63+
message(STATUS "Found FLAC version ${FLAC_VERSION}")
64+
else()
65+
message(FATAL_ERROR "FLAC version ${FLAC_VERSION} is not >= 1.4.0")
66+
endif()
67+
endif()
68+
endif()
69+
else()
70+
message(STATUS "Cannot determine FLAC version- assuming it is >= 1.4.0")
71+
endif()
72+
73+
add_subdirectory(src)

MANIFEST.in

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)