Skip to content

Commit 37883ed

Browse files
Merge pull request #113 from IntelPython/build-with-meson
Move build system to `meson-python`
2 parents d061d8f + 8a260b4 commit 37883ed

21 files changed

Lines changed: 490 additions & 274 deletions

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
4545
shell: bash -l {0}
4646
run: |
47-
pip install numpy cython setuptools">=77" scikit-build cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
47+
pip install meson-python ninja cython cmake numpy sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
4848
- name: Checkout repo
4949
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5050
with:

.github/workflows/build-with-clang.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16-
numpy_version: ["numpy>=2"]
16+
numpy_version: ["'numpy>=2'"]
1717
env:
1818
ONEAPI_ROOT: /opt/intel/oneapi
1919

@@ -38,7 +38,6 @@ jobs:
3838
- name: Install Intel OneAPI
3939
run: |
4040
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp
41-
sudo apt-get install intel-oneapi-tbb
4241
sudo apt-get install intel-oneapi-mkl-devel
4342
4443
- name: Setup Python
@@ -54,8 +53,8 @@ jobs:
5453

5554
- name: Install mkl_random dependencies
5655
run: |
57-
pip install cython setuptools">=77"
58-
pip install "${{ matrix.numpy_version }}"
56+
pip install meson-python ninja cython cmake
57+
pip install ${{ matrix.numpy_version }}
5958
6059
- name: List oneAPI folder content
6160
run: ls "${{ env.ONEAPI_ROOT }}/compiler"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build project with standard clang compiler
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
permissions: read-all
9+
10+
jobs:
11+
build-with-standard-clang:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
17+
numpy_version: ["'numpy>=2'"]
18+
19+
env:
20+
COMPILER_ROOT: /usr/bin
21+
22+
defaults:
23+
run:
24+
shell: bash -el {0}
25+
26+
steps:
27+
- name: Cancel Previous Runs
28+
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
29+
with:
30+
access_token: ${{ github.token }}
31+
32+
- name: Install Dependencies
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y clang
36+
37+
- name: Setup Python
38+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
39+
with:
40+
python-version: ${{ matrix.python }}
41+
architecture: x64
42+
43+
- name: Checkout repo
44+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Install mkl_random dependencies
49+
run: |
50+
pip install meson-python ninja cmake cython mkl-devel
51+
pip install ${{ matrix.numpy_version }}
52+
53+
- name: Build mkl_random
54+
run: |
55+
export CC=${{ env.COMPILER_ROOT }}/clang
56+
export CXX=${{ env.COMPILER_ROOT }}/clang++
57+
pip install -e . --no-build-isolation --no-deps --verbose
58+
59+
- name: Run mkl_random tests
60+
run: |
61+
pip install pytest
62+
python -m pytest -sv --pyargs mkl_random

.github/workflows/build_pip.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Editable build using pip and pre-release NumPy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash -el {0}
17+
18+
strategy:
19+
matrix:
20+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
21+
use_pre: ["", "--pre"]
22+
23+
steps:
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
fetch-depth: 0
27+
28+
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
29+
with:
30+
miniforge-version: latest
31+
channels: conda-forge
32+
activate-environment: test
33+
python-version: ${{ matrix.python }}
34+
35+
- name: Install MKL
36+
run: |
37+
conda install mkl-devel
38+
39+
- name: Build with pip
40+
run: |
41+
pip install --no-cache-dir meson-python ninja cmake cython
42+
pip install --no-cache-dir numpy ${{ matrix.use_pre }}
43+
pip install -e . --no-build-isolation --no-deps --verbose
44+
pip install --no-cache-dir pytest
45+
pip list
46+
python -m pytest -v mkl_random/tests

.github/workflows/conda-package-cf.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,157 @@ jobs:
323323
run: |
324324
conda activate ${{ env.TEST_ENV_NAME }}
325325
pytest -v --pyargs ${{ env.MODULE_NAME }}
326+
327+
build_osx:
328+
runs-on: macos-26-intel
329+
strategy:
330+
matrix:
331+
include:
332+
- python: "3.10"
333+
numpy: "2.2"
334+
- python: "3.11"
335+
numpy: "2.3"
336+
- python: "3.12"
337+
numpy: "2.3"
338+
- python: "3.13"
339+
numpy: "2.3"
340+
- python: "3.14"
341+
numpy: "2.3"
342+
343+
steps:
344+
- name: Cancel Previous Runs
345+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # v0.13.1
346+
with:
347+
access_token: ${{ github.token }}
348+
349+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
350+
with:
351+
fetch-depth: 0
352+
353+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
354+
with:
355+
miniforge-version: latest
356+
activate-environment: build
357+
channels: conda-forge
358+
python-version: ${{ matrix.python }}
359+
360+
- name: Cache conda packages
361+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
362+
env:
363+
CACHE_NUMBER: 0 # Increase to reset cache
364+
with:
365+
path: /Users/runner/conda_pkgs_dir
366+
key:
367+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
368+
restore-keys: |
369+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
370+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
371+
372+
- name: Install conda-build
373+
shell: bash -el {0}
374+
run: |
375+
conda install -n base -y conda-build
376+
conda list -n base
377+
378+
- name: Store conda paths as envs
379+
shell: bash -el {0}
380+
run: |
381+
echo "CONDA_BLD=$CONDA/conda-bld/osx-64/" >> "$GITHUB_ENV"
382+
383+
- name: Build conda package
384+
shell: bash -el {0}
385+
run: |
386+
CHANNELS=(-c conda-forge --override-channels)
387+
VERSIONS=(--python "${{ matrix.python }}" --numpy "${{ matrix.numpy }}")
388+
TEST=(--no-test)
389+
390+
conda build \
391+
"${TEST[@]}" \
392+
"${VERSIONS[@]}" \
393+
"${CHANNELS[@]}" \
394+
conda-recipe-cf
395+
396+
- name: Upload artifact
397+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
398+
with:
399+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
400+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
401+
402+
test_osx:
403+
needs: build_osx
404+
runs-on: macos-26-intel
405+
strategy:
406+
matrix:
407+
include:
408+
- python: "3.10"
409+
numpy: "2.2"
410+
- python: "3.11"
411+
numpy: "2.3"
412+
- python: "3.12"
413+
numpy: "2.3"
414+
- python: "3.13"
415+
numpy: "2.3"
416+
- python: "3.14"
417+
numpy: "2.3"
418+
419+
steps:
420+
- name: Download artifact
421+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
422+
with:
423+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
424+
425+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
426+
with:
427+
miniforge-version: latest
428+
channels: conda-forge
429+
activate-environment: base
430+
431+
- name: Install conda-index
432+
shell: bash -el {0}
433+
run: conda install -n base -y conda-index
434+
435+
- name: Create conda channel
436+
shell: bash -el {0}
437+
run: |
438+
mkdir -p "$GITHUB_WORKSPACE/channel/osx-64"
439+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
440+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/osx-64" || exit 1
441+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
442+
# Test channel
443+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
444+
cat ver.json
445+
446+
- name: Collect dependencies
447+
shell: bash -el {0}
448+
run: |
449+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
450+
export PACKAGE_VERSION
451+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels --only-deps --dry-run > lockfile
452+
cat lockfile
453+
454+
- name: Cache conda packages
455+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
456+
env:
457+
CACHE_NUMBER: 0 # Increase to reset cache
458+
with:
459+
path: /Users/runner/conda_pkgs_dir
460+
key:
461+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
462+
restore-keys: |
463+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
464+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
465+
466+
- name: Install mkl_random
467+
shell: bash -el {0}
468+
run: |
469+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
470+
export PACKAGE_VERSION
471+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" pytest "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels
472+
# Test installed packages
473+
conda list -n "${{ env.TEST_ENV_NAME }}"
474+
475+
- name: Run tests
476+
shell: bash -el {0}
477+
run: |
478+
conda activate ${{ env.TEST_ENV_NAME }}
479+
pytest -vv --pyargs ${{ env.MODULE_NAME }}

.github/workflows/coverity.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,15 @@ jobs:
5050
architecture: x64
5151

5252
- name: Install build dependencies
53-
run: pip install cython "setuptools>=77" "numpy>=2" mkl-devel
54-
55-
- name: Export MKLROOT
56-
run: |
57-
# mkl-devel installs mkl.h + libmkl_rt into the Python prefix.
58-
MKLROOT="$(python -c 'import sys; print(sys.prefix)')"
59-
if [ ! -f "${MKLROOT}/include/mkl.h" ]; then
60-
echo "::error::mkl.h not found under ${MKLROOT}; mkl-devel did not install as expected."
61-
exit 1
62-
fi
63-
# The wheel ships only the versioned libmkl_rt.so.3, not the bare
64-
# linker name, so `g++ -lmkl_rt` fails until we add the symlink.
65-
if [ ! -e "${MKLROOT}/lib/libmkl_rt.so" ]; then
66-
rt_so=("${MKLROOT}/lib/"libmkl_rt.so.*)
67-
if [ ! -e "${rt_so[0]}" ]; then
68-
echo "::error::libmkl_rt.so.* not found under ${MKLROOT}/lib."
69-
exit 1
70-
fi
71-
ln -s "${rt_so[0]}" "${MKLROOT}/lib/libmkl_rt.so"
72-
fi
73-
echo "MKLROOT=${MKLROOT}" >> "$GITHUB_ENV"
74-
# Only append the inherited value when it is non-empty: a trailing (or
75-
# leading) empty element in LD_LIBRARY_PATH means "current directory"
76-
# to the loader, which is an unwanted search path.
77-
echo "LD_LIBRARY_PATH=${MKLROOT}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> "$GITHUB_ENV"
53+
run: pip install meson-python ninja cmake cython "numpy>=2" mkl-devel
7854

7955
- name: Download Coverity Build Tool
8056
timeout-minutes: 15
8157
env:
8258
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
8359
run: |
8460
curl --location --no-progress-meter \
61+
--retry 5 --retry-connrefused --retry-delay 5 \
8562
--data-urlencode "token=${COVERITY_SCAN_TOKEN}" \
8663
--data-urlencode "project=${COVERITY_PROJECT}" \
8764
--output cov-analysis.tar.gz \
@@ -107,9 +84,9 @@ jobs:
10784
timeout-minutes: 20
10885
run: |
10986
# Force a clean rebuild so g++ genuinely runs and Coverity can capture
110-
# it. A stale .so or generated .cpp would skip compilation and yield
87+
# it. A stale build directory would skip compilation and yield
11188
# "No files were emitted", which the upload rejects.
112-
rm -rf build/ mkl_random/*.so mkl_random/mklrand.cpp
89+
rm -rf build/
11390
cov-build --dir cov-int pip install -e . --no-build-isolation --no-deps 2>&1 | tee cov-build.log
11491
# The extension has 3 translation units (mklrand.cpp + the two src/*.cpp);
11592
# bail out if none were captured.
@@ -126,6 +103,7 @@ jobs:
126103
run: |
127104
tar -czf cov-int.tgz cov-int
128105
curl --no-progress-meter \
106+
--retry 5 --retry-connrefused --retry-delay 5 \
129107
--form token="${COVERITY_SCAN_TOKEN}" \
130108
--form email="${COVERITY_SCAN_EMAIL}" \
131109
--form file=@cov-int.tgz \

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# CMake build and local install directory
1+
# Meson build and local install directory
22
build/
3+
.mesonpy-*
34
mkl_random.egg-info/
45

56
# Byte-compiled / optimized / DLL files
67
__pycache__/
7-
8-
mkl_random/src/mklrand.c
9-
mkl_random/mklrand.cpp
10-
mkl_random/mklrand.cpython*.so

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313
* Removed `numpy-base` dependency and `USE_NUMPY_BASE` environment variable from conda recipe [gh-124](https://github.com/IntelPython/mkl_random/pull/124)
14+
* Migrated the build system from `setuptools` to `meson-python`, removing `setup.py` in favor of `meson.build` [gh-113](https://github.com/IntelPython/mkl_random/pull/113)
1415

1516
### Fixed
1617
* Fixed compatibility with NumPy 2.5 by replacing the deprecated in-place array `shape` assignment with `reshape`, and by replacing the deprecated `numpy.testing.suppress_warnings` usage in tests with `pytest.warns` [gh-137](https://github.com/IntelPython/mkl_random/pull/137)

0 commit comments

Comments
 (0)