Skip to content

Commit 31009b5

Browse files
committed
Add conda-recipe-cf
aligned with dpctl-feedstock on conda-forge's recipe and scripts
1 parent d81c830 commit 31009b5

7 files changed

Lines changed: 569 additions & 0 deletions

File tree

Lines changed: 372 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,372 @@
1+
name: Conda package (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: dpctl
13+
MODULE_NAME: dpctl
14+
TEST_ENV_NAME: test_dpctl
15+
RECIPE_DIR: conda-recipe-cf
16+
CHANNELS: "-c conda-forge --override-channels"
17+
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); d = j['dpctl'][0];"
18+
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"
19+
CONDA_BUILD_VERSION: 26.3.0
20+
CONDA_INDEX_VERSION: 0.11.0
21+
22+
jobs:
23+
build_linux:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 90
26+
27+
strategy:
28+
matrix:
29+
python: ['3.10', '3.11', '3.12', '3.13']
30+
python_spec: ['']
31+
include:
32+
- python: '3.14'
33+
python_spec: '3.14.* *_cp314'
34+
- python: '3.14'
35+
python_spec: '3.14.* *_cp314t'
36+
steps:
37+
- name: Cancel Previous Runs
38+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
39+
with:
40+
access_token: ${{ github.token }}
41+
42+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Set pkgs_dirs
47+
run: |
48+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
49+
- name: Cache conda packages
50+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
51+
env:
52+
CACHE_NUMBER: 3 # Increase to reset cache
53+
with:
54+
path: ~/.conda/pkgs
55+
key:
56+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-${{hashFiles('conda-recipe-cf/meta.yaml') }}
57+
restore-keys: |
58+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-
59+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-
60+
- name: Add conda to system path
61+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
62+
- name: Update conda
63+
run: |
64+
conda update -n base --all
65+
- name: Install conda-build
66+
run: |
67+
conda install -n base conda-build=${{ env.CONDA_BUILD_VERSION }} ${{ env.CHANNELS }}
68+
- name: Show Conda info
69+
run: |
70+
conda info --all
71+
- name: List base environment packages
72+
run: |
73+
conda list -n base
74+
- name: Build conda package
75+
run: |
76+
if [ -n "${{ matrix.python_spec }}" ]; then
77+
conda build --no-test --python "${{ matrix.python_spec }}" ${{ env.CHANNELS }} ${{ env.RECIPE_DIR }}
78+
else
79+
conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} ${{ env.RECIPE_DIR }}
80+
fi
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
83+
with:
84+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
85+
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda
86+
87+
build_windows:
88+
runs-on: windows-latest
89+
timeout-minutes: 150
90+
defaults:
91+
run:
92+
shell: cmd /C CALL {0}
93+
94+
strategy:
95+
matrix:
96+
python: ['3.10', '3.11', '3.12', '3.13']
97+
python_spec: ['']
98+
include:
99+
- python: '3.14'
100+
python_spec: '3.14.* *_cp314'
101+
- python: '3.14'
102+
python_spec: '3.14.* *_cp314t'
103+
steps:
104+
- name: Cancel Previous Runs
105+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
106+
with:
107+
access_token: ${{ github.token }}
108+
109+
# the recipe takes the version from git describe
110+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
111+
with:
112+
fetch-depth: 0
113+
114+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
115+
with:
116+
auto-update-conda: true
117+
miniforge-version: latest
118+
activate-environment: build
119+
channels: conda-forge
120+
conda-remove-defaults: true
121+
python-version: ${{ matrix.python }}
122+
conda-build-version: ${{ env.CONDA_BUILD_VERSION }}
123+
- name: Store conda paths as envs
124+
shell: bash -l {0}
125+
run: |
126+
echo "CONDA_BLD=$CONDA/conda-bld/win-64/" | tr "\\\\" '/' >> "$GITHUB_ENV"
127+
- name: Show Conda info
128+
run: |
129+
conda info --all
130+
- name: List base environment packages
131+
run: |
132+
conda list -n base
133+
- name: Build conda package
134+
env:
135+
OVERRIDE_INTEL_IPO: 1 # IPO requires more resources that GH actions VM provides
136+
run: |
137+
set "PYTHON_VER=${{ matrix.python_spec }}"
138+
if "%PYTHON_VER%" NEQ "" (
139+
conda build --no-test --python "%PYTHON_VER%" ${{ env.CHANNELS }} ${{ env.RECIPE_DIR }}
140+
) else (
141+
conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} ${{ env.RECIPE_DIR }}
142+
)
143+
144+
- name: Upload artifact
145+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
146+
with:
147+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
148+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
149+
150+
test_linux:
151+
needs: build_linux
152+
runs-on: ${{ matrix.runner }}
153+
timeout-minutes: 30
154+
155+
strategy:
156+
matrix:
157+
python: ['3.10', '3.11', '3.12', '3.13']
158+
python_spec: ['']
159+
include:
160+
- python: '3.14'
161+
python_spec: '3.14.* *_cp314'
162+
runner: ubuntu-22.04
163+
- python: '3.14'
164+
python_spec: '3.14.* *_cp314t'
165+
runner: ubuntu-22.04
166+
runner: [ubuntu-latest]
167+
168+
steps:
169+
- name: Download artifact
170+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
171+
with:
172+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
173+
- name: Add conda to system path
174+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
175+
- name: Update conda
176+
run: |
177+
conda update -n base --all
178+
- name: Install conda-index
179+
run: |
180+
conda install -n base conda-index=${{ env.CONDA_INDEX_VERSION }} ${{ env.CHANNELS }}
181+
- name: Show Conda info
182+
run: |
183+
conda info --all
184+
- name: List base environment packages
185+
run: |
186+
conda list -n base
187+
- name: Create conda channel
188+
run: |
189+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
190+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
191+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
192+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
193+
# Test channel
194+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
195+
cat ver.json
196+
- name: Collect dependencies
197+
run: |
198+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
199+
export CHANNELS
200+
PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
201+
export PACKAGE_VERSION
202+
PYTHON_VER="${{ matrix.python_spec }}"
203+
if [ -z "${PYTHON_VER}" ]; then
204+
PYTHON_VER="${{ matrix.python }}"
205+
fi
206+
# shellcheck disable=SC2086
207+
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python="${PYTHON_VER}" $CHANNELS --only-deps --dry-run > lockfile
208+
cat lockfile
209+
- name: Set pkgs_dirs
210+
run: |
211+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
212+
- name: Cache conda packages
213+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
214+
env:
215+
CACHE_NUMBER: 3 # Increase to reset cache
216+
with:
217+
path: ~/.conda/pkgs
218+
key:
219+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-${{hashFiles('lockfile') }}
220+
restore-keys: |
221+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-
222+
${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-
223+
- name: Install dpctl
224+
run: |
225+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
226+
export CHANNELS
227+
# intel-opencl-rt provides the OpenCL CPU device to run the tests on
228+
TEST_DEPENDENCIES="pytest cython setuptools intel-opencl-rt"
229+
export TEST_DEPENDENCIES
230+
PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
231+
PYTHON_VER="${{ matrix.python_spec }}"
232+
if [ -z "${PYTHON_VER}" ]; then
233+
PYTHON_VER="${{ matrix.python }}"
234+
fi
235+
export PACKAGE_VERSION
236+
# shellcheck disable=SC2086
237+
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} $TEST_DEPENDENCIES python="${PYTHON_VER}" $CHANNELS
238+
# Test installed packages
239+
conda list -n "${{ env.TEST_ENV_NAME }}"
240+
- name: Smoke test
241+
run: |
242+
. "$CONDA/etc/profile.d/conda.sh"
243+
conda activate "${{ env.TEST_ENV_NAME }}"
244+
python -c "import dpctl; dpctl.lsplatform(verbosity=2)"
245+
- name: Create test temp dir
246+
# create temporary empty folder to runs tests from
247+
# https://github.com/pytest-dev/pytest/issues/11904
248+
run: mkdir -p "${GITHUB_WORKSPACE}/test_tmp"
249+
- name: Run tests
250+
working-directory: ${{ github.workspace }}/test_tmp
251+
env:
252+
SYCL_CACHE_PERSISTENT: 1
253+
run: |
254+
. "$CONDA/etc/profile.d/conda.sh"
255+
conda activate "${{ env.TEST_ENV_NAME }}"
256+
python -m pytest -v --pyargs "${{ env.MODULE_NAME }}"
257+
258+
test_windows:
259+
needs: build_windows
260+
runs-on: ${{ matrix.runner }}
261+
timeout-minutes: 60
262+
defaults:
263+
run:
264+
shell: cmd /C CALL {0}
265+
strategy:
266+
matrix:
267+
python: ['3.10', '3.11', '3.12', '3.13']
268+
python_spec: ['']
269+
include:
270+
- python: '3.14'
271+
python_spec: '3.14.* *_cp314'
272+
runner: windows-latest
273+
- python: '3.14'
274+
python_spec: '3.14.* *_cp314t'
275+
runner: windows-latest
276+
runner: [windows-latest]
277+
env:
278+
workdir: '${{ github.workspace }}'
279+
280+
steps:
281+
- name: Download artifact
282+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
283+
with:
284+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
285+
286+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
287+
with:
288+
auto-update-conda: true
289+
miniforge-version: latest
290+
channels: conda-forge
291+
conda-remove-defaults: true
292+
activate-environment: ${{ env.TEST_ENV_NAME }}
293+
python-version: ${{ matrix.python }}
294+
295+
- name: Install conda-index
296+
run: |
297+
conda install -n base conda-index=${{ env.CONDA_INDEX_VERSION }}
298+
299+
- name: Show Conda info
300+
run: |
301+
conda info --all
302+
303+
- name: List base environment packages
304+
run: |
305+
conda list -n base
306+
307+
- name: Create conda channel with the artifact bit
308+
run: |
309+
@echo on
310+
mkdir ${{ env.workdir }}\channel\win-64
311+
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.workdir }}\channel\win-64
312+
dir ${{ env.workdir }}\channel\win-64\
313+
314+
- name: Index the channel
315+
run: |
316+
@echo on
317+
conda index ${{ env.workdir }}\channel
318+
319+
- name: Dump dpctl version info from created channel into ver.json
320+
run: |
321+
@echo on
322+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
323+
dir ${{ env.workdir }}
324+
325+
- name: Install dpctl
326+
run: |
327+
@ECHO ON
328+
IF NOT EXIST ver.json (
329+
copy /Y ${{ env.workdir }}\ver.json .
330+
)
331+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
332+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
333+
SET PACKAGE_VERSION=%%F
334+
)
335+
SET "PYTHON_VER=${{ matrix.python_spec }}"
336+
IF "%PYTHON_VER%"=="" SET "PYTHON_VER=${{ matrix.python }}"
337+
REM intel-opencl-rt provides the OpenCL CPU device to run the tests on
338+
SET "TEST_DEPENDENCIES=pytest cython setuptools intel-opencl-rt"
339+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python="%PYTHON_VER%" -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
340+
341+
- name: Report content of test environment
342+
run: |
343+
conda info && conda list -n ${{ env.TEST_ENV_NAME }}
344+
345+
- name: Register the OpenCL CPU driver with the ICD loader
346+
shell: pwsh
347+
run: |
348+
$vendors = "HKLM:\SOFTWARE\Khronos\OpenCL\Vendors"
349+
$drivers = @(Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter intelocl64.dll -Path "$env:CONDA_PREFIX\Library\bin")
350+
if ($drivers.Count -eq 0) { throw "intel-opencl-rt installed no OpenCL CPU driver under $env:CONDA_PREFIX" }
351+
if (-not (Test-Path $vendors)) { New-Item -Path $vendors -Force | Out-Null }
352+
foreach ($driver in $drivers) {
353+
New-ItemProperty -Path $vendors -Name $driver.FullName -Value 0 -PropertyType DWord -Force | Out-Null
354+
}
355+
Get-ItemProperty -Path $vendors
356+
357+
- name: Smoke test
358+
run: >-
359+
conda activate ${{ env.TEST_ENV_NAME }} && python -m dpctl -f
360+
361+
- name: Create empty temporary directory to run tests from
362+
# create temporary empty folder to runs tests from
363+
# https://github.com/pytest-dev/pytest/issues/11904
364+
run: >-
365+
mkdir "${{ env.workdir }}\test_tmp"
366+
367+
- name: Run tests
368+
env:
369+
SYCL_CACHE_PERSISTENT: 1
370+
working-directory: ${{ env.workdir }}\test_tmp
371+
run: >-
372+
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}

0 commit comments

Comments
 (0)