Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
503cdce
Use meson as build system
ndgrigorian Apr 8, 2026
392d89a
remove MKLROOT
ndgrigorian Apr 8, 2026
e8255b5
add standard clang workflow and update clang workflow
ndgrigorian Apr 8, 2026
8681c0d
add ninja to build-system
ndgrigorian Apr 8, 2026
acb1d16
use cmake to find MKL and update dependencies
ndgrigorian Apr 8, 2026
488455e
update meta.yamls and conda-forge conda recipes
ndgrigorian Apr 8, 2026
f6e5526
install mkl-devel when building with standard clang
ndgrigorian Apr 8, 2026
869a7dc
add pip build workflow
ndgrigorian Apr 8, 2026
02fdbbe
update conda-recipe build scripts
ndgrigorian Apr 8, 2026
a92a577
address review feedback
ndgrigorian Apr 26, 2026
49fc7be
update workflows
ndgrigorian Apr 26, 2026
83838d5
remove copy-paste error numpy installations in workflows
ndgrigorian Apr 26, 2026
b39b64b
update agent instructions
ndgrigorian Apr 26, 2026
70124c9
address review feedback
ndgrigorian Jul 8, 2026
243009b
Merge branch 'master' into use-meson-build
ndgrigorian Jul 8, 2026
24994a1
Apply review comments
antonwolfy Jul 10, 2026
2f10210
Update `AGENTS.md` with info why `mkl`-dependency can't be added to `…
antonwolfy Jul 10, 2026
b50576e
Fix nits and typos
antonwolfy Jul 10, 2026
af7bfdb
Clarified build command in teh README.md with how to install build deps
antonwolfy Jul 13, 2026
b6082f6
Update changelog
antonwolfy Jul 13, 2026
83147f0
Merge branch 'master' into use-meson-build
antonwolfy Jul 13, 2026
9df754d
Remove excess import os per review comment
antonwolfy Jul 20, 2026
3e0d126
Merge branch 'master' into use-meson-build
antonwolfy Jul 20, 2026
f5be62c
Restore verbose visibility for the build
antonwolfy Jul 20, 2026
a04d7a8
Bake the RPATH into the extensions via a literal linker argument rath…
antonwolfy Jul 20, 2026
24a9cd4
Removed the entire "Upload wheels artifact" step, because cf recipe i…
antonwolfy Jul 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ CI/CD workflows, automation, security scanning, and package distribution.

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

Expand Down
4 changes: 2 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Higher-precedence file overrides; lower must not restate overridden guidance.
- Never include secrets/tokens/credentials in files.

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

## MKL-specific constraints
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

env:
ONEAPI_ROOT: /opt/intel/oneapi
Expand All @@ -37,10 +37,9 @@ jobs:
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update

- name: Install Intel OneAPI
- name: Install Intel oneAPI
run: |
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp
sudo apt-get install intel-oneapi-tbb
sudo apt-get install intel-oneapi-mkl-devel

- name: Setup Python
Expand All @@ -55,12 +54,8 @@ jobs:
fetch-depth: 0

- name: Install mkl-service dependencies
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
with:
packages: |
cython
setuptools>=77
pytest
run: |
pip install meson-python cython cmake ninja

- name: List oneAPI folder content
run: ls ${{ env.ONEAPI_ROOT }}/compiler
Expand All @@ -71,9 +66,10 @@ jobs:
echo "$CMPLR_ROOT"
export CC="$CMPLR_ROOT/bin/icx"
export CFLAGS="${CFLAGS} -fno-fast-math"
python setup.py develop
pip install . --no-build-isolation --no-deps --verbose

- name: Run mkl-service tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pip install pytest
pytest -s -v --pyargs mkl
56 changes: 56 additions & 0 deletions .github/workflows/build-with-standard-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build project with standard clang compiler

on:
pull_request:
push:
branches: [master]

permissions: read-all

jobs:
build-with-standard-clang:
runs-on: ubuntu-latest

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

env:
COMPILER_ROOT: /usr/bin

defaults:
run:
shell: bash -el {0}

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
with:
access_token: ${{ github.token }}

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang

- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python }}
architecture: x64

- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Install mkl-service dependencies
run: |
pip install meson-python cython cmake ninja mkl-devel

- name: Build mkl-service
run: |
export CC=${{ env.COMPILER_ROOT }}/clang
pip install -e ".[test]" --no-build-isolation --verbose
pip list
python -m pytest -v mkl/tests
43 changes: 43 additions & 0 deletions .github/workflows/build_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Editable build using pip

on:
push:
branches:
- master
pull_request:

permissions: read-all

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
channels: conda-forge
activate-environment: test
python-version: ${{ matrix.python }}

- name: Install MKL
run: |
conda install mkl-devel mkl
- name: Build with pip
run: |
pip install --no-cache-dir meson-python ninja cmake cython
pip install -e ".[test]" --no-build-isolation --verbose
pip list
python -m pytest -v mkl/tests
21 changes: 0 additions & 21 deletions .github/workflows/conda-package-cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
shell: bash -el {0}
run: |
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"

- name: Build conda package
run: |
Expand All @@ -79,12 +78,6 @@ jobs:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda

- name: Upload wheels artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl

build_windows:
runs-on: windows-latest

Expand Down Expand Up @@ -132,7 +125,6 @@ jobs:
shell: bash -el {0}
run: |
echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV"

- name: Show Conda info
run: |
Expand All @@ -151,12 +143,6 @@ jobs:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda

- name: Upload wheels artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl

test_linux:
needs: build_linux
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -359,7 +345,6 @@ jobs:
shell: bash -el {0}
run: |
echo "CONDA_BLD=$CONDA/conda-bld/osx-64/" >> "$GITHUB_ENV"
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"

- name: Build conda package
shell: bash -el {0}
Expand All @@ -380,12 +365,6 @@ jobs:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda

- name: Upload wheels artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl

test_osx:
needs: build_osx
runs-on: ${{ matrix.runner }}
Expand Down
32 changes: 25 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,44 @@ Originally part of Intel® Distribution for Python*, now a standalone package av

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

## Build dependencies
**Required:**
- Intel® oneMKL
- meson-python
- CMake
- Ninja
- Cython
- Python 3.10+

**Conda environment:**
**Build against an existing `mkl` installation:**

Install the build dependencies via Conda:
```bash
conda install -c conda-forge mkl-devel cython meson-python cmake ninja
```
or via pip:
```bash
python -m pip install mkl-devel cython meson-python cmake ninja
```
then build without pulling a fresh `mkl` into an isolated build:
```bash
conda install -c conda-forge mkl-devel cython
python setup.py install
python -m pip install --no-deps --no-build-isolation .
```

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

Expand All @@ -61,15 +76,16 @@ mkl.get_version_string() # MKL version info
- **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)

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

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

## Directory map
Expand All @@ -85,4 +101,6 @@ Below directories have local `AGENTS.md` for deeper context:
For broader IntelPython ecosystem context, see:
- `mkl_umath` (MKL-backed NumPy ufuncs)
- `mkl_random` (MKL-based random number generation)
- `mkl_fft` (MKL-based fast fourier transform functions)
- `dpnp` (Data Parallel NumPy)
- `dpctl` (Data Parallel Control)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
* 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)

### Fixed

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ A short example, illustrating its use:
```

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).

---

## Building

A C compiler and Intel(R) oneAPI Math Kernel Library (oneMKL) are required to build mkl-service from source.

Executing
```sh
python -m pip install .
```

will pull in the required build dependencies, including `mkl`, and build `mkl-service`.

If you already have `mkl` installed (from your system or a Conda environment) and
want to reuse it instead of pulling a fresh copy into an isolated build, first
install the build dependencies:
```sh
python -m pip install mkl-devel meson-python cmake ninja cython
```

then build against the existing installation with:
```sh
python -m pip install --no-build-isolation --no-deps .
```
3 changes: 1 addition & 2 deletions conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@rem Remember to activate Intel Compiler, or remove these two lines to use Microsoft Visual Studio compiler

set MKLROOT=%PREFIX%
%PYTHON% setup.py build --force install --old-and-unmanageable
%PYTHON% -m pip install --no-deps --no-build-isolation .
if errorlevel 1 exit 1
4 changes: 2 additions & 2 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash -x
MKLROOT=$PREFIX $PYTHON setup.py build --force install --old-and-unmanageable
#!/bin/bash -ex
$PYTHON -m pip install --no-deps --no-build-isolation .
Comment thread
ndgrigorian marked this conversation as resolved.
7 changes: 3 additions & 4 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ source:
build:
number: {{ GIT_DESCRIBE_NUMBER }}
skip: true # [osx and arm64]
script_env:
- WHEELS_OUTPUT_FOLDER
ignore_run_exports:
- blas
- mkl-service
Expand All @@ -19,15 +17,16 @@ requirements:
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
- cmake
- ninja
- python
- python-gil # [py>=314]
- pip >=25.0
- setuptools >=77
- mkl-devel # [not osx]
- mkl-devel <2024 # [osx]
- cython
- wheel >=0.45.1
- python-build >=1.2.2
Comment thread
ndgrigorian marked this conversation as resolved.
run:
- python
- python-gil # [py>=314]
Expand Down
Loading
Loading