Hi,
On Thu, Nov 30, 2017 at 02:38:55AM -0800, Laurent Fournier wrote:
> Hi,
>
...
> laurent@NanoStation:~/atWork/Singularity$ ./conda create -n py27 python=2.7
>
> Fetching package metadata ...............
> Solving package specifications: .
>
> Package plan for installation in environment /home/laurent/.conda/envs/py27:
>
>
> But from that point, whenever i try "source activate" or even modify the
> calling script as follows :
>
> laurent@NanoStation:~/atWork/Singularity$ cat activate
>
> #!/bin/sh
> singularity exec my/path/to/pytools27.img bash -c 'source activate $@'
>
>
> Nothing happens :
>
> laurent@NanoStation:~/atWork/Singularity$ source activate py27
> laurent@NanoStation:~/atWork/Singularity$ ./activate py27
> laurent@NanoStation:~/atWork/Singularity$
>
>
> Any ideas ?
your "singularity exec" is finished once the "source activate py27" exits
It' just a one line command... doing nothing and exiting.
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ cat Singularity
#!/bin/bash
#
# Tru Huynh <
t...@pasteur.fr>
# 2017-12-01: initial version
# use as baseline to build a container from miniconda
# added bioconda + conda-forge from Laurent Fournier <
ma...@laurent-fournier.be>
# [Singularity] Using conda envs as modules on a cluster
BootStrap: docker
From: continuumio/miniconda
%runscript
echo "This is what happens when you run the container..."
export PATH=/opt/conda/bin:${PATH}
/bin/bash
%environment
export PATH=/opt/conda/bin:${PATH}
unset CONDA_DEFAULT_ENV
export ANACONDA_HOME=/opt/conda
%post
export PATH=/opt/conda/bin:${PATH}
echo "Hello from inside the container"
conda update -y conda
conda update --all
#
conda config --add channels bioconda
conda config --add channels conda-forge
conda clean --index-cache --tarballs --packages --yes
conda list > /conda.txt
touch /`date -u -Iseconds`
%labels
MAINTAINER truatpasteurdotfr
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ sudo singularity build py27 Singularity
...
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ singularity exec ./py27 bash -c 'conda create -n py27 python=2.7'
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment /home/tru/.conda/envs/py27:
The following NEW packages will be INSTALLED:
ca-certificates: 2017.08.26-h1d4fec5_0
certifi: 2017.11.5-py27h71e7faf_0
libedit: 3.1-heed3624_0
libffi: 3.2.1-hd88cf55_4
libgcc-ng: 7.2.0-h7cc24e2_2
libstdcxx-ng: 7.2.0-h7a57d05_2
ncurses: 6.0-h9df7e31_2
openssl: 1.0.2m-h26d622b_1
pip: 9.0.1-py27ha730c48_4
python: 2.7.14-hdd48546_24
readline: 7.0-ha6073c6_4
setuptools: 36.5.0-py27h68b189e_0
sqlite: 3.20.1-hb898158_2
tk: 8.6.7-hc745277_3
wheel: 0.30.0-py27h2bc6bb2_1
zlib: 1.2.11-ha838bed_2
Proceed ([y]/n)? y
#
# To activate this environment, use:
# > source activate py27
#
# To deactivate an active environment, use:
# > source deactivate
#
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ singularity exec py27 bash -c 'source activate py27; printenv|grep CONDA; conda list'
ANACONDA_HOME=/opt/conda
CONDA_PATH_BACKUP=/opt/conda/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CONDA_PREFIX=/home/tru/.conda/envs/py27
CONDA_PS1_BACKUP=
CONDA_DEFAULT_ENV=py27
# packages in environment at /home/tru/.conda/envs/py27:
#
ca-certificates 2017.08.26 h1d4fec5_0
certifi 2017.11.5 py27h71e7faf_0
libedit 3.1 heed3624_0
libffi 3.2.1 hd88cf55_4
libgcc-ng 7.2.0 h7cc24e2_2
libstdcxx-ng 7.2.0 h7a57d05_2
ncurses 6.0 h9df7e31_2
openssl 1.0.2m h26d622b_1
pip 9.0.1 py27ha730c48_4
python 2.7.14 hdd48546_24
readline 7.0 ha6073c6_4
setuptools 36.5.0 py27h68b189e_0
sqlite 3.20.1 hb898158_2
tk 8.6.7 hc745277_3
wheel 0.30.0 py27h2bc6bb2_1
zlib 1.2.11 ha838bed_2
[tru@elitebook840g3 singularity-docker-bioconda-forge]$
If you need your "activate" script to provide an interactive shell, you might need to spawn another shell:
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ cat activate
#!/bin/sh
singularity exec /home/tru/git/truatpasteurdotfr/singularity-docker-bioconda-forge/py27 bash -c "source activate $@; bash"
[tru@elitebook840g3 singularity-docker-bioconda-forge]$ ./activate py27
Singularity.py27> tru@elitebook840g3:~/git/truatpasteurdotfr/singularity-docker-bioconda-forge$ printenv|grep CONDA
ANACONDA_HOME=/opt/conda
CONDA_PATH_BACKUP=/opt/conda/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CONDA_PREFIX=/home/tru/.conda/envs/py27
CONDA_PS1_BACKUP=
CONDA_DEFAULT_ENV=py27
Singularity.py27> tru@elitebook840g3:~/git/truatpasteurdotfr/singularity-docker-bioconda-forge$
Cheers
Tru
--
Dr Tru Huynh | mailto:
t...@pasteur.fr | tel/fax
+33 1 45 68 87 37/19
https://research.pasteur.fr/en/team/structural-bioinformatics/
Institut Pasteur, 25-28 rue du Docteur Roux, 75724 Paris CEDEX 15 France