Skip to content

Add conda recipe cf and workflow #118

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

Merged
merged 2 commits into from
Aug 15, 2024
Merged
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
256 changes: 256 additions & 0 deletions .github/workflows/conda-package-cf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
name: Conda package with conda-forge channel only

on: push

permissions: read-all

env:
PACKAGE_NAME: mkl_fft
MODULE_NAME: mkl_fft
TEST_ENV_NAME: test_mkl_fft

jobs:
build:
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 with NumPy 2
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

test:
needs: build
runs-on: ${{ matrix.runner }}

strategy:
matrix:
python_ver: ['3.9', '3.10', '3.11', '3.12']
numpy: ['numpy"<2"', 'numpy">=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_ver }}
- 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
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
conda index $GITHUB_WORKSPACE/channel
# Test channel
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels

- name: Collect dependencies
run: |
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME python=${{ matrix.python_ver }} ${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
- name: Display lockfile
run: 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_ver }}-${{hashFiles('lockfile') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

- name: Install mkl_fft
run: |
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python_ver }} ${{ matrix.numpy }} $PACKAGE_NAME pytest $CHANNELS
# Test installed packages
conda list -n ${{ env.TEST_ENV_NAME }}
- name: Run tests
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate ${{ env.TEST_ENV_NAME }}
pytest -v --pyargs $MODULE_NAME

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
conda-build-version: "*"
activate-environment: true
python-version: ${{ matrix.python }}

- 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: Build conda package with NumPy 2.0
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_windows:
needs: build_windows
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: cmd /C CALL {0}
strategy:
matrix:
python_ver: ['3.9', '3.10', '3.11', '3.12']
numpy: ['numpy"<2"', 'numpy">=2"']
experimental: [false]
runner: [windows-2019]
continue-on-error: ${{ matrix.experimental }}
env:
workdir: '${{ github.workspace }}'
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_ver }}
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
conda-build-version: '*'
miniconda-version: 'latest'
activate-environment: mkl_fft_test
python-version: ${{ matrix.python_ver }}
- name: Create conda channel with the artifact bit
shell: cmd /C CALL {0}
run: |
echo ${{ env.workdir }}
mkdir ${{ env.workdir }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
dir ${{ env.workdir }}\channel\win-64
- name: Index the channel
shell: cmd /C CALL {0}
run: conda index ${{ env.workdir }}\channel

- name: Dump mkl_fft version info from created channel into ver.json
shell: cmd /C CALL {0}
run: |
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
- name: Output content of produced ver.json
shell: pwsh
run: Get-Content -Path ${{ env.workdir }}\ver.json
- name: Collect dependencies
shell: cmd /C CALL {0}
run: |
IF NOT EXIST ver.json (
copy /Y ${{ env.workdir }}\ver.json .
)
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python_ver }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
- name: Display lockfile content
shell: pwsh
run: Get-Content -Path .\lockfile
- name: Cache conda packages
uses: actions/cache@v4
env:
CACHE_NUMBER: 0 # Increase to reset cache
with:
path: /home/runner/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-${{hashFiles('lockfile') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
- name: Install mkl_fft
shell: cmd /C CALL {0}
run: |
@ECHO ON
IF NOT EXIST ver.json (
copy /Y ${{ env.workdir }}\ver.json .
)
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
SET "TEST_DEPENDENCIES=pytest pytest-cov"
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
- name: Report content of test environment
shell: cmd /C CALL {0}
run: |
echo "Value of CONDA enviroment variable was: " %CONDA%
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
conda info && conda list -n mkl_fft_test
- name: Run tests
shell: cmd /C CALL {0}
run: >-
conda activate mkl_fft_test && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}

2 changes: 1 addition & 1 deletion .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
runner: [ubuntu-latest]
continue-on-error: ${{ matrix.experimental }}
env:
CHANNELS: -c https://software.repos.intel.com/python/conda -c main --override-channels
CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels

steps:
- name: Download artifact
Expand Down
3 changes: 3 additions & 0 deletions conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set MKLROOT=%PREFIX%
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
10 changes: 10 additions & 0 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -x

if [ `uname` == Darwin ]; then
export MACOSX_DEPLOYMENT_TARGET=10.9
fi

export MKLROOT=$PREFIX
export CFLAGS="-I$PREFIX/include $CFLAGS"
$PYTHON -m pip install --no-build-isolation --no-deps .

46 changes: 46 additions & 0 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% set version = "1.3.10" %}
{% set buildnumber = 0 %}

package:
name: mkl_fft
version: {{ version }}

source:
path: ../

build:
number: {{ buildnumber }}
ignore_run_exports:
- blas

requirements:
build:
- {{ compiler('c') }}
host:
- python
- setuptools
- mkl-devel
- cython
- numpy
run:
- python
- mkl
- mkl-service
- numpy

test:
commands:
- pytest -v --pyargs mkl_fft
requires:
- pytest
imports:
- mkl_fft
- mkl_fft.interfaces
- mkl_fft.interfaces.numpy_fft
- mkl_fft.interfaces.scipy_fft

about:
home: http://github.com/IntelPython/mkl_fft
license: BSD-3
license_file: LICENSE.txt
summary: NumPy-based implementation of Fast Fourier Transform using Intel (R) Math Kernel Library
Empty file removed conda-recipe/run_test.py
Empty file.
Loading