From 04605feb41c01e36f7547f350cebb4c91c774b9b Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 18:51:04 -0700 Subject: [PATCH 01/24] Moves the build system from setuptools to meson * removes setup.py and generate_mklrand_c.py * updates pyproject.toml * adds meson.build --- conda-recipe-cf/meta.yaml | 4 +- conda-recipe/meta.yaml | 4 +- meson.build | 94 ++++++++++++++++++++++++ mkl_random/src/generate_mklrand_c.py | 48 ------------ pyproject.toml | 22 ++---- setup.py | 105 --------------------------- 6 files changed, 107 insertions(+), 170 deletions(-) create mode 100644 meson.build delete mode 100644 mkl_random/src/generate_mklrand_c.py delete mode 100644 setup.py diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index 4effa580..317805af 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -18,9 +18,11 @@ requirements: - {{ compiler('cxx') }} - {{ stdlib('c') }} host: + - meson-python >=0.13.0 + - meson + - pkg-config - python - python-gil # [py>=314] - - setuptools >=77 - mkl-devel - cython - numpy diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 4de995a0..eee53bf4 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -18,9 +18,11 @@ requirements: - {{ compiler('cxx') }} - {{ stdlib('c') }} host: + - meson-python >=0.13.0 + - meson + - pkg-config - python - python-gil # [py>=314] - - setuptools >=77 - mkl-devel - cython - numpy diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..727ebde4 --- /dev/null +++ b/meson.build @@ -0,0 +1,94 @@ +project( + 'mkl_random', + ['c', 'cpp', 'cython'], + version: run_command( + 'python', '-c', + 'import os; exec(open("mkl_random/_version.py").read()); print(__version__)', + check: true + ).stdout().strip(), + default_options: [ + 'cpp_std=c++11', + 'buildtype=release', + ] +) + +py = import('python').find_installation(pure: false) +py_dep = py.dependency() + +# numpy includes +np_dir = run_command(py, + ['-c', 'import numpy; print(numpy.get_include())'], + check: true +).stdout().strip() + +inc_np = include_directories(np_dir, 'mkl_random/src') + +# compiler/linker +cpp = meson.get_compiler('cpp') +cpp_args = [ + '-D_FILE_OFFSET_BITS=64', + '-D_LARGEFILE_SOURCE=1', + '-D_LARGEFILE64_SOURCE=1', + '-DPY_ARRAY_UNIQUE_SYMBOL=mkl_random_ext', + '-DNDEBUG' +] +link_args = [] + +if cpp.get_argument_syntax() == 'msvc' + link_args += ['Advapi32.lib'] +else + cpp_args += ['-Wno-unused-but-set-variable', '-Wno-unused-function'] +endif + +mkl_dep = dependency('MKL', method: 'cmake', + modules: ['MKL::MKL'], + cmake_args: [ + '-DMKL_ARCH=intel64', + '-DMKL_LINK=dynamic', + '-DMKL_THREADING=intel_thread', + '-DMKL_INTERFACE=lp64' + ], + required: true +) + +py.extension_module( + 'mklrand', + sources: [ + 'mkl_random/mklrand.pyx', + 'mkl_random/src/mkl_distributions.cpp', + 'mkl_random/src/randomkit.cpp' + ], + include_directories: inc_np, + dependencies: [mkl_dep, py_dep], + cpp_args: cpp_args, + link_args: link_args, + override_options: ['cython_language=cpp'], + install: true, + subdir: 'mkl_random' +) + +# install python sources + +py.install_sources( + [ + 'mkl_random/__init__.py', + 'mkl_random/_init_helper.py', + 'mkl_random/_patch_numpy.py', + 'mkl_random/_version.py', + ], + subdir: 'mkl_random' +) + +py.install_sources( + [ + 'mkl_random/interfaces/__init__.py', + 'mkl_random/interfaces/_numpy_random.py', + 'mkl_random/interfaces/numpy_random.py', + ], + subdir: 'mkl_random/interfaces' +) + +install_subdir( + 'mkl_random/tests', + install_dir: py.get_install_dir() / 'mkl_random' +) diff --git a/mkl_random/src/generate_mklrand_c.py b/mkl_random/src/generate_mklrand_c.py deleted file mode 100644 index 744223ed..00000000 --- a/mkl_random/src/generate_mklrand_c.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -from __future__ import absolute_import, division, print_function - -import os -import re -import sys - -unused_internal_funcs = [ - "__Pyx_PrintItem", - "__Pyx_PrintNewline", - "__Pyx_ReRaise", - # '__Pyx_GetExcValue', - "__Pyx_ArgTypeTest", - "__Pyx_SetVtable", - "__Pyx_GetVtable", - "__Pyx_CreateClass", -] - -if __name__ == "__main__": - # Use cython here so that long docstrings are broken up. - # This is needed for some VC++ compilers. - os.system("cython mklrand.pyx") - mklrand_c = open("mklrand.c", "r") - processed = open("mklrand_pp.c", "w") - unused_funcs_str = "(" + "|".join(unused_internal_funcs) + ")" - uifpat = re.compile(r"static \w+ \*?" + unused_funcs_str + r".*/\*proto\*/") - linepat = re.compile(r'/\* ".*/mklrand.pyx":') - for linenum, line in enumerate(mklrand_c): - m = re.match( - r"^(\s+arrayObject\w*\s*=\s*[(])[(]PyObject\s*[*][)]", line - ) - if m: - line = "%s(PyArrayObject *)%s" % (m.group(1), line[m.end() :]) - m = uifpat.match(line) - if m: - line = "" - m = re.search(unused_funcs_str, line) - if m: - print( - "%s was declared unused, but is used at line %d" - % (m.group(), linenum + 1), - file=sys.stderr, - ) - line = linepat.sub(r'/* "mklrand.pyx":', line) - processed.write(line) - mklrand_c.close() - processed.close() - os.rename("mklrand_pp.c", "mklrand.c") diff --git a/pyproject.toml b/pyproject.toml index 0476dba7..3e26ce2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,13 +24,15 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools>=77", "Cython", "numpy"] +build-backend = "mesonpy" +requires = [ + "meson-python>=0.13.0", + "Cython", + "numpy" +] [project] -authors = [ - {name = "Intel Corporation", email = "scripting@intel.com"} -] +authors = [{name = "Intel Corporation"}] classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", @@ -98,13 +100,3 @@ extension-pkg-allow-list = ["numpy", "mkl_random.mklrand"] [tool.pylint.typecheck] generated-members = ["RandomState", "min", "max"] - -[tool.setuptools] -include-package-data = true -packages = ["mkl_random", "mkl_random.interfaces"] - -[tool.setuptools.dynamic] -version = {attr = "mkl_random._version.__version__"} - -[tool.setuptools.package-data] -"mkl_random" = ["tests/**/*.py"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 0b90bf9d..00000000 --- a/setup.py +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright (c) 2017, Intel Corporation -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Intel Corporation nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import os -import sys -from os.path import join - -import Cython.Build -import numpy as np -from setuptools import Extension, setup - - -def extensions(): - mkl_root = os.environ.get("MKLROOT", None) - if mkl_root: - mkl_info = { - "include_dirs": [join(mkl_root, "include")], - "library_dirs": [ - join(mkl_root, "lib"), - join(mkl_root, "lib", "intel64"), - ], - "libraries": ["mkl_rt"], - } - else: - raise ValueError("MKLROOT environment variable not set.") - - mkl_include_dirs = mkl_info.get("include_dirs", []) - mkl_library_dirs = mkl_info.get("library_dirs", []) - mkl_libraries = mkl_info.get("libraries", ["mkl_rt"]) - - libs = mkl_libraries - lib_dirs = mkl_library_dirs - - if sys.platform == "win32": - libs.append("Advapi32") - - Q = ( - "/Q" - if sys.platform.startswith("win") or sys.platform == "cygwin" - else "-" - ) - eca = [Q + "std=c++11"] - if sys.platform == "linux": - eca.extend(["-Wno-unused-but-set-variable", "-Wno-unused-function"]) - - defs = [ - ("_FILE_OFFSET_BITS", "64"), - ("_LARGEFILE_SOURCE", "1"), - ("_LARGEFILE64_SOURCE", "1"), - ("PY_ARRAY_UNIQUE_SYMBOL", "mkl_random_ext"), - ] - - exts = [ - Extension( - "mkl_random.mklrand", - sources=[ - join("mkl_random", "mklrand.pyx"), - join("mkl_random", "src", "mkl_distributions.cpp"), - join("mkl_random", "src", "randomkit.cpp"), - ], - depends=[ - join("mkl_random", "src", "mkl_distributions.hpp"), - join("mkl_random", "src", "randomkit.h"), - join("mkl_random", "src", "numpy_multiiter_workaround.h"), - ], - include_dirs=[join("mkl_random", "src"), np.get_include()] - + mkl_include_dirs, - libraries=libs, - library_dirs=lib_dirs, - extra_compile_args=eca, - define_macros=defs + [("NDEBUG", None)], - language="c++", - ), - ] - - return exts - - -setup( - cmdclass={"build_ext": Cython.Build.build_ext}, - ext_modules=extensions(), - zip_safe=False, -) From a8429b324c2ad9b34a5f72d90edde1eaecf3fbf2 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 19:12:17 -0700 Subject: [PATCH 02/24] add cmake to build system dependencies we search for MKL with cmake. Also drop pkg-config from meta.yamls and use cmake --- conda-recipe-cf/meta.yaml | 2 +- conda-recipe/meta.yaml | 2 +- pyproject.toml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index 317805af..012645a5 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -20,7 +20,7 @@ requirements: host: - meson-python >=0.13.0 - meson - - pkg-config + - cmake - python - python-gil # [py>=314] - mkl-devel diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index eee53bf4..ff55e54d 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -20,7 +20,7 @@ requirements: host: - meson-python >=0.13.0 - meson - - pkg-config + - cmake - python - python-gil # [py>=314] - mkl-devel diff --git a/pyproject.toml b/pyproject.toml index 3e26ce2b..6dddf739 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,8 @@ build-backend = "mesonpy" requires = [ "meson-python>=0.13.0", "Cython", - "numpy" + "numpy", + "cmake" ] [project] From dd8fb6cb18626d4ec9797d3821f7b4d739742246 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 20:40:28 -0700 Subject: [PATCH 03/24] use meson-python in builds --- .github/workflows/build-docs.yml | 2 +- .github/workflows/build-with-clang.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 13d07a56..144d11be 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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 cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design - name: Checkout repo uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 37eeec2a..7cb8d3ad 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -54,7 +54,7 @@ jobs: - name: Install mkl_random dependencies run: | - pip install cython setuptools">=77" + pip install meson-python ninja cython cmake pip install "${{ matrix.numpy_version }}" - name: List oneAPI folder content From e7b7b563922b0eff02dd307029c40b02548dca34 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 20:40:54 -0700 Subject: [PATCH 04/24] add pip build --- .github/workflows/build_pip.yml | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/build_pip.yml diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml new file mode 100644 index 00000000..ee02be68 --- /dev/null +++ b/.github/workflows/build_pip.yml @@ -0,0 +1,58 @@ +name: Editable build using pip and pre-release NumPy + +on: + push: + branches: + - master + pull_request: + +permissions: read-all + +env: + PACKAGE_NAME: mkl_random + MODULE_NAME: mkl_random + TEST_ENV_NAME: test_mkl_random + +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: + - name: Install jq + shell: bash -l {0} + run: | + sudo apt-get install jq + + - 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-service + python -c "import sys; print(sys.executable)" + which python + python -c "import mkl; print(mkl.__file__)" + + - name: Build conda package + 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 + pip list + python -m pytest -v mkl_random/tests From 2d1f4a4cee0d70dbb0d48d651a19747d8451e18c Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 20:56:21 -0700 Subject: [PATCH 05/24] add standard clang workflow remove tbb from build-with-clang workflow --- .github/workflows/build-with-clang.yml | 1 - .../workflows/build-with-standard-clang.yml | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-with-standard-clang.yml diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 7cb8d3ad..2594eeae 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -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 diff --git a/.github/workflows/build-with-standard-clang.yml b/.github/workflows/build-with-standard-clang.yml new file mode 100644 index 00000000..ca6a6a61 --- /dev/null +++ b/.github/workflows/build-with-standard-clang.yml @@ -0,0 +1,66 @@ +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-service + pip install 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 From 6b6bc71689b4df05493ec9d37db3d0f7dde5ee9e Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 22:08:25 -0700 Subject: [PATCH 06/24] add ninja to build system and meta.yamls --- conda-recipe-cf/meta.yaml | 1 + conda-recipe/meta.yaml | 1 + pyproject.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index 012645a5..3b94d47c 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -21,6 +21,7 @@ requirements: - meson-python >=0.13.0 - meson - cmake + - ninja - python - python-gil # [py>=314] - mkl-devel diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index ff55e54d..c309a44e 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -21,6 +21,7 @@ requirements: - meson-python >=0.13.0 - meson - cmake + - ninja - python - python-gil # [py>=314] - mkl-devel diff --git a/pyproject.toml b/pyproject.toml index 6dddf739..d17e3204 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ build-backend = "mesonpy" requires = [ "meson-python>=0.13.0", + "ninja", "Cython", "numpy", "cmake" From 668fbb5afe248a1a7e5464b41ad3000e3e460d2e Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 22:08:46 -0700 Subject: [PATCH 07/24] use pip install in build scripts aligns more closely with conda-forge feedstock --- conda-recipe-cf/bld.bat | 17 ++--------------- conda-recipe-cf/build.sh | 17 +---------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/conda-recipe-cf/bld.bat b/conda-recipe-cf/bld.bat index 29a732bd..a08c27bb 100644 --- a/conda-recipe-cf/bld.bat +++ b/conda-recipe-cf/bld.bat @@ -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 diff --git a/conda-recipe-cf/build.sh b/conda-recipe-cf/build.sh index f513746f..562c55f3 100644 --- a/conda-recipe-cf/build.sh +++ b/conda-recipe-cf/build.sh @@ -1,18 +1,3 @@ #!/bin/bash -x -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 . From 6f8d749a1c8f0a4caec4db7b57342758a347750b Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 22:12:05 -0700 Subject: [PATCH 08/24] remove MKLROOT --- conda-recipe/bld.bat | 2 -- conda-recipe/build.sh | 1 - 2 files changed, 3 deletions(-) diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index 29a732bd..fed6ce06 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -1,7 +1,5 @@ @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 . diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index f513746f..527f695c 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -2,7 +2,6 @@ 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' ' ')" From 02efc616962d664874f041b1a13387b4c860d4be Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 7 Apr 2026 23:16:51 -0700 Subject: [PATCH 09/24] don't install mkl-service in pip and standard clang builds --- .github/workflows/build-with-standard-clang.yml | 3 +-- .github/workflows/build_pip.yml | 10 +--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-with-standard-clang.yml b/.github/workflows/build-with-standard-clang.yml index ca6a6a61..94e916df 100644 --- a/.github/workflows/build-with-standard-clang.yml +++ b/.github/workflows/build-with-standard-clang.yml @@ -47,8 +47,7 @@ jobs: - name: Install mkl_random dependencies run: | - pip install meson-python ninja cmake cython mkl-service - pip install mkl-devel + pip install meson-python ninja cmake cython mkl-devel mkl pip install ${{ matrix.numpy_version }} - name: Build mkl_random diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml index ee02be68..93740aa8 100644 --- a/.github/workflows/build_pip.yml +++ b/.github/workflows/build_pip.yml @@ -26,11 +26,6 @@ jobs: use_pre: ["", "--pre"] steps: - - name: Install jq - shell: bash -l {0} - run: | - sudo apt-get install jq - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 @@ -44,10 +39,7 @@ jobs: - name: Install MKL run: | - conda install mkl-devel mkl-service - python -c "import sys; print(sys.executable)" - which python - python -c "import mkl; print(mkl.__file__)" + conda install mkl-devel mkl - name: Build conda package run: | From e2c6db2ecc4b14c70b9fffe8caaffbb656b27ecd Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 15 May 2026 18:25:48 -0700 Subject: [PATCH 10/24] add mkl_threading option --- meson.build | 2 +- meson.options | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 meson.options diff --git a/meson.build b/meson.build index 727ebde4..5da12705 100644 --- a/meson.build +++ b/meson.build @@ -45,7 +45,7 @@ mkl_dep = dependency('MKL', method: 'cmake', cmake_args: [ '-DMKL_ARCH=intel64', '-DMKL_LINK=dynamic', - '-DMKL_THREADING=intel_thread', + '-DMKL_THREADING=' + get_option('mkl_threading'), '-DMKL_INTERFACE=lp64' ], required: true diff --git a/meson.options b/meson.options new file mode 100644 index 00000000..7bd9b387 --- /dev/null +++ b/meson.options @@ -0,0 +1,7 @@ +option( + 'mkl_threading', + type: 'combo', + choices: ['intel_thread', 'tbb_thread', 'sequential', 'gnu_thread'], + value: 'intel_thread', + description: 'MKL threading layer to link to (default: intel_thread)' +) From d6652645bd3d0c7fcf9d9995ca620ae2c8286b49 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 15 May 2026 18:26:03 -0700 Subject: [PATCH 11/24] use gnu_thread in Linux conda-forge builds --- conda-recipe-cf/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe-cf/build.sh b/conda-recipe-cf/build.sh index 562c55f3..2c308764 100644 --- a/conda-recipe-cf/build.sh +++ b/conda-recipe-cf/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -x -$PYTHON -m pip install --no-build-isolation --no-deps . +$PYTHON -m pip install --no-build-isolation --no-deps -Csetup-args="-Dmkl_threading=gnu_thread" . From 03930e6010293b3a424aab1f746493e61f64c28c Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 15 May 2026 18:27:26 -0700 Subject: [PATCH 12/24] add fix to pip builds --- .github/workflows/build_pip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml index 93740aa8..0cc4b477 100644 --- a/.github/workflows/build_pip.yml +++ b/.github/workflows/build_pip.yml @@ -45,6 +45,6 @@ jobs: 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 + pip install -e ".[test]" --no-build-isolation --verbose -Csetup-args="-Dmkl_threading=gnu_thread" pip list python -m pytest -v mkl_random/tests From 9bf7d7ee5cbf859d16b7b40a58f41835101030bc Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:03:01 -0700 Subject: [PATCH 13/24] Apply remarks from mkl-service PR for meson.build --- meson.build | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 5da12705..724aa163 100644 --- a/meson.build +++ b/meson.build @@ -2,10 +2,11 @@ project( 'mkl_random', ['c', 'cpp', 'cython'], version: run_command( - 'python', '-c', - 'import os; exec(open("mkl_random/_version.py").read()); print(__version__)', + find_program('python3', 'python'), + ['-c', 'exec(open("mkl_random/_version.py").read()); print(__version__)'], check: true ).stdout().strip(), + meson_version: '>=1.8.3', default_options: [ 'cpp_std=c++11', 'buildtype=release', @@ -40,6 +41,17 @@ else cpp_args += ['-Wno-unused-but-set-variable', '-Wno-unused-function'] endif +rpath_link_args = [] +if host_machine.system() != 'windows' + if host_machine.system() == 'darwin' + origin = '@loader_path' + else + origin = '$ORIGIN' + endif + rpath = origin / '../..' + ':' + origin / '../../..' + rpath_link_args = ['-Wl,-rpath,' + rpath] +endif + mkl_dep = dependency('MKL', method: 'cmake', modules: ['MKL::MKL'], cmake_args: [ @@ -61,7 +73,7 @@ py.extension_module( include_directories: inc_np, dependencies: [mkl_dep, py_dep], cpp_args: cpp_args, - link_args: link_args, + link_args: link_args + rpath_link_args, override_options: ['cython_language=cpp'], install: true, subdir: 'mkl_random' @@ -90,5 +102,6 @@ py.install_sources( install_subdir( 'mkl_random/tests', - install_dir: py.get_install_dir() / 'mkl_random' + install_dir: py.get_install_dir() / 'mkl_random', + exclude_files: ['AGENTS.md'] ) From 60adc5f8ccdbfb29171096e11220d90ca2b4d716 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:06:05 -0700 Subject: [PATCH 14/24] Apply remarks from mkl-service PR for conda-recipe --- conda-recipe/bld.bat | 27 +++++++++++++++++---------- conda-recipe/build.sh | 35 +++++++++++++++++++++++++---------- conda-recipe/meta.yaml | 2 +- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index fed6ce06..38d7c254 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -1,13 +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 + +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 ) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 527f695c..3dab4732 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -1,17 +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 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 diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index c309a44e..1b40a08b 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -19,7 +19,7 @@ requirements: - {{ stdlib('c') }} host: - meson-python >=0.13.0 - - meson + - python-build >=1.2.2 - cmake - ninja - python From 72f9a2d8ba3f3a6049195c23e3dea8212e9f8418 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:08:49 -0700 Subject: [PATCH 15/24] Update conda-recipe-cf --- conda-recipe-cf/build.sh | 2 +- conda-recipe-cf/meta.yaml | 2 +- meson.build | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conda-recipe-cf/build.sh b/conda-recipe-cf/build.sh index 2c308764..d52c78b4 100644 --- a/conda-recipe-cf/build.sh +++ b/conda-recipe-cf/build.sh @@ -1,3 +1,3 @@ -#!/bin/bash -x +#!/bin/bash -ex $PYTHON -m pip install --no-build-isolation --no-deps -Csetup-args="-Dmkl_threading=gnu_thread" . diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index 3b94d47c..f8ad89af 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -31,7 +31,7 @@ requirements: - 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") }} diff --git a/meson.build b/meson.build index 724aa163..17a2f69f 100644 --- a/meson.build +++ b/meson.build @@ -102,6 +102,5 @@ py.install_sources( install_subdir( 'mkl_random/tests', - install_dir: py.get_install_dir() / 'mkl_random', - exclude_files: ['AGENTS.md'] + install_dir: py.get_install_dir() / 'mkl_random' ) From 7483cfb9c60f31c53f408ea2b2005c760d95a996 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:12:46 -0700 Subject: [PATCH 16/24] Add missing python source file to meson.build --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 17a2f69f..8247ffaa 100644 --- a/meson.build +++ b/meson.build @@ -84,9 +84,13 @@ py.extension_module( py.install_sources( [ 'mkl_random/__init__.py', + 'mkl_random/__main__.py', 'mkl_random/_init_helper.py', 'mkl_random/_patch_numpy.py', + 'mkl_random/_patch_startup.py', 'mkl_random/_version.py', + 'mkl_random/patch.py', + 'mkl_random/with_patch.py', ], subdir: 'mkl_random' ) From 74a8ae0ab291bbb61e8d8bef350731f484dd991c Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:25:59 -0700 Subject: [PATCH 17/24] Clean up github workflows --- .github/workflows/build-docs.yml | 2 +- .github/workflows/build-with-clang.yml | 2 +- .github/workflows/build-with-standard-clang.yml | 2 +- .github/workflows/build_pip.yml | 2 +- conda-recipe-cf/meta.yaml | 1 - 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 4c1cbde9..474f059b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -41,7 +41,7 @@ jobs: if: ${{ !github.event.pull_request || github.event.action != 'closed' }} shell: bash -l {0} run: | - pip install meson-python ninja cython cmake numpy 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: diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 61459d8a..2c5ba096 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -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 diff --git a/.github/workflows/build-with-standard-clang.yml b/.github/workflows/build-with-standard-clang.yml index 94e916df..927e2781 100644 --- a/.github/workflows/build-with-standard-clang.yml +++ b/.github/workflows/build-with-standard-clang.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: python: ["3.10", "3.11", "3.12", "3.13", "3.14"] - numpy_version: ["numpy'>=2'"] + numpy_version: ["'numpy>=2'"] env: COMPILER_ROOT: /usr/bin diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml index 0cc4b477..a5573251 100644 --- a/.github/workflows/build_pip.yml +++ b/.github/workflows/build_pip.yml @@ -41,7 +41,7 @@ jobs: run: | conda install mkl-devel mkl - - name: Build conda package + - name: Build with pip run: | pip install --no-cache-dir meson-python ninja cmake cython pip install --no-cache-dir numpy ${{ matrix.use_pre }} diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index f8ad89af..44b75c22 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -19,7 +19,6 @@ requirements: - {{ stdlib('c') }} host: - meson-python >=0.13.0 - - meson - cmake - ninja - python From 6819973e80818950e31ecb1a0352862a1ae48e41 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:34:28 -0700 Subject: [PATCH 18/24] Remove unused env variables from build_pip.yml --- .github/workflows/build_pip.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml index a5573251..c7ec10ba 100644 --- a/.github/workflows/build_pip.yml +++ b/.github/workflows/build_pip.yml @@ -8,11 +8,6 @@ on: permissions: read-all -env: - PACKAGE_NAME: mkl_random - MODULE_NAME: mkl_random - TEST_ENV_NAME: test_mkl_random - jobs: build: runs-on: ubuntu-latest From 59da27693013a4cc69a32b98bc03282cc126be05 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:38:37 -0700 Subject: [PATCH 19/24] Add Building from source block to README.md --- README.md | 26 ++++++++++++++++++++++---- meson.build | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b58ae37f..cd5e40c8 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,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 . +``` diff --git a/meson.build b/meson.build index 8247ffaa..4a3737c9 100644 --- a/meson.build +++ b/meson.build @@ -63,6 +63,7 @@ mkl_dep = dependency('MKL', method: 'cmake', required: true ) +# Cython extension py.extension_module( 'mklrand', sources: [ @@ -79,8 +80,8 @@ py.extension_module( subdir: 'mkl_random' ) -# install python sources +# Python sources py.install_sources( [ 'mkl_random/__init__.py', From b98b4db407b3351934998c9ed22b55ac8edb9b58 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:41:55 -0700 Subject: [PATCH 20/24] A small clean up --- .github/workflows/build_pip.yml | 2 +- meson.build | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_pip.yml b/.github/workflows/build_pip.yml index c7ec10ba..2903a39a 100644 --- a/.github/workflows/build_pip.yml +++ b/.github/workflows/build_pip.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: bash -el {0} + shell: bash -el {0} strategy: matrix: diff --git a/meson.build b/meson.build index 4a3737c9..1141fbaa 100644 --- a/meson.build +++ b/meson.build @@ -80,7 +80,6 @@ py.extension_module( subdir: 'mkl_random' ) - # Python sources py.install_sources( [ From c925f2b85e9ccdcc3a7d2c3b99b91b0a92232b15 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 04:59:51 -0700 Subject: [PATCH 21/24] Remove redundant mkl from build-with-standard-clang dependencies --- .github/workflows/build-with-standard-clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-with-standard-clang.yml b/.github/workflows/build-with-standard-clang.yml index 927e2781..e8176e47 100644 --- a/.github/workflows/build-with-standard-clang.yml +++ b/.github/workflows/build-with-standard-clang.yml @@ -47,7 +47,7 @@ jobs: - name: Install mkl_random dependencies run: | - pip install meson-python ninja cmake cython mkl-devel mkl + pip install meson-python ninja cmake cython mkl-devel pip install ${{ matrix.numpy_version }} - name: Build mkl_random From b60d962dfeb438b19a4c643835470245c531dcfc Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 05:09:19 -0700 Subject: [PATCH 22/24] Fix numpy install in GH CI workflows --- .github/workflows/build-with-clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 2c5ba096..5e16c4d6 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -54,7 +54,7 @@ jobs: - name: Install mkl_random dependencies run: | pip install meson-python ninja cython cmake - pip install "${{ matrix.numpy_version }}" + pip install ${{ matrix.numpy_version }} - name: List oneAPI folder content run: ls "${{ env.ONEAPI_ROOT }}/compiler" From a80ff598a24a7c0f2320fc9df9e33c9a02084566 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 05:10:55 -0700 Subject: [PATCH 23/24] add CI badges to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cd5e40c8..1e58e898 100644 --- a/README.md +++ b/README.md @@ -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. From 01d2179f0017591c58c51465b520aca48ab2ef34 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 23 Jul 2026 06:22:53 -0700 Subject: [PATCH 24/24] Fix MKL detection with non-Intel clang++ --- meson.build | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 1141fbaa..61c3430d 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'mkl_random', - ['c', 'cpp', 'cython'], + ['c', 'cython'], version: run_command( find_program('python3', 'python'), ['-c', 'exec(open("mkl_random/_version.py").read()); print(__version__)'], @@ -25,7 +25,6 @@ np_dir = run_command(py, inc_np = include_directories(np_dir, 'mkl_random/src') # compiler/linker -cpp = meson.get_compiler('cpp') cpp_args = [ '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE=1', @@ -35,12 +34,6 @@ cpp_args = [ ] link_args = [] -if cpp.get_argument_syntax() == 'msvc' - link_args += ['Advapi32.lib'] -else - cpp_args += ['-Wno-unused-but-set-variable', '-Wno-unused-function'] -endif - rpath_link_args = [] if host_machine.system() != 'windows' if host_machine.system() == 'darwin' @@ -63,7 +56,18 @@ mkl_dep = dependency('MKL', method: 'cmake', required: true ) -# Cython extension +# cpp must be added after MKL detection: +# MKLConfig.cmake runs check_cxx_compiler_flag when CXX is present +# in the cmake toolchain which fails with non-Intel clang++ +add_languages('cpp', native: false) +cpp = meson.get_compiler('cpp') + +if cpp.get_argument_syntax() == 'msvc' + link_args += ['Advapi32.lib'] +else + cpp_args += ['-Wno-unused-but-set-variable', '-Wno-unused-function'] +endif + py.extension_module( 'mklrand', sources: [