Skip to content

Migrate random to pyproject.toml from setup.py #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
36a187e
Update workflows to use .conda for conda package builds
ndgrigorian Mar 25, 2025
9711f79
Use `--numpy 2.0`
ndgrigorian Mar 25, 2025
b6a5bb4
Add pyproject.toml and migrate from setup.py
ndgrigorian Apr 13, 2025
40645ad
Add build instructions to README
ndgrigorian Apr 13, 2025
ff67a36
Clean up pyproject.toml
ndgrigorian Apr 13, 2025
ce8ca25
Pin setuptools to greater than 77
ndgrigorian Apr 13, 2025
c1832ab
Fix Conda package workflows on PRs
ndgrigorian Apr 13, 2025
6c52bd3
Remove numpy as dependency for tests
ndgrigorian Apr 13, 2025
b155c87
Remove mkl-service as test requirement
ndgrigorian Apr 13, 2025
f3b3d40
Change pip to install in build scripts
ndgrigorian Apr 13, 2025
5ee291c
Remove license family
ndgrigorian Apr 13, 2025
3a59787
Install with pip in clang build
ndgrigorian Apr 13, 2025
1b3437d
Install wheel package in clang builds
ndgrigorian Apr 13, 2025
0c05403
Pin setuptools in CI to >=77
ndgrigorian Apr 13, 2025
359fe9d
Adjust pyproject.toml and setup.py license headers
ndgrigorian Apr 13, 2025
04e3207
Update README.md
ndgrigorian Apr 14, 2025
f8b2e7c
Raise ValueError if `MKLROOT` variable is not set
ndgrigorian Apr 14, 2025
41a07e7
Remove insertion of setup.py in path
ndgrigorian Apr 14, 2025
7b5a63e
Apply review comments to clang workflow
ndgrigorian Apr 14, 2025
5aabb91
remove defaults channel
ndgrigorian Apr 14, 2025
59b354d
Add openmp as explicit dependency in test_windows step
ndgrigorian Apr 15, 2025
a4ba7f2
Run conda-package workflow on 3.11 and 3.12 as well
ndgrigorian Apr 15, 2025
64bdbe5
Run all workflows on all supported Python versions
ndgrigorian Apr 15, 2025
5e56f05
Run docs workflow on Python 3.12
ndgrigorian Apr 15, 2025
2c69830
Make mkl_random dependencies consistent in clang build
ndgrigorian Apr 16, 2025
1294dc7
Update build instructions in docs
ndgrigorian Apr 16, 2025
cfb8e0a
Attempt using editable wheel build in docs build
ndgrigorian Apr 16, 2025
482aa53
Update Clang worfklow
ndgrigorian Apr 17, 2025
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
7 changes: 4 additions & 3 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build mkl_random documentation

on:
pull_request:
push:
Expand Down Expand Up @@ -34,13 +35,13 @@ jobs:
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.12"
architecture: x64
- name: Install sphinx dependencies
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
shell: bash -l {0}
run: |
pip install numpy cython setuptools scikit-build cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
pip install numpy cython setuptools">=77" scikit-build cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design
- name: Checkout repo
uses: actions/[email protected]
with:
Expand All @@ -52,7 +53,7 @@ jobs:
run: |
# Ensure that SYCL libraries are on LD_LIBRARY_PATH
source /opt/intel/oneapi/setvars.sh
python setup.py develop
pip install --no-deps --no-build-isolation -e . --verbose
python -c "import mkl_random; print(mkl_random.__version__)" || exit 1
sphinx-build -M html docs/source docs/build
mkdir -p ~/rendered_docs
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12"]
numpy_build_version: ["numpy'<2'", "numpy'>=2'"]

numpy_version: ["numpy'<2'", "numpy'>=2'"]
env:
ONEAPI_ROOT: /opt/intel/oneapi

Expand Down Expand Up @@ -55,8 +54,8 @@ jobs:

- name: Install mkl_random dependencies
run: |
pip install cython setuptools pytest pytest-cov
pip install ${{ matrix.numpy_build_version }}
pip install cython setuptools">=77"
pip install ${{ matrix.numpy_version }}

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

- name: Run mkl_random tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
# Test with NumPy<2 for now
pip install numpy"<2"
pip install pytest
pytest -s -v --pyargs mkl_random
19 changes: 12 additions & 7 deletions .github/workflows/conda-package-cf.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Conda package using conda-forge

on: push
on:
pull_request:
push:
branches: [master]

permissions: read-all

Expand Down Expand Up @@ -44,7 +47,7 @@ jobs:
- name: Build conda package
run: |
CHANNELS="-c conda-forge --override-channels"
VERSIONS="--python ${{ matrix.python }} --numpy 2"
VERSIONS="--python ${{ matrix.python }} --numpy 2.0"
TEST="--no-test"

conda build \
Expand All @@ -56,7 +59,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda

build_windows:
runs-on: windows-2019
Expand All @@ -72,6 +75,7 @@ jobs:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true
auto-activate-base: true
activate-environment: ""

Expand All @@ -89,12 +93,12 @@ jobs:
- name: Install conda-build
run: conda install conda-build
- name: Build conda package
run: conda build --no-test --python ${{ matrix.python }} --numpy 2 -c conda-forge --override-channels conda-recipe-cf
run: conda build --no-test --python ${{ matrix.python }} --numpy 2.0 -c conda-forge --override-channels conda-recipe-cf
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.conda

test_linux:
needs: build_linux
Expand Down Expand Up @@ -123,7 +127,7 @@ jobs:
run: |
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
conda index $GITHUB_WORKSPACE/channel || exit 1
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 || exit 1
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
conda index $GITHUB_WORKSPACE/channel || exit 1
# Test channel
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
Expand Down Expand Up @@ -185,6 +189,7 @@ jobs:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
- uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true
auto-activate-base: true
activate-environment: ""
- name: Install conda-build
Expand All @@ -193,7 +198,7 @@ jobs:
- name: Create conda channel
run: |
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.GITHUB_WORKSPACE }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
conda index ${{ env.GITHUB_WORKSPACE }}/channel
# Test channel
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
Expand Down
29 changes: 19 additions & 10 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Conda package

on: push
on:
pull_request:
push:
branches: [master]

permissions: read-all

Expand All @@ -16,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10"]
python: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -56,14 +59,14 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda

build_windows:
runs-on: windows-2019

strategy:
matrix:
python: ['3.9', '3.10']
python: ["3.9", "3.10", "3.11", "3.12"]
env:
conda-bld: C:\Miniconda\conda-bld\win-64\
steps:
Expand All @@ -72,6 +75,7 @@ jobs:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true
auto-activate-base: true
activate-environment: ""

Expand All @@ -94,15 +98,15 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.conda

test_linux:
needs: build_linux
runs-on: ${{ matrix.runner }}

strategy:
matrix:
python: ['3.9', '3.10']
python: ["3.9", "3.10", "3.11", "3.12"]
numpy: ['1.26*']
experimental: [false]
runner: [ubuntu-latest]
Expand All @@ -123,7 +127,7 @@ jobs:
run: |
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
conda index $GITHUB_WORKSPACE/channel || exit 1
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 || exit 1
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
conda index $GITHUB_WORKSPACE/channel || exit 1
# Test channel
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
Expand Down Expand Up @@ -170,7 +174,7 @@ jobs:

strategy:
matrix:
python: ['3.9', '3.10']
python: ["3.9", "3.10", "3.11", "3.12"]
numpy: ['1.26*']
experimental: [false]
runner: [windows-2019]
Expand All @@ -185,6 +189,7 @@ jobs:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
- uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true
auto-activate-base: true
activate-environment: ""
- name: Install conda-build
Expand All @@ -193,7 +198,7 @@ jobs:
- name: Create conda channel
run: |
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.GITHUB_WORKSPACE }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
conda index ${{ env.GITHUB_WORKSPACE }}/channel
# Test channel
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
Expand All @@ -220,6 +225,9 @@ jobs:
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

# add intel-openmp as an explicit dependency
# to avoid it being missed when package version is specified exactly
- name: Install mkl_random
shell: cmd
run: |
Expand All @@ -229,7 +237,8 @@ jobs:
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
SET "WORKAROUND_DEPENDENCIES=intel-openmp"
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %WORKAROUND_DEPENDENCIES% pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
# Test installed packages
conda list
- name: Run tests
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ The list of supported by `mkl_random.RandomState` constructor `brng` keywords is
* 'PHILOX4X32X10'
* 'NONDETERM'
* 'ARS5'

---

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 .`
2 changes: 1 addition & 1 deletion conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@rem Remember to source the compiler

set MKLROOT=%CONDA_PREFIX%
%PYTHON% setup.py install
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
2 changes: 1 addition & 1 deletion conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export CFLAGS="-I$PREFIX/include $CFLAGS"
export MKLROOT=$CONDA_PREFIX
$PYTHON setup.py install
$PYTHON -m pip install --no-build-isolation --no-deps .
5 changes: 1 addition & 4 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ requirements:
- {{ compiler('cxx') }}
host:
- python
- setuptools
- setuptools >=77
- mkl-devel
- cython
- numpy
Expand All @@ -34,15 +34,12 @@ test:
- pytest --pyargs mkl_random
requires:
- pytest
- mkl-service
- numpy
imports:
- mkl_random
- mkl_random.mklrand

about:
home: http://github.com/IntelPython/mkl_random
license: BSD-3-Clause
license_family: BSD
license_file: LICENSE.txt
summary: NumPy-based implementation of random number generation sampling using Intel (R) Math Kernel Library, mirroring numpy.random, but exposing all choices of sampling algorithms available in MKL.
2 changes: 1 addition & 1 deletion conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@rem Remember to source the compiler

set MKLROOT=%CONDA_PREFIX%
%PYTHON% setup.py install
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
2 changes: 1 addition & 1 deletion conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export CFLAGS="-I$PREFIX/include $CFLAGS"
export MKLROOT=$CONDA_PREFIX
$PYTHON setup.py install
$PYTHON -m pip install --no-build-isolation --no-deps .
5 changes: 1 addition & 4 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ requirements:
- {{ compiler('cxx') }}
host:
- python
- setuptools
- setuptools >=77
- mkl-devel
- cython
- numpy-base
Expand All @@ -34,15 +34,12 @@ test:
- pytest --pyargs mkl_random
requires:
- pytest
- mkl-service
- numpy
imports:
- mkl_random
- mkl_random.mklrand

about:
home: http://github.com/IntelPython/mkl_random
license: BSD-3-Clause
license_family: BSD
license_file: LICENSE.txt
summary: NumPy-based implementation of random number generation sampling using Intel (R) Math Kernel Library, mirroring numpy.random, but exposing all choices of sampling algorithms available in MKL.
2 changes: 1 addition & 1 deletion docs/source/maintenance/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ can be found.
:caption: Building mkl_random

$ export MKLROOT=</path/to/mkl>
python setup.py develop
python -m pip install .

To run test suite, install :mod:`pytest`, and run

Expand Down
Loading