-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from IntelPython/build-and-test-with-numpy-2
Add workflow to build from conda-forge only
- Loading branch information
Showing
6 changed files
with
316 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
name: Conda package using conda-forge | ||
|
||
on: push | ||
|
||
permissions: read-all | ||
|
||
env: | ||
PACKAGE_NAME: mkl_random | ||
MODULE_NAME: mkl_random | ||
TEST_ENV_NAME: test_mkl_random | ||
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); " | ||
VER_SCRIPT2: "d = j['mkl_random'][0]; print('='.join((d[s] for s in ('version', 'build'))))" | ||
|
||
jobs: | ||
build_linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ["3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set pkgs_dirs | ||
run: | | ||
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc | ||
- name: Cache conda packages | ||
uses: actions/cache@v4 | ||
env: | ||
CACHE_NUMBER: 0 # Increase to reset cache | ||
with: | ||
path: ~/.conda/pkgs | ||
key: | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | ||
- name: Add conda to system path | ||
run: echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Install conda-build | ||
run: conda install conda-build | ||
- name: Build conda package | ||
run: | | ||
CHANNELS="-c conda-forge --override-channels" | ||
VERSIONS="--python ${{ matrix.python }} --numpy 2" | ||
TEST="--no-test" | ||
conda build \ | ||
$TEST \ | ||
$VERSIONS \ | ||
$CHANNELS \ | ||
conda-recipe-cf | ||
- name: Upload artifact | ||
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 | ||
|
||
build_windows: | ||
runs-on: windows-2019 | ||
|
||
strategy: | ||
matrix: | ||
python: ["3.9", "3.10", "3.11", "3.12"] | ||
env: | ||
conda-bld: C:\Miniconda\conda-bld\win-64\ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
auto-activate-base: true | ||
activate-environment: "" | ||
|
||
- name: Cache conda packages | ||
uses: actions/cache@v4 | ||
env: | ||
CACHE_NUMBER: 3 # Increase to reset cache | ||
with: | ||
path: /home/runner/conda_pkgs_dir | ||
key: | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | ||
- 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 | ||
- 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 | ||
|
||
test_linux: | ||
needs: build_linux | ||
runs-on: ${{ matrix.runner }} | ||
|
||
strategy: | ||
matrix: | ||
python: ["3.9", "3.10", "3.11", "3.12"] | ||
numpy: ["1.26*", "2*"] | ||
experimental: [false] | ||
runner: [ubuntu-latest] | ||
continue-on-error: ${{ matrix.experimental }} | ||
env: | ||
CHANNELS: -c conda-forge --override-channels | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | ||
- name: Add conda to system path | ||
run: echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Install conda-build | ||
run: conda install conda-build | ||
- name: Create conda channel | ||
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 | ||
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 | ||
cat ver.json | ||
- name: Collect dependencies | ||
run: | | ||
. $CONDA/etc/profile.d/conda.sh | ||
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" | ||
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | ||
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile | ||
cat lockfile | ||
- name: Set pkgs_dirs | ||
run: | | ||
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc | ||
- name: Cache conda packages | ||
uses: actions/cache@v4 | ||
env: | ||
CACHE_NUMBER: 0 # Increase to reset cache | ||
with: | ||
path: ~/.conda/pkgs | ||
key: | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} | ||
restore-keys: | | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | ||
- name: Install mkl_random | ||
run: | | ||
. $CONDA/etc/profile.d/conda.sh | ||
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" | ||
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | ||
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS | ||
# Test installed packages | ||
conda list | ||
- name: Run tests | ||
run: | | ||
. $CONDA/etc/profile.d/conda.sh | ||
conda activate ${{ env.TEST_ENV_NAME }} | ||
pytest -vv --pyargs ${{ env.MODULE_NAME }} | ||
test_windows: | ||
needs: build_windows | ||
runs-on: ${{ matrix.runner }} | ||
|
||
strategy: | ||
matrix: | ||
python: ["3.9", "3.10", "3.11", "3.12"] | ||
numpy: ["1.26*", "2*"] | ||
experimental: [false] | ||
runner: [windows-2019] | ||
continue-on-error: ${{ matrix.experimental }} | ||
env: | ||
CHANNELS: -c conda-forge --override-channels | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
auto-activate-base: true | ||
activate-environment: "" | ||
- name: Install conda-build | ||
# Needed to be able to run conda index | ||
run: conda install conda-build | ||
- name: Create conda channel | ||
run: | | ||
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64 | ||
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ 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 | ||
more ${{ env.GITHUB_WORKSPACE }}\ver.json | ||
- name: Collect dependencies | ||
shell: cmd | ||
run: | | ||
@ECHO ON | ||
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json . | ||
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" | ||
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% python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile | ||
more lockfile | ||
- name: Cache conda packages | ||
uses: actions/cache@v4 | ||
env: | ||
CACHE_NUMBER: 3 # Increase to reset cache | ||
with: | ||
path: /home/runner/conda_pkgs_dir | ||
key: | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} | ||
restore-keys: | | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | ||
- name: Install mkl_random | ||
shell: cmd | ||
run: | | ||
@ECHO ON | ||
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json . | ||
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" | ||
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 }} | ||
# Test installed packages | ||
conda list | ||
- name: Run tests | ||
run: | | ||
conda activate -n ${{ env.TEST_ENV_NAME }} | ||
pytest -v --pyargs ${{ env.MODULE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@rem Remember to source the compiler | ||
|
||
set MKLROOT=%CONDA_PREFIX% | ||
%PYTHON% setup.py install | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash -x | ||
|
||
export CFLAGS="-I$PREFIX/include $CFLAGS" | ||
export MKLROOT=$CONDA_PREFIX | ||
$PYTHON setup.py install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% set version = "1.2.6" %} | ||
{% set buildnumber = 0 %} | ||
|
||
package: | ||
name: mkl_random | ||
version: {{ version }} | ||
|
||
source: | ||
path: .. | ||
|
||
build: | ||
number: {{buildnumber}} | ||
ignore_run_exports: | ||
- blas | ||
|
||
requirements: | ||
build: | ||
- {{ compiler('c') }} | ||
- {{ compiler('cxx') }} | ||
host: | ||
- python | ||
- setuptools | ||
- mkl-devel | ||
- cython | ||
- numpy | ||
- pip | ||
run: | ||
- python | ||
- numpy | ||
- {{ pin_compatible('mkl', min_pin="x.x", max_pin="x") }} | ||
|
||
test: | ||
commands: | ||
- 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. |
Oops, something went wrong.