Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04605fe
Moves the build system from setuptools to meson
ndgrigorian Apr 8, 2026
a8429b3
add cmake to build system dependencies
ndgrigorian Apr 8, 2026
dd8fb6c
use meson-python in builds
ndgrigorian Apr 8, 2026
e7b7b56
add pip build
ndgrigorian Apr 8, 2026
2d1f4a4
add standard clang workflow
ndgrigorian Apr 8, 2026
6b6bc71
add ninja to build system and meta.yamls
ndgrigorian Apr 8, 2026
668fbb5
use pip install in build scripts
ndgrigorian Apr 8, 2026
6f8d749
remove MKLROOT
ndgrigorian Apr 8, 2026
02efc61
don't install mkl-service in pip and standard clang builds
ndgrigorian Apr 8, 2026
e2c6db2
add mkl_threading option
ndgrigorian May 16, 2026
d665264
use gnu_thread in Linux conda-forge builds
ndgrigorian May 16, 2026
03930e6
add fix to pip builds
ndgrigorian May 16, 2026
570f465
Merge remote-tracking branch 'origin/master' into build-with-meson
vlad-perevezentsev Jul 23, 2026
9bf7d7e
Apply remarks from mkl-service PR for meson.build
vlad-perevezentsev Jul 23, 2026
60adc5f
Apply remarks from mkl-service PR for conda-recipe
vlad-perevezentsev Jul 23, 2026
72f9a2d
Update conda-recipe-cf
vlad-perevezentsev Jul 23, 2026
7483cfb
Add missing python source file to meson.build
vlad-perevezentsev Jul 23, 2026
74a8ae0
Clean up github workflows
vlad-perevezentsev Jul 23, 2026
6819973
Remove unused env variables from build_pip.yml
vlad-perevezentsev Jul 23, 2026
59da276
Add Building from source block to README.md
vlad-perevezentsev Jul 23, 2026
b98b4db
A small clean up
vlad-perevezentsev Jul 23, 2026
c925f2b
Remove redundant mkl from build-with-standard-clang dependencies
vlad-perevezentsev Jul 23, 2026
b60d962
Fix numpy install in GH CI workflows
vlad-perevezentsev Jul 23, 2026
a80ff59
add CI badges to README.md
vlad-perevezentsev Jul 23, 2026
01d2179
Fix MKL detection with non-Intel clang++
vlad-perevezentsev Jul 23, 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
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
shell: bash -l {0}
run: |
pip install numpy cython setuptools">=77" scikit-build cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
pip install meson-python ninja cython cmake numpy sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
- name: Checkout repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
numpy_version: ["numpy>=2"]
numpy_version: ["'numpy>=2'"]
env:
ONEAPI_ROOT: /opt/intel/oneapi

Expand All @@ -38,7 +38,6 @@ jobs:
- 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 @@ -54,8 +53,8 @@ jobs:

- name: Install mkl_random dependencies
run: |
pip install cython setuptools">=77"
pip install "${{ matrix.numpy_version }}"
pip install meson-python ninja cython cmake
pip install ${{ matrix.numpy_version }}

- name: List oneAPI folder content
run: ls "${{ env.ONEAPI_ROOT }}/compiler"
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/build-with-standard-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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"]
numpy_version: ["'numpy>=2'"]

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_random dependencies
run: |
pip install meson-python ninja cmake cython mkl-devel
pip install ${{ matrix.numpy_version }}

- name: Build mkl_random
run: |
export CC=${{ env.COMPILER_ROOT }}/clang
export CXX=${{ env.COMPILER_ROOT }}/clang++
pip install . --no-build-isolation --no-deps --verbose

- name: Run mkl_random tests
run: |
pip install pytest
# mkl_random cannot be installed in editable mode, we need
# to change directory before importing it and running tests
cd ..
python -m pytest -sv --pyargs mkl_random
45 changes: 45 additions & 0 deletions .github/workflows/build_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Editable build using pip and pre-release NumPy

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"]
use_pre: ["", "--pre"]

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 --no-cache-dir numpy ${{ matrix.use_pre }}
pip install -e ".[test]" --no-build-isolation --verbose -Csetup-args="-Dmkl_threading=gnu_thread"
pip list
python -m pytest -v mkl_random/tests
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## `mkl_random` -- a NumPy-based Python interface to Intel® oneAPI Math Kernel Library (OneMKL) Random Number Generation functionality
[![Conda package](https://github.com/IntelPython/mkl_random/actions/workflows/conda-package.yml/badge.svg)](https://github.com/IntelPython/mkl_random/actions/workflows/conda-package.yml)
[![Editable build using pip and pre-release NumPy](https://github.com/IntelPython/mkl_random/actions/workflows/build_pip.yml/badge.svg)](https://github.com/IntelPython/mkl_random/actions/workflows/build_pip.yml)
[![Conda package using conda-forge](https://github.com/IntelPython/mkl_random/actions/workflows/conda-package-cf.yml/badge.svg)](https://github.com/IntelPython/mkl_random/actions/workflows/conda-package-cf.yml)

`mkl_random` started as a part of Intel® Distribution for Python optimizations to NumPy.
Expand Down Expand Up @@ -132,7 +134,25 @@ with mkl_random.mkl_random():

---

To build `mkl_random` from sources on Linux:
- install a recent version of MKL, if necessary;
- execute `source /path_to_oneapi/mkl/latest/env/vars.sh`;
- execute `python -m pip install .`
# Building from source

A C++ compiler, Intel® oneAPI Math Kernel Library (oneMKL), and NumPy are required
to build `mkl_random` from source.

Executing
```sh
python -m pip install .
```
will pull in the required build dependencies, including `mkl` and `numpy`, and build `mkl_random`.

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

then build against the existing installation with:
```sh
python -m pip install --no-build-isolation --no-deps .
```
17 changes: 2 additions & 15 deletions conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
@rem Remember to source the compiler

set MKLROOT=%CONDA_PREFIX%

rem Build wheel package
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
%PYTHON% -m pip wheel --no-build-isolation --no-deps .
if errorlevel 1 exit 1
copy mkl_random*.whl %WHEELS_OUTPUT_FOLDER%
if errorlevel 1 exit 1
) ELSE (
rem Build conda package
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
)
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
19 changes: 2 additions & 17 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
#!/bin/bash -x
#!/bin/bash -ex

export CFLAGS="-I$PREFIX/include $CFLAGS"
export LDFLAGS="-Wl,-rpath,\$ORIGIN/../.. -Wl,-rpath,\$ORIGIN/../../.. -L${PREFIX}/lib ${LDFLAGS}"
export MKLROOT=$CONDA_PREFIX

read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"

# Build wheel package
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
$PYTHON -m pip wheel --no-build-isolation --no-deps .
${PYTHON} -m wheel tags --remove --platform-tag "manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64" mkl_random*.whl
cp mkl_random*.whl "${WHEELS_OUTPUT_FOLDER}"
else
# Build conda package
$PYTHON -m pip install --no-build-isolation --no-deps .
fi
$PYTHON -m pip install --no-build-isolation --no-deps -Csetup-args="-Dmkl_threading=gnu_thread" .
6 changes: 4 additions & 2 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ requirements:
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
- cmake
- ninja
- python
- python-gil # [py>=314]
- setuptools >=77
- mkl-devel
- cython
- numpy
- pip
- wheel >=0.41.3
run:
- python
- python-gil [py>=314]
- python-gil # [py>=314]
- {{ pin_compatible('numpy', min_pin="x.x", max_pin="x") }}
- {{ pin_compatible('mkl', min_pin="x.x", max_pin="x") }}

Expand Down
27 changes: 16 additions & 11 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
@rem Remember to source the compiler
:: -wnx flags mean: --wheel --no-isolation --skip-dependency-check
:: -Ccompile-args=-v makes ninja print full compiler commands (verbose build)
%PYTHON% -m build -w -n -x -Ccompile-args=-v
if %ERRORLEVEL% neq 0 exit 1

set MKLROOT=%CONDA_PREFIX%
for /f %%f in ('dir /b /S .\dist') do (
%PYTHON% -m pip install %%f ^
--no-build-isolation ^
--no-deps ^
--only-binary :all: ^
--no-index ^
--prefix %PREFIX% ^
-vv
if %ERRORLEVEL% neq 0 exit 1
)

rem Build wheel package
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
%PYTHON% -m pip wheel --no-build-isolation --no-deps .
if errorlevel 1 exit 1
copy mkl_random*.whl %WHEELS_OUTPUT_FOLDER%
if errorlevel 1 exit 1
) ELSE (
rem Build conda package
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
copy dist\mkl_random*.whl %WHEELS_OUTPUT_FOLDER%
if %ERRORLEVEL% neq 0 exit 1
)
36 changes: 25 additions & 11 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
#!/bin/bash -x
#!/bin/bash -ex

if [ -d "build" ]; then
rm -rf build
fi

export CFLAGS="-I$PREFIX/include $CFLAGS"
export LDFLAGS="-Wl,-rpath,\$ORIGIN/../.. -Wl,-rpath,\$ORIGIN/../../.. -L${PREFIX}/lib ${LDFLAGS}"
export MKLROOT=$CONDA_PREFIX
export LDFLAGS="-L${PREFIX}/lib ${LDFLAGS}"

read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"

# Build wheel package
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
$PYTHON -m pip wheel --no-build-isolation --no-deps .
${PYTHON} -m wheel tags --remove --platform-tag "manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64" mkl_random*.whl
cp mkl_random*.whl "${WHEELS_OUTPUT_FOLDER}"
else
# Build conda package
$PYTHON -m pip install --no-build-isolation --no-deps .
# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
# -Ccompile-args=-v makes ninja print full compiler commands (verbose build)
${PYTHON} -m build -w -n -x -Ccompile-args=-v

${PYTHON} -m wheel tags --remove \
--platform-tag "manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64" \
dist/mkl_random*.whl

${PYTHON} -m pip install dist/mkl_random*.whl \
--no-build-isolation \
--no-deps \
--only-binary :all: \
--no-index \
--prefix "${PREFIX}" \
-vv

# Copy wheel package
if [[ -d "${WHEELS_OUTPUT_FOLDER}" ]]; then
cp dist/mkl_random*.whl "${WHEELS_OUTPUT_FOLDER[@]}"
fi
5 changes: 4 additions & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ requirements:
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
- python-build >=1.2.2
- cmake
- ninja
- python
- python-gil # [py>=314]
- setuptools >=77
- mkl-devel
- cython
- numpy
Expand Down
Loading
Loading