~/.ipython/profile_default/startup/000-odurc-lmod.py
from Wahab cluster on the "legacy" lmod-based ipython/jupyter
session. Last update: 2020-06-09.
Sigs:
# -rw-r--r-- 1 wpurwant users 179 2020-06-03 15:49 000-odurc-lmod.py
# -rw-r--r-- 1 wpurwant users 843 2020-03-17 14:02 lmod_python.py
# 8718a2d7a7d6d152701e6c31254f7168 000-odurc-lmod.py
# 24a740e83656875bd39f942529378414 lmod_python.py
27 lines
843 B
Python
27 lines
843 B
Python
# -*- python -*-
|
|
from __future__ import print_function
|
|
from subprocess import PIPE, Popen
|
|
import os, sys
|
|
|
|
sys.path.append('/shared/apps/common/lmod/current/init')
|
|
|
|
from env_modules_python import module as lmod_module
|
|
|
|
def module(command, *arguments):
|
|
lmod_module(command, *arguments)
|
|
sys.path = os.environ.get('PYTHONPATH').split(':') + sys.path
|
|
manual_ld_library_dir = os.environ.get('LMOD_MANUAL_LD_LIBRARY_PATH')
|
|
|
|
for search_path in os.getenv('LD_LIBRARY_PATH').split(':')[::-1]:
|
|
if not os.path.isdir(search_path):
|
|
continue
|
|
|
|
for f in os.listdir(search_path):
|
|
if '.so' in f:
|
|
src = f'{search_path}/{f}'
|
|
tgt = f'{manual_ld_library_dir}/{f}'
|
|
if os.path.islink(tgt):
|
|
os.unlink(tgt)
|
|
|
|
os.symlink(src, tgt)
|