Skip to content

Commit

Permalink
fix MKL tests in Github Actions
Browse files Browse the repository at this point in the history
The most recent version of MKL on PyPI ships only `libmkl_rt.so.1`, not
`libmkl_rt.so`. In Nutils we load the latter. This causes two problems: in
Github Actions we cannot find the location of the library directory where MKL
is being installed, because we explicitly look for `libmkl_rt.so` and Nutils
can't load the library because we explicitly load the missing unversioned
library. This patch fixes both problems by searching for the versioned library
and adding a symlink to the unversioned library.
  • Loading branch information
joostvanzwieten committed Apr 14, 2021
1 parent 672facd commit 50a7a30
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ jobs:
# Install Nutils from `dist` dir created in job
# `build-python-package`.
python -um pip install --no-index --find-links ./dist nutils
- name: Get library directory
id: get-lib-dir
- name: Configure MKL
id: configure-mkl
if: ${{ matrix.matrix-backend == 'mkl' }}
run: python -um devtools.gha.get_lib_dir
run: python -um devtools.gha.configure_mkl
- name: Test
env:
LD_LIBRARY_PATH: ${{ steps.get-lib-dir.outputs.libdir }}
NUTILS_DEBUG: all
run: |
mkdir testenv
Expand Down
25 changes: 25 additions & 0 deletions devtools/gha/configure_mkl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from .. import log
import sys, site, os

libsubdir = 'lib'
prefixes = list(site.PREFIXES)
if hasattr(site, 'getuserbase'):
prefixes.append(site.getuserbase())
for prefix in prefixes:
libdir = os.path.join(prefix, libsubdir)
if not os.path.exists(os.path.join(libdir, 'libmkl_rt.so.1')):
continue
log.set_output('libdir', libdir)
break
else:
log.error('cannot find {} in any of the following dirs: {}'.format('libmkl_rt.so.1', ' '.join(prefixes)))

lib = os.path.join(libdir, 'libmkl_rt.so')
if not os.path.exists(lib):
os.symlink('libmkl_rt.so.1', lib)

github_env = os.environ.get('GITHUB_ENV')
assert github_env
ld_library_path = ':'.join(filter(None, (os.environ.get('LD_LIBRARY_PATH', ''), libdir)))
with open(github_env, 'a') as f:
print('LD_LIBRARY_PATH={}'.format(ld_library_path), file=f)
16 changes: 0 additions & 16 deletions devtools/gha/get_lib_dir.py

This file was deleted.

0 comments on commit 50a7a30

Please sign in to comment.