Skip to content

Commit 7af96a1

Browse files
authored
Merge pull request #158 from IntelPython/add-conda-forge-workflow
Add conda-forge workflow
2 parents e5926c4 + 1a15196 commit 7af96a1

7 files changed

Lines changed: 404 additions & 17 deletions

File tree

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
name: Conda package using conda-forge
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
env:
12+
PACKAGE_NAME: mkl-service
13+
MODULE_NAME: mkl
14+
TEST_ENV_NAME: test_mkl_service
15+
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); "
16+
VER_SCRIPT2: "d = j['mkl-service'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
17+
18+
jobs:
19+
build_linux:
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
25+
26+
steps:
27+
- name: Cancel Previous Runs
28+
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
29+
with:
30+
access_token: ${{ github.token }}
31+
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set pkgs_dirs
37+
run: |
38+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
39+
40+
- name: Cache conda packages
41+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
42+
env:
43+
CACHE_NUMBER: 0 # Increase to reset cache
44+
with:
45+
path: ~/.conda/pkgs
46+
key:
47+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
50+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
51+
52+
- name: Add conda to system path
53+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
54+
55+
- name: Install conda-build
56+
run: conda install conda-build
57+
58+
- name: Store conda paths as envs
59+
shell: bash -el {0}
60+
run: |
61+
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
62+
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
63+
64+
- name: Build conda package
65+
run: |
66+
CHANNELS=(-c conda-forge -c conda-forge/label/python_rc --override-channels)
67+
VERSIONS=(--python "${{ matrix.python }}")
68+
TEST=(--no-test)
69+
70+
conda build \
71+
"${TEST[@]}" \
72+
"${VERSIONS[@]}" \
73+
"${CHANNELS[@]}" \
74+
conda-recipe-cf
75+
76+
- name: Upload artifact
77+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
78+
with:
79+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
80+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
81+
82+
- name: Upload wheels artifact
83+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
84+
with:
85+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
86+
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
87+
88+
build_windows:
89+
runs-on: windows-latest
90+
91+
strategy:
92+
matrix:
93+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
94+
95+
steps:
96+
- name: Cancel Previous Runs
97+
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
98+
with:
99+
access_token: ${{ github.token }}
100+
101+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
102+
with:
103+
fetch-depth: 0
104+
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
105+
with:
106+
miniforge-version: latest
107+
activate-environment: build
108+
channels: conda-forge
109+
python-version: ${{ matrix.python }}
110+
111+
- name: Cache conda packages
112+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
113+
env:
114+
CACHE_NUMBER: 3 # Increase to reset cache
115+
with:
116+
path: /home/runner/conda_pkgs_dir
117+
key:
118+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
119+
restore-keys: |
120+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
121+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
122+
123+
- name: Store conda paths as envs
124+
shell: bash -el {0}
125+
run: |
126+
echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
127+
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV"
128+
129+
- name: Install conda build
130+
run: |
131+
conda install -n base -y conda-build
132+
conda list -n base
133+
134+
- name: Build conda package
135+
run: conda build --no-test --python ${{ matrix.python }} -c conda-forge -c conda-forge/label/python_rc --override-channels conda-recipe-cf
136+
137+
- name: Upload artifact
138+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
139+
with:
140+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
141+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
142+
143+
- name: Upload wheels artifact
144+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
145+
with:
146+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
147+
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
148+
149+
test_linux:
150+
needs: build_linux
151+
runs-on: ${{ matrix.runner }}
152+
153+
strategy:
154+
matrix:
155+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
156+
experimental: [false]
157+
runner: [ubuntu-latest]
158+
continue-on-error: ${{ matrix.experimental }}
159+
env:
160+
CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels
161+
162+
steps:
163+
- name: Download artifact
164+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
165+
with:
166+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
167+
168+
- name: Add conda to system path
169+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
170+
171+
- name: Install conda-build
172+
run: conda install conda-build
173+
174+
- name: Create conda channel
175+
run: |
176+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
177+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
178+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
179+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
180+
# Test channel
181+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
182+
cat ver.json
183+
184+
- name: Collect dependencies
185+
run: |
186+
. "$CONDA/etc/profile.d/conda.sh"
187+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
188+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
189+
export PACKAGE_VERSION
190+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" "python=${{ matrix.python }}" "${CHANNELS[@]}" --only-deps --dry-run > lockfile
191+
cat lockfile
192+
193+
- name: Set pkgs_dirs
194+
run: |
195+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
196+
197+
- name: Cache conda packages
198+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
199+
env:
200+
CACHE_NUMBER: 0 # Increase to reset cache
201+
with:
202+
path: ~/.conda/pkgs
203+
key:
204+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
205+
restore-keys: |
206+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
207+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
208+
209+
- name: Install mkl-service
210+
run: |
211+
. "$CONDA/etc/profile.d/conda.sh"
212+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
213+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
214+
export PACKAGE_VERSION
215+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" pytest "python=${{ matrix.python }}" "${CHANNELS[@]}"
216+
# Test installed packages
217+
conda list
218+
219+
- name: Run tests
220+
run: |
221+
. "$CONDA/etc/profile.d/conda.sh"
222+
conda activate ${{ env.TEST_ENV_NAME }}
223+
pytest -vv --pyargs ${{ env.MODULE_NAME }}
224+
225+
test_windows:
226+
needs: build_windows
227+
runs-on: ${{ matrix.runner }}
228+
229+
strategy:
230+
matrix:
231+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
232+
experimental: [false]
233+
runner: [windows-latest]
234+
continue-on-error: ${{ matrix.experimental }}
235+
env:
236+
CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels
237+
238+
steps:
239+
- name: Download artifact
240+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
241+
with:
242+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
243+
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
244+
with:
245+
miniforge-version: latest
246+
channels: conda-forge
247+
activate-environment: ${{ env.TEST_ENV_NAME }}
248+
python-version: ${{ matrix.python }}
249+
250+
- name: Install conda-index
251+
run: conda install conda-index
252+
253+
- name: Create conda channel
254+
run: |
255+
mkdir ${{ env.GITHUB_WORKSPACE }}/channel/win-64
256+
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}/channel/win-64
257+
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
258+
259+
# Test channel
260+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}/ver.json
261+
more ${{ env.GITHUB_WORKSPACE }}/ver.json
262+
263+
- name: Collect dependencies
264+
shell: cmd
265+
run: |
266+
@ECHO ON
267+
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json .
268+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
269+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
270+
SET PACKAGE_VERSION=%%F
271+
)
272+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
273+
more lockfile
274+
275+
- name: Cache conda packages
276+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
277+
env:
278+
CACHE_NUMBER: 3 # Increase to reset cache
279+
with:
280+
path: /home/runner/conda_pkgs_dir
281+
key:
282+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
283+
restore-keys: |
284+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
285+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
286+
287+
- name: Install mkl-service
288+
shell: cmd
289+
run: |
290+
@ECHO ON
291+
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json .
292+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
293+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
294+
SET PACKAGE_VERSION=%%F
295+
)
296+
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% pytest python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
297+
# Test installed packages
298+
conda list
299+
300+
- name: Run tests
301+
run: |
302+
conda activate ${{ env.TEST_ENV_NAME }}
303+
pytest -v --pyargs ${{ env.MODULE_NAME }}

.github/workflows/conda-package.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ jobs:
104104
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
105105
with:
106106
miniforge-version: latest
107-
use-mamba: 'true'
108-
conda-remove-defaults: 'true'
109-
activate-environment: 'build'
110-
python-version: '3.13' # no python 3.14 support by conda-build
107+
activate-environment: build
108+
channels: conda-forge
109+
python-version: ${{ matrix.python }}
111110

112111
- name: Cache conda packages
113112
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
@@ -121,15 +120,17 @@ jobs:
121120
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
122121
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
123122
124-
- name: Install conda-build
125-
run: conda install conda-build
126-
127123
- name: Store conda paths as envs
128124
shell: bash -el {0}
129125
run: |
130-
echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
126+
echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
131127
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV"
132128
129+
- name: Install conda build
130+
run: |
131+
conda install -n base -y conda-build
132+
conda list -n base
133+
133134
- name: Build conda package
134135
run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge -c conda-forge/label/python_rc --override-channels conda-recipe
135136

@@ -242,10 +243,9 @@ jobs:
242243
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
243244
with:
244245
miniforge-version: latest
245-
use-mamba: 'true'
246-
conda-remove-defaults: 'true'
247-
activate-environment: 'test'
248-
python-version: '3.13' # no python 3.14 support by conda-index
246+
channels: conda-forge
247+
activate-environment: ${{ env.TEST_ENV_NAME }}
248+
python-version: ${{ matrix.python }}
249249

250250
- name: Install conda-index
251251
run: conda install conda-index
@@ -254,7 +254,7 @@ jobs:
254254
run: |
255255
mkdir ${{ env.GITHUB_WORKSPACE }}/channel/win-64
256256
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}/channel/win-64
257-
python -m conda_index "${{ env.GITHUB_WORKSPACE }}/channel"
257+
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
258258
259259
# Test channel
260260
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}/ver.json
@@ -269,7 +269,7 @@ jobs:
269269
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
270270
SET PACKAGE_VERSION=%%F
271271
)
272-
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
272+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
273273
more lockfile
274274
275275
- name: Cache conda packages
@@ -302,5 +302,5 @@ jobs:
302302
303303
- name: Run tests
304304
run: |
305-
conda activate -n ${{ env.TEST_ENV_NAME }}
305+
conda activate ${{ env.TEST_ENV_NAME }}
306306
pytest -v --pyargs ${{ env.MODULE_NAME }}

conda-recipe-cf/bld.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@rem Remember to activate Intel Compiler, or remove these two lines to use Microsoft Visual Studio compiler
2+
3+
set MKLROOT=%PREFIX%
4+
%PYTHON% setup.py build --force install --old-and-unmanageable
5+
if errorlevel 1 exit 1

conda-recipe-cf/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash -x
2+
MKLROOT=$PREFIX $PYTHON setup.py build --force install --old-and-unmanageable

0 commit comments

Comments
 (0)