Skip to content

Commit ffd2f32

Browse files
authored
Merge pull request #193 from IntelPython/fix-for-old-mkl-versions
Fix building and running on pre-2026 MKL versions
2 parents 1e45475 + 331d12f commit ffd2f32

8 files changed

Lines changed: 384 additions & 40 deletions

File tree

.github/workflows/conda-package-cf.yml

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ jobs:
108108
channels: conda-forge
109109
python-version: ${{ matrix.python }}
110110

111+
- name: Update conda
112+
run: |
113+
conda update -n base --all
114+
115+
- name: Install conda build
116+
run: |
117+
conda install -n base -y conda-build
118+
111119
- name: Cache conda packages
112120
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
113121
env:
@@ -126,9 +134,12 @@ jobs:
126134
echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
127135
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV"
128136
129-
- name: Install conda build
137+
- name: Show Conda info
138+
run: |
139+
conda info --all
140+
141+
- name: List base environment packages
130142
run: |
131-
conda install -n base -y conda-build
132143
conda list -n base
133144
134145
- name: Build conda package
@@ -301,3 +312,153 @@ jobs:
301312
run: |
302313
conda activate ${{ env.TEST_ENV_NAME }}
303314
pytest -v --pyargs ${{ env.MODULE_NAME }}
315+
316+
build_osx:
317+
runs-on: macos-26-intel
318+
319+
strategy:
320+
matrix:
321+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
322+
323+
steps:
324+
- name: Cancel Previous Runs
325+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
326+
with:
327+
access_token: ${{ github.token }}
328+
329+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
330+
with:
331+
fetch-depth: 0
332+
333+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
334+
with:
335+
miniforge-version: latest
336+
activate-environment: build
337+
channels: conda-forge
338+
python-version: ${{ matrix.python }}
339+
340+
- name: Cache conda packages
341+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
342+
env:
343+
CACHE_NUMBER: 0 # Increase to reset cache
344+
with:
345+
path: /Users/runner/conda_pkgs_dir
346+
key:
347+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
348+
restore-keys: |
349+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
350+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
351+
352+
- name: Install conda-build
353+
shell: bash -el {0}
354+
run: |
355+
conda install -n base -y conda-build
356+
conda list -n base
357+
358+
- name: Store conda paths as envs
359+
shell: bash -el {0}
360+
run: |
361+
echo "CONDA_BLD=$CONDA/conda-bld/osx-64/" >> "$GITHUB_ENV"
362+
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
363+
364+
- name: Build conda package
365+
shell: bash -el {0}
366+
run: |
367+
CHANNELS=(-c conda-forge -c conda-forge/label/python_rc --override-channels)
368+
VERSIONS=(--python "${{ matrix.python }}")
369+
TEST=(--no-test)
370+
371+
conda build \
372+
"${TEST[@]}" \
373+
"${VERSIONS[@]}" \
374+
"${CHANNELS[@]}" \
375+
conda-recipe-cf
376+
377+
- name: Upload artifact
378+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
379+
with:
380+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
381+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
382+
383+
- name: Upload wheels artifact
384+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
385+
with:
386+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
387+
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
388+
389+
test_osx:
390+
needs: build_osx
391+
runs-on: ${{ matrix.runner }}
392+
393+
strategy:
394+
matrix:
395+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
396+
experimental: [false]
397+
runner: [macos-26-intel]
398+
continue-on-error: ${{ matrix.experimental }}
399+
env:
400+
CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels
401+
402+
steps:
403+
- name: Download artifact
404+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
405+
with:
406+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
407+
408+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
409+
with:
410+
miniforge-version: latest
411+
channels: conda-forge
412+
activate-environment: base
413+
414+
- name: Install conda-index
415+
shell: bash -el {0}
416+
run: conda install -n base -y conda-index
417+
418+
- name: Create conda channel
419+
shell: bash -el {0}
420+
run: |
421+
mkdir -p "$GITHUB_WORKSPACE/channel/osx-64"
422+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
423+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/osx-64" || exit 1
424+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
425+
# Test channel
426+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
427+
cat ver.json
428+
429+
- name: Collect dependencies
430+
shell: bash -el {0}
431+
run: |
432+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
433+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
434+
export PACKAGE_VERSION
435+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" "python=${{ matrix.python }}" "${CHANNELS[@]}" --only-deps --dry-run > lockfile
436+
cat lockfile
437+
438+
- name: Cache conda packages
439+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
440+
env:
441+
CACHE_NUMBER: 0 # Increase to reset cache
442+
with:
443+
path: /Users/runner/conda_pkgs_dir
444+
key:
445+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
446+
restore-keys: |
447+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
448+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
449+
450+
- name: Install mkl-service
451+
shell: bash -el {0}
452+
run: |
453+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
454+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
455+
export PACKAGE_VERSION
456+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" pytest "python=${{ matrix.python }}" "${CHANNELS[@]}"
457+
# Test installed packages
458+
conda list -n "${{ env.TEST_ENV_NAME }}"
459+
460+
- name: Run tests
461+
shell: bash -el {0}
462+
run: |
463+
conda activate ${{ env.TEST_ENV_NAME }}
464+
pytest -vv --pyargs ${{ env.MODULE_NAME }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
### Changed
12+
* Make `mkl-service` backward compatibility from MKL 2026.0 down to at least 2023.2 [gh-193](https://github.com/IntelPython/mkl-service/pull/193)
1213

1314
### Fixed
1415
* Changed insecure HTTP URLs to HTTPS in `pyproject.toml` and conda recipe files for improved security
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
c_compiler: # [linux]
22
- gcc # [linux]
3-
cxx_compiler: # [linux]
4-
- gxx # [linux]
5-
cxx_compiler_version: # [linux]
6-
- '14' # [linux]
73
c_stdlib: # [linux]
84
- sysroot # [linux]
95
c_stdlib_version: # [linux]
106
- '2.28' # [linux]
7+
c_compiler: # [osx]
8+
- clang # [osx]
9+
c_stdlib: # [osx]
10+
- macosx_deployment_target # [osx]
1111
c_stdlib: # [win]
1212
- vs # [win]
13-
cxx_compiler: # [win]
14-
- vs2022 # [win]
1513
c_compiler: # [win]
1614
- vs2022 # [win]

conda-recipe-cf/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source:
77

88
build:
99
number: {{ GIT_DESCRIBE_NUMBER }}
10+
skip: true # [osx and arm64]
1011
script_env:
1112
- WHEELS_OUTPUT_FOLDER
1213
ignore_run_exports:
@@ -22,7 +23,8 @@ requirements:
2223
- python-gil # [py>=314]
2324
- pip >=25.0
2425
- setuptools >=77
25-
- mkl-devel
26+
- mkl-devel # [not osx]
27+
- mkl-devel <2024 # [osx]
2628
- cython
2729
- wheel >=0.45.1
2830
- python-build >=1.2.2
Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
c_compiler: # [linux]
2-
- gcc # [linux]
3-
cxx_compiler: # [linux]
4-
- gxx # [linux]
5-
cxx_compiler_version: # [linux]
6-
- '14' # [linux]
7-
c_stdlib: # [linux]
8-
- sysroot # [linux]
9-
c_stdlib_version: # [linux]
10-
- '2.28' # [linux]
11-
c_stdlib: # [win]
12-
- vs # [win]
13-
cxx_compiler: # [win]
14-
- vs2022 # [win]
15-
c_compiler: # [win]
16-
- vs2022 # [win]
1+
c_compiler: # [linux]
2+
- gcc # [linux]
3+
c_stdlib: # [linux]
4+
- sysroot # [linux]
5+
c_stdlib_version: # [linux]
6+
- '2.28' # [linux]
7+
c_stdlib: # [win]
8+
- vs # [win]
9+
c_compiler: # [win]
10+
- vs2022 # [win]

mkl/_mkl_service.pxd

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ cdef extern from "mkl.h":
5959
int MKL_CBWR_AVX2
6060
int MKL_CBWR_AVX512
6161
int MKL_CBWR_AVX512_E1
62-
int MKL_CBWR_AVX10
6362

6463
int MKL_CBWR_SUCCESS
6564
int MKL_CBWR_ERR_INVALID_SETTINGS
@@ -74,12 +73,10 @@ cdef extern from "mkl.h":
7473
int MKL_ENABLE_AVX512_E3
7574
int MKL_ENABLE_AVX512_E4
7675
int MKL_ENABLE_AVX512_E1
77-
int MKL_ENABLE_AVX512_E5
7876
int MKL_ENABLE_AVX512
7977
int MKL_ENABLE_AVX2
8078
int MKL_ENABLE_AVX2_E1
8179
int MKL_ENABLE_SSE4_2
82-
int MKL_ENABLE_AVX10
8380

8481
# MPI Implementation Constants
8582
int MKL_BLACS_CUSTOM
@@ -169,3 +166,62 @@ cdef extern from "mkl.h":
169166
int vmlSetErrStatus(const MKL_INT status)
170167
int vmlGetErrStatus()
171168
int vmlClearErrStatus()
169+
170+
# version-compat shim
171+
cdef extern from *:
172+
"""
173+
#include <mkl.h>
174+
175+
/* define constants removed in 2026.0 if undefined */
176+
#ifndef MKL_CBWR_SSSE3
177+
#define MKL_CBWR_SSSE3 -1
178+
#endif
179+
#ifndef MKL_CBWR_SSE4_1
180+
#define MKL_CBWR_SSE4_1 -1
181+
#endif
182+
#ifndef MKL_CBWR_AVX
183+
#define MKL_CBWR_AVX -1
184+
#endif
185+
#ifndef MKL_CBWR_AVX512_MIC
186+
#define MKL_CBWR_AVX512_MIC -1
187+
#endif
188+
#ifndef MKL_CBWR_AVX512_MIC_E1
189+
#define MKL_CBWR_AVX512_MIC_E1 -1
190+
#endif
191+
192+
#ifndef MKL_ENABLE_AVX512_MIC_E1
193+
#define MKL_ENABLE_AVX512_MIC_E1 -1
194+
#endif
195+
#ifndef MKL_ENABLE_AVX512_MIC
196+
#define MKL_ENABLE_AVX512_MIC -1
197+
#endif
198+
#ifndef MKL_ENABLE_AVX
199+
#define MKL_ENABLE_AVX -1
200+
#endif
201+
202+
/* define constants from 2026.0 if undefined */
203+
#ifndef MKL_CBWR_AVX10
204+
#define MKL_CBWR_AVX10 -2
205+
#endif
206+
207+
#ifndef MKL_ENABLE_AVX512_E5
208+
#define MKL_ENABLE_AVX512_E5 -2
209+
#endif
210+
#ifndef MKL_ENABLE_AVX10
211+
#define MKL_ENABLE_AVX10 -2
212+
#endif
213+
"""
214+
int MKL_CBWR_SSSE3
215+
int MKL_CBWR_SSE4_1
216+
int MKL_CBWR_AVX
217+
int MKL_CBWR_AVX512_MIC
218+
int MKL_CBWR_AVX512_MIC_E1
219+
220+
int MKL_ENABLE_AVX512_MIC_E1
221+
int MKL_ENABLE_AVX512_MIC
222+
int MKL_ENABLE_AVX
223+
224+
int MKL_CBWR_AVX10
225+
226+
int MKL_ENABLE_AVX512_E5
227+
int MKL_ENABLE_AVX10

0 commit comments

Comments
 (0)