diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 603953625..4a0d36531 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/devtools/gha/configure_mkl.py b/devtools/gha/configure_mkl.py new file mode 100644 index 000000000..9ecff944e --- /dev/null +++ b/devtools/gha/configure_mkl.py @@ -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) diff --git a/devtools/gha/get_lib_dir.py b/devtools/gha/get_lib_dir.py deleted file mode 100644 index 9e411ab92..000000000 --- a/devtools/gha/get_lib_dir.py +++ /dev/null @@ -1,16 +0,0 @@ -from .. import log -import sys, site, os - -libname = 'libmkl_rt.so' -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, libname)): - continue - log.set_output('libdir', libdir) - break -else: - log.error('cannot find {} in any of the following dirs: {}'.format(libname, ' '.join(prefixes)))