Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 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:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,7 +53,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
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 mkl
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
50 changes: 50 additions & 0 deletions .github/workflows/build_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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:
- 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 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
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
17 changes: 1 addition & 16 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -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 .
5 changes: 4 additions & 1 deletion conda-recipe-cf/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
- meson
- cmake
- ninja
- python
- python-gil # [py>=314]
- setuptools >=77
- mkl-devel
- cython
- numpy
Expand Down
2 changes: 0 additions & 2 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -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 .
Expand Down
1 change: 0 additions & 1 deletion conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' ' ')"
Expand Down
5 changes: 4 additions & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ requirements:
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
- meson
- cmake
- ninja
- python
- python-gil # [py>=314]
- setuptools >=77
- mkl-devel
- cython
{% if use_numpy_base %}
Expand Down
94 changes: 94 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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'
)
48 changes: 0 additions & 48 deletions mkl_random/src/generate_mklrand_c.py

This file was deleted.

Loading
Loading