Commit 9547dadc authored by l_opal's avatar l_opal

Merge branch 'master' of gitlab.psi.ch:Pmodules/buildblocks

parents fcb2f546 32ab21ee
......@@ -46,3 +46,5 @@ hdf5_serial/1.10.4 stable pgi/18.5
hdf5_serial/1.10.5 stable gcc/{5.5.0,6.4.0,6.5.0,7.3.0,7.4.0,8.2.0,8.3.0}
hdf5_serial/1.10.5 stable intel/{18.4,19.3}
hdf5_serial/1.10.5 stable pgi/18.5
hdf5_serial/1.10.6 unstable gcc/{7.5.0,8.4.0,9.3.0,10.2.0}
......@@ -23,23 +23,39 @@ pbuild::pre_configure() {
pbuild::add_configure_args "--enable-shared"
pbuild::add_configure_args "--enable-static"
pbuild::add_configure_args "--with-sge=yes"
pbuild::add_configure_args "--with-ucx"
pbuild::add_configure_args "--with-hwloc=internal"
pbuild::add_configure_args "--with-slurm=yes"
if pbuild::use_flag slurm ; then
pbuild::add_configure_args "--with-pmi"
pbuild::add_configure_args "--with-pmi-libdir=/usr/lib64/"
if pbuild::use_flag "libpmix"; then
pbuild::add_configure_args "--enable-install-libpmix"
fi
fi
local version
(( version = (${V_MAJOR} * 100 + ${V_MINOR}) * 100 + V_PATCHLVL ))
if (( version < 30104 )) ; then
if (( V_MAJOR < 4 )); then
pbuild::add_configure_args "--enable-mpi-f90"
pbuild::add_configure_args "--enable-mpi-profile"
pbuild::add_configure_args "--enable-smp-locks"
elif (( V_MAJOR >= 4 )); then
pbuild::add_configure_args "--enable-mpi-fortran"
pbuild::add_configure_args "--without-verbs"
fi
}
pbuild::post_install() {
mkdir -p "${PREFIX}/lib/fallback"
local -r binary=$(ls "${PREFIX}"/lib/libmpi.so.*.*.*)
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/usr/.*/libuc[mpst].so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/usr/.*/libnuma.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/usr/.*/libbverbs.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/usr/.*/librdmacm.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libuc[mpst].so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libuct_ib.so.0'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libnuma.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libibverbs.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/librdmacm.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libpmi.so'
pbuild::install_shared_libs "${binary}" "${PREFIX}/lib/fallback" '/libpmi2.so'
}
openmpi/3.1.4_merlin6 stable gcc/{7.4.0,8.3.0}
openmpi/3.1.4-1_merlin6 stable gcc/{7.4.0,8.3.0}
openmpi/3.1.4_merlin6 deprecated gcc/{7.4.0,8.3.0}
openmpi/3.1.5_merlin6 deprecated gcc/{7.3.0,7.4.0,8.3.0,9.2.0}
openmpi/3.1.5_merlin6 deprecated intel/{15.2,17.4,18.4}
openmpi/3.1.5-1_merlin6 stable gcc/{7.3.0,7.4.0,8.3.0,9.2.0}
openmpi/3.1.5-1_merlin6 stable intel/{15.2,17.4,18.4}
openmpi/2.1.6_slurm unstable gcc/{4.9.4,5.5.0,6.5.0,7.4.0,8.3.0,9.2.0}
openmpi/2.1.6_slurm unstable intel/{15.2,17.4,18.4}
openmpi/3.0.5_slurm unstable gcc/{4.9.4,5.5.0,6.5.0,7.4.0,8.3.0,9.2.0}
openmpi/3.0.5_slurm unstable intel/{15.2,17.4,18.4}
openmpi/3.1.6_slurm stable gcc/{4.9.4,5.5.0,6.5.0,7.5.0,8.4.0,9.3.0}
openmpi/3.1.6_slurm stable intel/{15.2,17.4,18.4,20.1}
openmpi/4.0.4_slurm stable gcc/{4.9.4,5.5.0,6.5.0,7.5.0,8.4.0,9.3.0}
openmpi/4.0.4_slurm stable intel/{15.2,17.4,18.4,20.1}
openmpi/4.0.4_slurm_libpmix unstable gcc/9.3.0
......@@ -29,8 +29,10 @@ set libibverbs [glob -nocomplain /usr/lib{64,}/libibverbs.so.1*]
set libnuma [glob -nocomplain /usr/lib{64,}/libnuma.so.1*]
set librdmacm [glob -nocomplain /usr/lib{64,}/librdmacm.so.1*]
set libucx [glob -nocomplain /usr/lib{64,}/libuc\[mpst\].so.0*]
set libpmi [glob -nocomplain /usr/lib{64,}/libpmi.so.0*]
set libpmi2 [glob -nocomplain /usr/lib{64,}/libpmi2.so.0*]
if { $libibverbs eq "" || $libnuma eq "" || $librdmacm eq "" || $libucx eq "" } {
if { $libibverbs eq "" || $libnuma eq "" || $librdmacm eq "" || $libucx eq "" || $libpmi eq "" || $libpmi2 eq "" } {
if { [file isdirectory $PREFIX/lib/fallback] } {
prepend-path LD_LIBRARY_PATH $PREFIX/lib/fallback
}
......
......@@ -2,5 +2,5 @@ relion/2.1.b1 stable gcc/4.9.4 openmpi/2.0.1 cuda/8.0.44
relion/3.0_beta stable gcc/4.9.4 openmpi/2.0.1 cuda/8.0.44
relion/3.0.8 stable gcc/7.4.0 openmpi/3.1.4_merlin6 cuda/9.2.148 b:cmake/3.14.0 b:tiff/4.0.9
relion/3.1-beta unstable gcc/7.4.0 openmpi/3.1.4_merlin6 cuda/9.2.148 b:cmake/3.14.0 b:tiff/4.0.9
relion/3.1.0 unstable gcc/7.5.0 openmpi/4.0.4_slurm cuda/10.0.130 b:cmake/3.15.5 b:tiff/4.0.9 b:git/2.22.0
relion/3.1.0 stable gcc/7.5.0 openmpi/4.0.4_slurm cuda/10.0.130 b:cmake/3.15.5 b:tiff/4.0.9 b:git/2.22.0
gromacs/2020_sp unstable gcc/7.4.0 openmpi/3.1.5_merlin6 cuda/10.0.130 Python/3.7.4 b:cmake/3.14.0
gromacs/2020.2_sp unstable gcc/7.5.0 openmpi/3.1.6_slurm cuda/10.0.130 Python/3.7.4 b:cmake/3.15.5
gromacs/2020.2_sp_gpu unstable gcc/7.5.0 openmpi/4.0.4_slurm cuda/10.0.130 Python/3.7.4 b:cmake/3.15.5
......@@ -11,10 +11,6 @@ else
fi
pbuild::pre_configure() {
# For enabling GPU, set to 'yes'
local enable_gpu='yes'
echo here
pbuild::add_configure_args "-DCMAKE_BUILD_TYPE=RELEASE"
pbuild::add_configure_args "-DGMX_MPI=on"
......@@ -24,11 +20,16 @@ pbuild::pre_configure() {
pbuild::add_configure_args "-DGFMX_DOUBLE=off"
fi
if [[ "${enable_gpu}" == 'yes' ]]; then
if pbuild::use_flag "gpu"; then
pbuild::add_configure_args "-DGMX_GPU=on"
else
pbuild::add_configure_args "-DGMX_GPU=off"
fi
# To remove: pbuild::add_configure_args "-DGMX_SIMD=SSE2"
# For GMX_SIMD the lowest instruction number you think might work on all nodes
# |- Available numbers: http://manual.gromacs.org/documentation/2020/install-guide/index.html#simd-support
# |- AVX_512 is only for newest Intel processors (Xeon Scalable Gold, Core i9, etc.)
# AVX_512 will not work on old GPUs, this is why we chood AVX2_256 which are processors from 2013
pbuild::add_configure_args "-DGMX_SIMD=AVX2_256"
pbuild::add_configure_args "-DGMX_BUILD_OWN_FFTW=on"
}
lammps/2020.3_merlin6 unstable gcc/8.4.0 openmpi/4.0.4_slurm b:cmake/3.15.5
[27.08.2020]
* With CMake is necessary to have 'python3-virtualenv' installed. Needed for building documentation.
* Compilation for version 2020.3 with OMP, GCC v8, OpenMPI v4.0.4 works without the need of specifying '-D LAMMPS_OMP_COMPAT=4'
* More details here: https://lammps.sandia.gov/doc/Build_basics.html)
* Problems are seen with GCC v9, so is recommended to use GCC v8 for that. It was compiled with v8.
......@@ -4,80 +4,50 @@
TARNAME=$(grep -E "^${V_MAJOR}.${V_MINOR}" files/version-to-tarname.txt| awk '{print $2}')
# pbuild::set_download_url "https://gitlab.psi.ch/caubet_m/merlin-software/raw/master/$P/$P-${V_PKG}.tar.gz"
pbuild::set_download_url "https://github.com/lammps/lammps/archive/${TARNAME}"
# pbuild::set_download_url "https://github.com/lammps/lammps/archive/${TARNAME}"
pbuild::set_download_url "https://lammps.sandia.gov/tars/${TARNAME}"
pbuild::add_to_group 'MPI'
pbuild::install_docfiles README LICENSE
pbuild::compile_in_sourcetree
# pbuild::pre_configure() {
# pbuild::add_configure_args "-D CMAKE_BUILD_TYPE=RELEASE"
#
# pbuild::add_configure_args "-D BUILD_MPI=yes"
# pbuild::add_configure_args "-D BUILD_OMP=yes"
# pbuild::add_configure_args "-D PKG_USER-OMP=yes"
# pbuild::add_configure_args "-D PKG_BODY=yes"
# pbuild::add_configure_args "-D PKG_DIPOLE=yes"
# pbuild::add_configure_args "-D PKG_MOLECULE=yes"
# pbuild::add_configure_args "-D PKG_MPIIO=yes"
# pbuild::add_configure_args "-D PKG_REPLICA=yes"
# # pbuild::add_configure_args "-D PKG_REAX=yes"
# pbuild::add_configure_args "-D PKG_RIGID=yes"
# pbuild::add_configure_args "-D PKG_USER-REAXC=yes"
#
# }
# pbuild::configure() {
# cp -v "${BUILDBLOCK_DIR}/files/Makefile.PSI" "${BUILD_DIR}/src/MAKE/MINE"
# }
#
pbuild::configure() {
sed -i '/^CCFLAGS.*/ s/$/ -fopenmp/' ${BUILD_DIR}/src/MAKE/Makefile.mpi
sed -i '/^LINKFLAGS.*/ s/$/ -fopenmp/' ${BUILD_DIR}/src/MAKE/Makefile.mpi
cmake -D CMAKE_INSTALL_PREFIX="${PREFIX}" \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_MPI=yes \
-D BUILD_OMP=yes \
-D BUILD_TOOLS=yes \
-D BUILD_DOC=yes \
-D LAMMPS_MACHINE=mpi \
-D PKG_USER-OMP=yes \
-D PKG_ASPHERE=yes \
-D PKG_BODY=yes \
-D PKG_COMPRESS=yes \
-D PKG_CORESHELL=yes \
-D PKG_DIPOLE=yes \
-D PKG_GRANULAR=yes \
-D PKG_MANYBODY=yes \
-D PKG_KSPACE=yes \
-D PKG_MC=yes \
-D PKG_MISC=yes \
-D PKG_MOLECULE=yes \
-D PKG_MPIIO=yes \
-D PKG_OPT=yes \
-D PKG_PYTHON=yes \
-D PKG_REPLICA=yes \
-D PKG_RIGID=yes \
-D PKG_SNAP=yes \
-D PKG_USER-EFF=yes \
-D PKG_USER-DRUDE=yes \
-D PKG_USER-REAXC=yes \
-D BUILD_SHARED_LIBS=on \
${BUILD_DIR}/../src/cmake
}
pbuild::compile() {
echo BEGIN COMPILE
cd src
# make clean-all
# make no-all
make yes-user-omp
make yes-asphere
make yes-body
make yes-compress
make yes-coreshell
make yes-dipole
make yes-granular
make yes-manybody
make yes-kspace
make yes-mc
make yes-misc
make yes-molecule
make yes-mpiio
make yes-opt
make yes-python
make yes-replica
make yes-rigid
make yes-snap
make yes-user-eff
make yes-user-drude
make yes-user-reaxc
make yes-user-reaxc args="-m serial"
make yes-user-reaxc args="-m mpi"
make mpi
echo ENDCOMPILE
cmake --build ${BUILD_DIR}
}
pbuild::install() {
install -m 0755 -d "${PREFIX}/bin"
# Modify this for installing individual binaries
install -m 0755 "${BUILD_DIR}/src/lmp_mpi" "${PREFIX}/bin/"
# Strip all present binaries
for file in $(ls ${PREFIX}/bin/lmp_*)
do
strip "$file"
done
make install
}
2018.11 patch_15Nov2018.tar.gz
2019.8 stable_7Aug2019.tar.gz
2020.3 lammps-3Mar20.tar.gz
qe/6.3 unstable gcc/8.2.0 openmpi/3.1.1 b:cmake/3.9.6
qe/6.5 unstable gcc/9.3.0 lapack/3.9.0 OpenBLAS/0.3.9 openmpi/4.0.4_slurm b:cmake/3.15.5
#!/usr/bin/env modbuild
pbuild::set_download_url "https://github.com/QEF/q-e/archive/$P-$V.tar.gz"
echo "https://github.com/QEF/q-e/archive/$P-$V.tar.gz"
pbuild::add_to_group 'MPI'
......@@ -9,24 +8,16 @@ pbuild::install_docfiles License README.md CONTRIBUTING.md
pbuild::compile_in_sourcetree
pbuild::configure() {
mkdir -p ${PREFIX}
./configure -enable-openmp --with-prefix="${PREFIX}/bin" --prefix="${PREFIX}/bin"
pbuild::pre_configure() {
pbuild::add_configure_args "-enable-openmp"
}
pbuild::compile() {
make all
make install
}
pbuild::install() {
# Due to bug in: https://gitlab.com/QEF/q-e/commit/88e6558646dbbcfcafa5f3fa758217f6062ab91c.diff
# Deploying custom install procedure
mkdir -p ${PREFIX}/bin
cd ${BUILD_DIR}
for x in `find * ! -path "test-suite/*" -name *.x -type f` ; do
cp $x ${PREFIX}/bin/
done
echo 'Quantum ESPRESSO binaries installed in ${PREFIX}/bin'
# make install
:
}
Java/10u44 stable
Java/10.0.44 removed
Java/12u2 stable
Java/12.0.2 deprecated
#!/usr/bin/env modbuild
pbuild::set_download_url "https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz"
URL=$(grep -E "^${V_MAJOR}" files/version-to-URL.txt | awk '{print $2}')
echo $URL
pbuild::set_download_url "${URL}"
pbuild::add_to_group 'Programming'
......@@ -13,33 +17,7 @@ pbuild::compile() {
}
pbuild::install() {
install -m 0755 -d "${PREFIX}/bin"
for binary_file in $(ls ${SRC_DIR}/bin/*)
do
install -m 0755 "${binary_file}" "${PREFIX}/bin"
done
for java_dir in $(echo "lib lib/security lib/jfr lib/server")
do
mkdir -p "${PREFIX}/${java_dir}"
install -m 0755 -d "${PREFIX}/${java_dir}"
for library_file in $(find ${SRC_DIR}/${java_dir} -maxdepth 1 -type f)
do
install -m 0755 "${library_file}" "${PREFIX}/${java_dir}"
done
done
for java_dir in $(echo "conf conf/management conf/security conf/security/policy conf/security/policy/unlimited conf/security/policy/limited conf/sdp")
do
mkdir -p "${PREFIX}/${java_dir}"
install -m 0755 -d "${PREFIX}/${java_dir}"
for library_file in $(find ${SRC_DIR}/${java_dir} -maxdepth 1 -type f)
do
install -m 0755 "${library_file}" "${PREFIX}/${java_dir}"
done
done
for java_dir in $(echo "jmods")
for java_dir in $(find ${SRC_DIR} -type d | sed -n "s|^${SRC_DIR}/||p")
do
mkdir -p "${PREFIX}/${java_dir}"
install -m 0755 -d "${PREFIX}/${java_dir}"
......
10u44 https://download.java.net/openjdk/jdk10/ri/openjdk-10+44_linux-x64_bin_ri.tar.gz
12u2 https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz
15u36 https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_linux-x64_bin.tar.gz
ROOT environment created on request from Alexander Skawran
name: hep_root
channels:
- conda-forge
dependencies:
- python=3.7
- root
- numpy
- root_numpy
- pandas
- matplotlib
- tensorflow
- nb_conda_kernels
......@@ -6,5 +6,15 @@ channels:
dependencies:
- python=3.6
- ldapuserdir
- cython # for pyslurm
# python development
- conda-build
- cython # for pyslurm
- black
- flake8
- mypy
- mypy_extensions
- typing_extensions
- tox
- tox-conda
- pytest
- bpython
# scicat-client
The scicat-client environment is used in the datacatalog module. Contact
Spencer Bliven, Stephan Egli, or Leo Sala for more info.
## Installing
First, create the conda environment
conda env create -f scicat_client.yml
Next, install scicat_client. Eventually this should be done automatically
through conda, but for now it needs to be installed from source.
git clone git@github.com:paulscherrerinstitute/scicat_client.git
cd scicat_client
conda activate scicat_client-0.1.0
python setup.py install
# Clean environment based on pure conda-forge packages
name: scicat_client-0.1.0
channels:
- conda-forge
- http://conda-pkg.intranet.psi.ch
dependencies:
- python=3.8
- requests
# development tools
- conda-build
- black
- flake8
- mypy
- mypy_extensions
- typing_extensions
- tox
- tox-conda
- pytest
# Topaz
[Topaz](https://github.com/tbepler/topaz) is a conda-based cryoEM particle
picker. It is used primarily through cryosparc, but also provides python
notebooks.
See https://intranet.psi.ch/en/bio/computing-cryosparc
## INSTALLATION
IMPORTANT! DON'T INSTALL WITH AURISTOR. Use an OpenAFS system (e.g. pmod6)
export TMPDIR=/opt/tmp/$USER
export XDG_CACHE_HOME=/opt/tmp/$USER/.cache
CONDA_COPY_ALWAYS=1 conda env create --file topaz.yml
conda activate topaz-0.2.5
The alternate TMPDIR is required on pmod6 because /tmp is too small for pip to expand all wheel files.
name: topaz-0.2.5
channels:
- tbepler
- defaults
dependencies:
- python=3.6
- cudatoolkit=9.2
- pytorch
- topaz
# Building of an Anaconda release using Pmodules
## Important Note about access permissions
The central anacoda installations are located below `/afs/psi.ch/sys/psi.merlin/Programming/anaconda`. All administrators
of these installations must be members of the AFS group `sys.modules:psi_python` in order to have write permission.
## Concepts
* The anaconda module just provides the **conda** package management tool together with its directory infrastructure which contains *conda environments* and a cache of downloaded packages
......@@ -14,7 +19,7 @@
## Building a central conda environment
* **Allways work on the host pmod6**: conda is trying to use hardlinks where it can. There is an issue that can appear if you install from a machine that uses Auristor (which provides hardlinks). This causes whole environments to become corrupt, so that only a PSI AFS admin can fix the problem. Therefore we only install from pmod6 which runs openAFS.
* **Allways work on the host pmod6**: conda is trying to use hardlinks where it can. There is an issue that can appear if you install from a machine that uses Auristor (which provides hardlinks within the same AFS volume). Accessing or modifying from an old OpenAFS client can cause problems. This causes whole environments to become corrupt, so that only a PSI AFS admin can fix the problem. Therefore we only install from pmod6 which runs openAFS.
### installation of a pure conda environment
......@@ -70,3 +75,48 @@ This works if the python package has a correct setup.py build
cd /opt/psi/Programming/anaconda/2019.07/xxxx/mypackage
pip install .
```
## Building for use with jupyter
Jupyter can discover conda environments if the environment contains the **nb_conda_kernels** package.
Regrettably the environment activation by this package does not run through the full process as compared to the command line functions. The activation scripts that can be placed in an environment do not get executed (q.v. my bug report https://github.com/Anaconda-Platform/nb_conda_kernels/issues/145).
In order to fix this, we must use a workaround which involves modifying the kernel spec configuration file of the environment to wrap the call to the python kernel like in this example for `.../envs/mpi-test/share/jupyter/kernels/python3/kernel.json`:
```
{
"argv": [
"/opt/psi/Programming/anaconda/2019.07/admintools/kernelwrapper.sh",
"mpi-test",
"/opt/psi/Programming/anaconda/2019.07/conda/envs/mpi-test/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
```
In order to modify an environment easily I wrote a tool found in the `admintools` of this buildblock which you can use as follows:
```
files/admintools/install-kernelwrapper.py -v /opt/psi/Programming/anaconda/2019.07/conda/envs/hep_root
```
### Logging of environment activation information
The logging of information for the usage of central environments is
important, because it allows to do lifetime management of the conda
environments. We can find out whether a particular environment is used at all
and by whom, and can so plan the decommissioning.
Logging is currently implemented by an activation hook script that gets placed
in each environment. This is done by running the script `.../files/admintools/install-env-loggers.sh`
which will loop over all central environments of this anaconda pmodule.
# simulate `conda init` type hook
# Expects CONDA_EXE and CONDA_PREFIX to be set
__conda_setup="$("${CONDA_EXE:-conda}" 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "${CONDA_PREFIX:?CONDA_PREFIX not set}/etc/profile.d/conda.sh" ]; then
. "${CONDA_PREFIX}/etc/profile.d/conda.sh"
else
export PATH="${CONDA_PREFIX}/bin:$PATH"
fi
fi
unset __conda_setup
#!/bin/bash
# Script to install logging into the activation hook directories
# of environments
#
# 2020 - Derek Feichtinger
function envlist() {
conda env list --json | jq -r '.envs[]' | grep -E -v 'conda$'
}
if [[ -z "$CONDA_PREFIX" ]]; then
echo "Error: No conda distribution seems active (CONDA_PREFIX)" >&2
exit 1
fi
for env in $(envlist); do
if [[ -e "$env/etc" ]]; then
echo "Installing into $env"
mkdir -p $env/etc/conda/activate.d
cat <<'EOF' > $env/etc/conda/activate.d/log-envname.sh
#!/bin/bash
logger "activated conda module: ${CONDA_PREFIX}"
EOF
else
echo "WARNING: SKIPPING ENV: $env has no /etc" >&2
fi
done
#!/usr/bin/env python
# installs a jupyter kernel wrapper solution into the environment's
# $ENVPATH/share/jupyter/kernels/python3/kernel.json kernel definition
# typical envpath at PSI
# "/opt/psi/Programming/anaconda/2019.07/conda/envs/datascience_py37"
import re
import os
import sys
import shutil
from datetime import datetime
import argparse
parser = argparse.ArgumentParser()
# DEFAULTS
verbose_flag = False
parser.add_argument("envpath", help="conda env path")
parser.add_argument("-v", "--verbose", help="verbose mode",action="store_true")
args = parser.parse_args()
if args.verbose:
verbose_flag = True
envpath = args.envpath
envname = os.path.basename(envpath)
condaroot = re.sub(r'(.*)/conda/envs/.*', r'\1', envpath)
kwrapper = os.path.join(condaroot, 'admintools/kernelwrapper.sh')
kfile = os.path.join(envpath,"share/jupyter/kernels/python3/kernel.json")
date_time = datetime.now().strftime("%Y%m%d-%H%M%S")
if verbose_flag:
print("env: %s" % envname)
print(kwrapper)
if not os.path.isfile(kwrapper):
sys.stderr.write("Error: no wrapper found at %s\n" % (kwrapper))
sys.exit(1)
searchstr = r'"argv": \[\n( *"/.*python", *)'
subststr = r'"argv": [\n' + ' "' + kwrapper + '",\n' + ' "' + envname + r'",\n\1'
try:
with open(kfile,"r") as fp:
filestr = "".join(fp.readlines())
except IOError:
sys.stderr.write("Error: Env has no kernel file: %s\n" % kfile)
sys.exit(0)
if re.search(kwrapper, filestr):
if verbose_flag:
print("env %s already contains kernelwrapper" % envpath)
sys.exit(0)
if re.search(searchstr, filestr):
filestr = re.sub(searchstr,
subststr,
filestr)
print(filestr)
bupfile = kfile + "-" + date_time + ".bup"
if verbose_flag:
print("copying original file to %s" % bupfile)
shutil.copyfile(kfile, bupfile)
if verbose_flag:
print("writing new file %s" % kfile)
print(filestr)
with open(kfile,"w") as fp:
fp.write(filestr)
else:
sys.stderr.write("ERROR: Could not do substitution in %s" % kfile)
sys.stderr.write(filestr)
#!/bin/bash
# kernelwrapper.sh
# This wrapper is needed to correctly have jupyter activate conda evnironments
# including the running of the $ENV/etc/conda/activate.d hooks
# q.v. https://github.com/Anaconda-Platform/nb_conda_kernels/issues/145
#
# This script must be called from the config located in an environment
# $ENV/share/jupyter/kernels/python3/kernel.jsonshare/jupyter/kernels/python3/kernel.json
# 2019 - Derek Feichtinger
dbgecho() {
DBGLOG=/tmp/kernelwrapper-${USER}.log
if [[ $DEBUG_JUPYTER_WRAPPER == 1 ]]; then
......
anaconda/2018.12 unstable
anaconda/2019.03 unstable
anaconda/2019.07 unstable
anaconda/2019.07 stable