Skip to content

Commit db00c87

Browse files
Merge pull request #118 from IntelPython/add-conda-recipe-cf-and-workflow
Add conda recipe cf and workflow
2 parents 3bf452f + 6b2e298 commit db00c87

File tree

6 files changed

+316
-1
lines changed

6 files changed

+316
-1
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: Conda package with conda-forge channel only
2+
3+
on: push
4+
5+
permissions: read-all
6+
7+
env:
8+
PACKAGE_NAME: mkl_fft
9+
MODULE_NAME: mkl_fft
10+
TEST_ENV_NAME: test_mkl_fft
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python: ['3.9', '3.10', '3.11', '3.12']
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set pkgs_dirs
24+
run: |
25+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
26+
- name: Cache conda packages
27+
uses: actions/cache@v4
28+
env:
29+
CACHE_NUMBER: 0 # Increase to reset cache
30+
with:
31+
path: ~/.conda/pkgs
32+
key:
33+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
34+
restore-keys: |
35+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
36+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
37+
38+
- name: Add conda to system path
39+
run: echo $CONDA/bin >> $GITHUB_PATH
40+
- name: Install conda-build
41+
run: conda install conda-build
42+
- name: Build conda package with NumPy 2
43+
run: |
44+
CHANNELS="-c conda-forge --override-channels"
45+
VERSIONS="--python ${{ matrix.python }} --numpy 2"
46+
TEST="--no-test"
47+
48+
conda build \
49+
$TEST \
50+
$VERSIONS \
51+
$CHANNELS \
52+
conda-recipe-cf
53+
- name: Upload artifact
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
57+
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
58+
59+
test:
60+
needs: build
61+
runs-on: ${{ matrix.runner }}
62+
63+
strategy:
64+
matrix:
65+
python_ver: ['3.9', '3.10', '3.11', '3.12']
66+
numpy: ['numpy"<2"', 'numpy">=2"']
67+
experimental: [false]
68+
runner: [ubuntu-latest]
69+
continue-on-error: ${{ matrix.experimental }}
70+
env:
71+
CHANNELS: -c conda-forge --override-channels
72+
73+
steps:
74+
- name: Download artifact
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_ver }}
78+
- name: Add conda to system path
79+
run: echo $CONDA/bin >> $GITHUB_PATH
80+
- name: Install conda-build
81+
run: conda install conda-build
82+
- name: Create conda channel
83+
run: |
84+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
85+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
86+
conda index $GITHUB_WORKSPACE/channel
87+
# Test channel
88+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
89+
90+
- name: Collect dependencies
91+
run: |
92+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
93+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME python=${{ matrix.python_ver }} ${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
94+
- name: Display lockfile
95+
run: cat lockfile
96+
- name: Set pkgs_dirs
97+
run: |
98+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
99+
- name: Cache conda packages
100+
uses: actions/cache@v4
101+
env:
102+
CACHE_NUMBER: 0 # Increase to reset cache
103+
with:
104+
path: ~/.conda/pkgs
105+
key:
106+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-${{hashFiles('lockfile') }}
107+
restore-keys: |
108+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
109+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
110+
111+
- name: Install mkl_fft
112+
run: |
113+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
114+
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python_ver }} ${{ matrix.numpy }} $PACKAGE_NAME pytest $CHANNELS
115+
# Test installed packages
116+
conda list -n ${{ env.TEST_ENV_NAME }}
117+
- name: Run tests
118+
run: |
119+
source $CONDA/etc/profile.d/conda.sh
120+
conda activate ${{ env.TEST_ENV_NAME }}
121+
pytest -v --pyargs $MODULE_NAME
122+
123+
build_windows:
124+
runs-on: windows-2019
125+
126+
strategy:
127+
matrix:
128+
python: ['3.9', '3.10', '3.11', '3.12']
129+
env:
130+
conda-bld: C:\Miniconda\conda-bld\win-64\
131+
steps:
132+
- uses: actions/checkout@v4
133+
with:
134+
fetch-depth: 0
135+
- uses: conda-incubator/setup-miniconda@v3
136+
with:
137+
auto-activate-base: true
138+
conda-build-version: "*"
139+
activate-environment: true
140+
python-version: ${{ matrix.python }}
141+
142+
- name: Cache conda packages
143+
uses: actions/cache@v4
144+
env:
145+
CACHE_NUMBER: 3 # Increase to reset cache
146+
with:
147+
path: /home/runner/conda_pkgs_dir
148+
key:
149+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
150+
restore-keys: |
151+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
152+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
153+
- name: Build conda package with NumPy 2.0
154+
run: conda build --no-test --python ${{ matrix.python }} --numpy 2 -c conda-forge --override-channels conda-recipe-cf
155+
- name: Upload artifact
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
159+
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
160+
161+
test_windows:
162+
needs: build_windows
163+
runs-on: ${{ matrix.runner }}
164+
defaults:
165+
run:
166+
shell: cmd /C CALL {0}
167+
strategy:
168+
matrix:
169+
python_ver: ['3.9', '3.10', '3.11', '3.12']
170+
numpy: ['numpy"<2"', 'numpy">=2"']
171+
experimental: [false]
172+
runner: [windows-2019]
173+
continue-on-error: ${{ matrix.experimental }}
174+
env:
175+
workdir: '${{ github.workspace }}'
176+
CHANNELS: -c conda-forge --override-channels
177+
178+
steps:
179+
- name: Download artifact
180+
uses: actions/download-artifact@v4
181+
with:
182+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_ver }}
183+
- uses: conda-incubator/setup-miniconda@v3
184+
with:
185+
auto-update-conda: true
186+
conda-build-version: '*'
187+
miniconda-version: 'latest'
188+
activate-environment: mkl_fft_test
189+
python-version: ${{ matrix.python_ver }}
190+
- name: Create conda channel with the artifact bit
191+
shell: cmd /C CALL {0}
192+
run: |
193+
echo ${{ env.workdir }}
194+
mkdir ${{ env.workdir }}\channel\win-64
195+
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
196+
dir ${{ env.workdir }}\channel\win-64
197+
- name: Index the channel
198+
shell: cmd /C CALL {0}
199+
run: conda index ${{ env.workdir }}\channel
200+
201+
- name: Dump mkl_fft version info from created channel into ver.json
202+
shell: cmd /C CALL {0}
203+
run: |
204+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
205+
- name: Output content of produced ver.json
206+
shell: pwsh
207+
run: Get-Content -Path ${{ env.workdir }}\ver.json
208+
- name: Collect dependencies
209+
shell: cmd /C CALL {0}
210+
run: |
211+
IF NOT EXIST ver.json (
212+
copy /Y ${{ env.workdir }}\ver.json .
213+
)
214+
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
215+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
216+
SET PACKAGE_VERSION=%%F
217+
)
218+
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
219+
- name: Display lockfile content
220+
shell: pwsh
221+
run: Get-Content -Path .\lockfile
222+
- name: Cache conda packages
223+
uses: actions/cache@v4
224+
env:
225+
CACHE_NUMBER: 0 # Increase to reset cache
226+
with:
227+
path: /home/runner/conda_pkgs_dir
228+
key:
229+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-${{hashFiles('lockfile') }}
230+
restore-keys: |
231+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
232+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
233+
- name: Install mkl_fft
234+
shell: cmd /C CALL {0}
235+
run: |
236+
@ECHO ON
237+
IF NOT EXIST ver.json (
238+
copy /Y ${{ env.workdir }}\ver.json .
239+
)
240+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
241+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
242+
SET PACKAGE_VERSION=%%F
243+
)
244+
SET "TEST_DEPENDENCIES=pytest pytest-cov"
245+
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
246+
- name: Report content of test environment
247+
shell: cmd /C CALL {0}
248+
run: |
249+
echo "Value of CONDA enviroment variable was: " %CONDA%
250+
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
251+
conda info && conda list -n mkl_fft_test
252+
- name: Run tests
253+
shell: cmd /C CALL {0}
254+
run: >-
255+
conda activate mkl_fft_test && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
256+

.github/workflows/conda-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
runner: [ubuntu-latest]
6868
continue-on-error: ${{ matrix.experimental }}
6969
env:
70-
CHANNELS: -c https://software.repos.intel.com/python/conda -c main --override-channels
70+
CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels
7171

7272
steps:
7373
- name: Download artifact

conda-recipe-cf/bld.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set MKLROOT=%PREFIX%
2+
%PYTHON% -m pip install --no-build-isolation --no-deps .
3+
if errorlevel 1 exit 1

conda-recipe-cf/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -x
2+
3+
if [ `uname` == Darwin ]; then
4+
export MACOSX_DEPLOYMENT_TARGET=10.9
5+
fi
6+
7+
export MKLROOT=$PREFIX
8+
export CFLAGS="-I$PREFIX/include $CFLAGS"
9+
$PYTHON -m pip install --no-build-isolation --no-deps .
10+

conda-recipe-cf/meta.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% set version = "1.3.10" %}
2+
{% set buildnumber = 0 %}
3+
4+
package:
5+
name: mkl_fft
6+
version: {{ version }}
7+
8+
source:
9+
path: ../
10+
11+
build:
12+
number: {{ buildnumber }}
13+
ignore_run_exports:
14+
- blas
15+
16+
requirements:
17+
build:
18+
- {{ compiler('c') }}
19+
host:
20+
- python
21+
- setuptools
22+
- mkl-devel
23+
- cython
24+
- numpy
25+
run:
26+
- python
27+
- mkl
28+
- mkl-service
29+
- numpy
30+
31+
test:
32+
commands:
33+
- pytest -v --pyargs mkl_fft
34+
requires:
35+
- pytest
36+
imports:
37+
- mkl_fft
38+
- mkl_fft.interfaces
39+
- mkl_fft.interfaces.numpy_fft
40+
- mkl_fft.interfaces.scipy_fft
41+
42+
about:
43+
home: http://github.com/IntelPython/mkl_fft
44+
license: BSD-3
45+
license_file: LICENSE.txt
46+
summary: NumPy-based implementation of Fast Fourier Transform using Intel (R) Math Kernel Library

conda-recipe/run_test.py

Whitespace-only changes.

0 commit comments

Comments
 (0)