Skip to content

Commit 48b89c8

Browse files
authored
Merge pull request #174 from IntelPython/use-meson-build
Move build system to `meson-python`
2 parents 16482a0 + 24a9cd4 commit 48b89c8

20 files changed

Lines changed: 265 additions & 189 deletions

.github/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ CI/CD workflows, automation, security scanning, and package distribution.
44

55
## Workflows
66
- **conda-package.yml** — main build/test pipeline (Linux/Windows, Python 3.10-3.14)
7+
- **conda-package-cf.yml** — build/test using only conda-forge channel (Linux/Windows, Python 3.10-3.14)
78
- **build-with-clang.yml** — Linux Clang compiler compatibility validation
9+
- **build-with-standard-clang.yml** — standard Clang compiler compatibility validation
10+
- **build_pip.yml** — validates editable build
811
- **pre-commit.yml** — code quality checks (flake8, etc.)
912
- **openssf-scorecard.yml** — security posture scanning
1013

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Higher-precedence file overrides; lower must not restate overridden guidance.
3434
- Never include secrets/tokens/credentials in files.
3535

3636
## Source-of-truth files
37-
- Build/config: `pyproject.toml`, `setup.py`
37+
- Build/config: `pyproject.toml`, `meson.build`
3838
- Recipe/deps: `conda-recipe/meta.yaml`, `conda-recipe/conda_build_config.yaml`
3939
- CI: `.github/workflows/*.{yml,yaml}`
40-
- API contracts: `mkl/__init__.py`, `mkl/_mkl_service.pyx`
40+
- API contracts: `mkl/__init__.py`, `mkl/_py_mkl_service.pyx`
4141
- Tests: `mkl/tests/test_mkl_service.py`
4242

4343
## MKL-specific constraints

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
python: ["3.10", "3.11", "3.12", "3.13"]
17+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1818

1919
env:
2020
ONEAPI_ROOT: /opt/intel/oneapi
@@ -37,10 +37,9 @@ jobs:
3737
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
3838
sudo apt-get update
3939
40-
- name: Install Intel OneAPI
40+
- name: Install Intel oneAPI
4141
run: |
4242
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp
43-
sudo apt-get install intel-oneapi-tbb
4443
sudo apt-get install intel-oneapi-mkl-devel
4544
4645
- name: Setup Python
@@ -55,12 +54,8 @@ jobs:
5554
fetch-depth: 0
5655

5756
- name: Install mkl-service dependencies
58-
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
59-
with:
60-
packages: |
61-
cython
62-
setuptools>=77
63-
pytest
57+
run: |
58+
pip install meson-python cython cmake ninja
6459
6560
- name: List oneAPI folder content
6661
run: ls ${{ env.ONEAPI_ROOT }}/compiler
@@ -71,9 +66,10 @@ jobs:
7166
echo "$CMPLR_ROOT"
7267
export CC="$CMPLR_ROOT/bin/icx"
7368
export CFLAGS="${CFLAGS} -fno-fast-math"
74-
python setup.py develop
69+
pip install . --no-build-isolation --no-deps --verbose
7570
7671
- name: Run mkl-service tests
7772
run: |
7873
source ${{ env.ONEAPI_ROOT }}/setvars.sh
74+
pip install pytest
7975
pytest -s -v --pyargs mkl
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
18+
env:
19+
COMPILER_ROOT: /usr/bin
20+
21+
defaults:
22+
run:
23+
shell: bash -el {0}
24+
25+
steps:
26+
- name: Cancel Previous Runs
27+
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
28+
with:
29+
access_token: ${{ github.token }}
30+
31+
- name: Install Dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y clang
35+
36+
- name: Setup Python
37+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
38+
with:
39+
python-version: ${{ matrix.python }}
40+
architecture: x64
41+
42+
- name: Checkout repo
43+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44+
with:
45+
fetch-depth: 0
46+
47+
- name: Install mkl-service dependencies
48+
run: |
49+
pip install meson-python cython cmake ninja mkl-devel
50+
51+
- name: Build mkl-service
52+
run: |
53+
export CC=${{ env.COMPILER_ROOT }}/clang
54+
pip install -e ".[test]" --no-build-isolation --verbose
55+
pip list
56+
python -m pytest -v mkl/tests

.github/workflows/build_pip.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Editable build using pip
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+
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
28+
with:
29+
miniforge-version: latest
30+
channels: conda-forge
31+
activate-environment: test
32+
python-version: ${{ matrix.python }}
33+
34+
- name: Install MKL
35+
run: |
36+
conda install mkl-devel mkl
37+
38+
- name: Build with pip
39+
run: |
40+
pip install --no-cache-dir meson-python ninja cmake cython
41+
pip install -e ".[test]" --no-build-isolation --verbose
42+
pip list
43+
python -m pytest -v mkl/tests

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ jobs:
5959
shell: bash -el {0}
6060
run: |
6161
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
62-
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
6362
6463
- name: Build conda package
6564
run: |
@@ -79,12 +78,6 @@ jobs:
7978
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
8079
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
8180

82-
- name: Upload wheels artifact
83-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
84-
with:
85-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
86-
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
87-
8881
build_windows:
8982
runs-on: windows-latest
9083

@@ -132,7 +125,6 @@ jobs:
132125
shell: bash -el {0}
133126
run: |
134127
echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
135-
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV"
136128
137129
- name: Show Conda info
138130
run: |
@@ -151,12 +143,6 @@ jobs:
151143
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
152144
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
153145

154-
- name: Upload wheels artifact
155-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
156-
with:
157-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
158-
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
159-
160146
test_linux:
161147
needs: build_linux
162148
runs-on: ${{ matrix.runner }}
@@ -359,7 +345,6 @@ jobs:
359345
shell: bash -el {0}
360346
run: |
361347
echo "CONDA_BLD=$CONDA/conda-bld/osx-64/" >> "$GITHUB_ENV"
362-
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
363348
364349
- name: Build conda package
365350
shell: bash -el {0}
@@ -380,12 +365,6 @@ jobs:
380365
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
381366
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
382367

383-
- name: Upload wheels artifact
384-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
385-
with:
386-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
387-
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
388-
389368
test_osx:
390369
needs: build_osx
391370
runs-on: ${{ matrix.runner }}

AGENTS.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,44 @@ Originally part of Intel® Distribution for Python*, now a standalone package av
1515

1616
## Key components
1717
- **Python interface:** `mkl/__init__.py` — public API surface
18-
- **Cython wrapper:** `mkl/_mkl_service.pyx` — wraps MKL support functions
18+
- **Cython wrapper:** `mkl/_py_mkl_service.pyx` — wraps MKL support functions
1919
- **C init module:** `mkl/_mklinitmodule.c` — Linux-side MKL runtime preloading / initialization
2020
- **Helper:** `mkl/_init_helper.py` — Windows venv DLL loading helper
21-
- **Build system:** setuptools + Cython
21+
- **Build system:** meson-python + Cython
2222

2323
## Build dependencies
2424
**Required:**
2525
- Intel® oneMKL
26+
- meson-python
27+
- CMake
28+
- Ninja
2629
- Cython
2730
- Python 3.10+
2831

29-
**Conda environment:**
32+
**Build against an existing `mkl` installation:**
33+
34+
Install the build dependencies via Conda:
35+
```bash
36+
conda install -c conda-forge mkl-devel cython meson-python cmake ninja
37+
```
38+
or via pip:
39+
```bash
40+
python -m pip install mkl-devel cython meson-python cmake ninja
41+
```
42+
then build without pulling a fresh `mkl` into an isolated build:
3043
```bash
31-
conda install -c conda-forge mkl-devel cython
32-
python setup.py install
44+
python -m pip install --no-deps --no-build-isolation .
3345
```
3446

3547
## CI/CD
3648
- **Platforms in CI workflows:** Linux, Windows
3749
- **Python versions:** 3.10, 3.11, 3.12, 3.13, 3.14
3850
- **Workflows:** `.github/workflows/`
3951
- `conda-package.yml` — main conda build/test pipeline
52+
- `conda-package-cf.yml` — conda build/test using only conda-forge channel
4053
- `build-with-clang.yml` — Linux Clang compatibility
54+
- `build-with-standard-clang.yml` — standard Clang compiler compatibility validation
55+
- `build_pip.yml` — validates editable build
4156
- `pre-commit.yml` — code quality checks
4257
- `openssf-scorecard.yml` — security scanning
4358

@@ -61,15 +76,16 @@ mkl.get_version_string() # MKL version info
6176
- **Docs:** MKL support functions documented in [Intel oneMKL Developer Reference](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2025-2/support-functions.html)
6277

6378
## Code structure
64-
- **Cython layer:** `_mkl_service.pyx` + `_mkl_service.pxd` (C declarations)
79+
- **Cython layer:** `_py_mkl_service.pyx` + `_mkl_service.pxd` (C declarations)
6580
- **C init:** `_mklinitmodule.c` handles Linux preloading (`dlopen(..., RTLD_GLOBAL)`) for MKL runtime
6681
- **Windows loading helper:** `_init_helper.py` handles DLL path setup in Windows venv
6782
- **Python wrapper:** `__init__.py` imports `_py_mkl_service` (generated from `.pyx`)
68-
- **Version:** `_version.py` (dynamic via setuptools)
83+
- **Version:** `_version.py`
6984

7085
## Notes
7186
- RTLD_GLOBAL preloading is required on Linux (handled by `RTLD_for_MKL` context manager)
7287
- MKL must be available at runtime (conda: mkl, pip: relies on system MKL)
88+
- Do **not** add `mkl` to `[project].dependencies` in `pyproject.toml` (its PyPI wheel lacks `.dist-info`, which breaks `pip check`).
7389
- Threading functions affect NumPy, SciPy, and other MKL-backed libraries
7490

7591
## Directory map
@@ -85,4 +101,6 @@ Below directories have local `AGENTS.md` for deeper context:
85101
For broader IntelPython ecosystem context, see:
86102
- `mkl_umath` (MKL-backed NumPy ufuncs)
87103
- `mkl_random` (MKL-based random number generation)
104+
- `mkl_fft` (MKL-based fast fourier transform functions)
88105
- `dpnp` (Data Parallel NumPy)
106+
- `dpctl` (Data Parallel Control)

CHANGELOG.md

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

1111
### Changed
12+
* Migrated the build system from `setuptools` to `meson-python`, removing `setup.py` in favor of `meson.build` [gh-174](https://github.com/IntelPython/mkl-service/pull/174)
1213

1314
### Fixed
1415

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,28 @@ A short example, illustrating its use:
2929
```
3030

3131
For more information about the usage of support functions see [Developer Reference for Intel® oneAPI Math Kernel Library for C](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2025-2/support-functions.html).
32+
33+
---
34+
35+
## Building
36+
37+
A C compiler and Intel(R) oneAPI Math Kernel Library (oneMKL) are required to build mkl-service from source.
38+
39+
Executing
40+
```sh
41+
python -m pip install .
42+
```
43+
44+
will pull in the required build dependencies, including `mkl`, and build `mkl-service`.
45+
46+
If you already have `mkl` installed (from your system or a Conda environment) and
47+
want to reuse it instead of pulling a fresh copy into an isolated build, first
48+
install the build dependencies:
49+
```sh
50+
python -m pip install mkl-devel meson-python cmake ninja cython
51+
```
52+
53+
then build against the existing installation with:
54+
```sh
55+
python -m pip install --no-build-isolation --no-deps .
56+
```

conda-recipe-cf/bld.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@rem Remember to activate Intel Compiler, or remove these two lines to use Microsoft Visual Studio compiler
22

3-
set MKLROOT=%PREFIX%
4-
%PYTHON% setup.py build --force install --old-and-unmanageable
3+
%PYTHON% -m pip install --no-deps --no-build-isolation .
54
if errorlevel 1 exit 1

0 commit comments

Comments
 (0)