Image size: 4.8 GB

For more on pulling from the registry, see the ilifu documentation.

First, once: add the registry and make it your default

singularity remote add --no-login idia-registry https://sregistry.idia.ac.za
singularity remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

singularity remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

singularity pull library://casa/casa-modular:v6.7.6-py3.12-2026-08-12

Shell into the container

singularity shell library://casa/casa-modular:v6.7.6-py3.12-2026-08-12

Run the container

singularity run library://casa/casa-modular:v6.7.6-py3.12-2026-08-12

First, once: add the registry and make it your default

apptainer remote add --no-login idia-registry https://sregistry.idia.ac.za
apptainer remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

apptainer remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

apptainer pull library://casa/casa-modular:v6.7.6-py3.12-2026-08-12

Shell into the container

apptainer shell library://casa/casa-modular:v6.7.6-py3.12-2026-08-12

Run the container

apptainer run library://casa/casa-modular:v6.7.6-py3.12-2026-08-12
Bootstrap: debootstrap
MirrorURL: http://archive.ubuntu.com/ubuntu/
OSVersion: noble

%labels
        APPLICATION_NAME Ubuntu LTS + CASA 6 (Modular)
        OS_VERSION 24.01
        APPLICATION_URL https://casadocs.readthedocs.io/en/stable/notebooks/introduction.html#Modular-Packages

        SYSTEM_NAME iLifu
        SYSTEM_SINGULARITY_VERSION 4.1.3
        SYSTEM_URL http://www.ilifu.ac.za

        AUTHOR_NAME IDIA
        AUTHOR_EMAIL support@ilifu.ac.za

%environment
        export VIRTUAL_ENV=/opt/casa-venv
        export PATH="/opt/casa-venv/bin:$PATH"
        export PYTHONPATH="/opt/casa-venv/lib/python3.12/site-packages:$PYTHONPATH"
        export PYTHONPATH=$PYTHONPATH:/opt/casaaddons
        
        # Priority LD_LIBRARY_PATH including Qt6 & AppImage paths
        export LD_LIBRARY_PATH=/opt/casaplotms/usr/lib:/opt/casaviewer/usr/lib:/opt/casatablebrowser/usr/lib:/opt/casalogger/usr/lib:/opt/casafeather/usr/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
        
        export PATH=$PATH:/opt/casaplotms/usr/bin
        export PATH=$PATH:/opt/casaviewer/usr/bin
        export PATH=$PATH:/opt/casatablebrowser/usr/bin
        export PATH=$PATH:/opt/casalogger/usr/bin
        export PATH=$PATH:/opt/casafeather/usr/bin
        export PATH=$PATH:~/.local/bin
        export CASARCFILES=/opt/.casarc
        
        # Qt Settings
        export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/casaplotms/usr/plugins/platforms/
        export QT_QPA_PLATFORM=xcb
        export XDG_RUNTIME_DIR=/tmp/runtime-$USER
        export QT_X11_NO_MITSHM=1

%post

        # Create Installation Directories and export paths
        mkdir -p /opt
        export DEBIAN_FRONTEND=noninteractive
        
        # Set LD_LIBRARY_PATH inside container during build
        export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu

        # Installation of initial packages
        apt-get update -y
        apt-get install -y software-properties-common
        add-apt-repository universe
        add-apt-repository -y multiverse
        add-apt-repository -y restricted
        apt-get update -y
        apt-get install -y wget vim apt-utils git build-essential bzip2 libpng-dev gfortran xvfb ghostscript curl pkg-config libxi-dev libfuse-dev python-is-python3
        apt-get install -y fuse
        apt-get install -y perl

        # Install SQLite inside container FIRST
        apt-get install -y libsqlite3-dev sqlite3 libsqlite3-0
        
        # Download and compile SQLite INSIDE container
        cd /tmp
        wget https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz
        tar xzf sqlite-autoconf-3450100.tar.gz
        cd sqlite-autoconf-3450100
        ./configure --prefix=/usr/local
        make -j$(nproc)
        make install
        
        # Update ldconfig inside container
        ldconfig

        # Installing plotms dependencies
        apt-get install -y libc-ares-dev libgoogle-perftools-dev libgrpc-dev
        apt-get install -y casacore-dev casacore-data

        # Update pip and install python packages
        apt-get install -y python3-pip
        apt-get install -y python3.12 python3.12-dev python3.12-venv

        # Create virtual environment
        cd /opt
        python3.12 -m venv casa-venv
        . /opt/casa-venv/bin/activate
        pip3.12 install --upgrade pip wheel
        
        # Install pysqlite3 from source
        pip3.12 install --upgrade --force-reinstall --no-binary pysqlite3 pysqlite3
        
        # Continue with package installation
        pip3.12 install --upgrade cloudpickle holoviews datashader bokeh pandas "dask-ms[xarray]" scipy==1.13.0 protobuf==3.20 scikit-image katdal astroquery DateTime
        pip3.12 install --no-binary :all: python-casacore
        pip3.12 install pyvirtualdisplay
        
        # Install Jupyter for IPykernel
        pip3.12 install jupyter ipykernel
        pip3.12 install numpy==1.26.4

        # MATPLOTLIB FIX FOR PYTHON 3.12 + CASA 
        sed -i 's/include-system-site-packages = true/include-system-site-packages = false/g' /opt/casa-venv/pyvenv.cfg

        . /opt/casa-venv/bin/activate
        pip3.12 install --upgrade pip
        pip3.12 uninstall -y matplotlib mpl_toolkits
        pip3.12 install "matplotlib>=3.8.0"

        # Fix libraries: libgrpc.so.7
        ln -sf /usr/lib/x86_64-linux-gnu/libgrpc.so.10 /usr/lib/x86_64-linux-gnu/libgrpc.so.7
        ln -sf /usr/lib/x86_64-linux-gnu/libgpr.so.10 /usr/lib/x86_64-linux-gnu/libgpr.so.7 || true
        ldconfig

        # Fix missing ICU SONAMEs
        ln -sf /usr/lib/x86_64-linux-gnu/libicui18n.so.70 /usr/lib/x86_64-linux-gnu/libicui18n.so.60 || true
        ln -sf /usr/lib/x86_64-linux-gnu/libicuuc.so.70 /usr/lib/x86_64-linux-gnu/libicuuc.so.60 || true
        ln -sf /usr/lib/x86_64-linux-gnu/libicudata.so.70 /usr/lib/x86_64-linux-gnu/libicudata.so.60 || true
        ldconfig || true

        # Install Qt dependencies - INCLUDING Qt6 libraries required for CASA 6.6+ / casaplotms 2.8+
        apt-get install -y \
            libqt6openglwidgets6 \
            libqt6gui6 \
            libqt6core6 \
            qt6-base-dev \
            libxcb-xinerama0 \
            libxcb-icccm4 \
            libxcb-image0 \
            libxcb-keysyms1 \
            libxcb-randr0 \
            libxcb-render-util0 \
            libxcb-shape0 \
            libxcb-sync1 \
            libxcb-xfixes0 \
            libxcb-xkb1 \
            libxkbcommon-x11-0 \
            libxkbcommon0 \
            x11-utils \
            libglx-mesa0 \
            mesa-vulkan-drivers \
            libgl1 \
            xauth \
            dbus-x11 \
            qtbase5-dev \
            qtchooser \
            qt5-qmake \
            qtbase5-dev-tools
            
        # Install PyBDSF
        apt-get install -y libboost-python-dev
        pip3.12 install --upgrade PyQt5==5.15.7
        pip3.12 install --upgrade astropy
        pip3.12 install bdsf[ishell]

        # Install Healpy
        apt-get install -y python3-healpy

        # Install PYGDSM
        pip3.12 install h5py
        pip3.12 install git+https://github.com/telegraphic/pygdsm

        # Install CASA 6
        apt-get install -y libopenmpi-dev

        pip3.12 install casaconfig==1.4.0
        pip3.12 install casatools==6.7.6.14
        pip3.12 install casatasks==6.7.6.14
        pip3.12 install casaplotms==2.8.2
        pip3.12 install casaviewer==2.4.4
        pip3.12 install casashell==6.7.6.14
        pip3.12 install casaplotserver==2.0.3
        pip3.12 install casatestutils==6.7.6.14
        pip3.12 install casatablebrowser==0.0.40
        pip3.12 install casalogger==1.0.23
        pip3.12 install casafeather==0.0.27
        pip3.12 install casampi==0.5.9

        cd /opt
        git clone https://open-bitbucket.nrao.edu/scm/casa/casaaddons.git

        # Install katbeam
        pip3.12 install git+https://github.com/ska-sa/katbeam

        # Extract AppImages
        cd /opt
        /opt/casa-venv/lib/python3.12/site-packages/casaplotms/__bin__/casaplotms-x86_64.AppImage --appimage-extract
        mv squashfs-root casaplotms
        chmod -R go+rx /opt/casaplotms
        
        # Create wrapper script that preserves both AppImage & system Qt library paths
        cat > /opt/casaplotms/usr/bin/casaplotms-wrapper << 'EOF'
#!/bin/bash
export LD_LIBRARY_PATH="/opt/casaplotms/usr/lib:/opt/casaplotms/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
exec /opt/casaplotms/usr/bin/casaplotms "$@"
EOF
        chmod +x /opt/casaplotms/usr/bin/casaplotms-wrapper
        
        # Create symlinks for Qt plugins in AppImage directory
        mkdir -p /opt/casaplotms/usr/plugins/platforms/
        find /opt/casaplotms -name "libqxcb.so" -exec cp {} /opt/casaplotms/usr/plugins/platforms/ \; 2>/dev/null || true
        
        if [ ! -f /opt/casaplotms/usr/plugins/platforms/libqxcb.so ]; then
            mkdir -p /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/
            ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so /opt/casaplotms/usr/plugins/platforms/ 2>/dev/null || true
        fi
        
        # Fix the plotmstool.py path to target the wrapper
        sed -i -e "s|app_path = __os.path.join( __os.path.abspath( __os.path.join(__os.path.dirname(__file__),\"..\") ), '__bin__/casaplotms-x86_64.AppImage')|app_path = '/opt/casaplotms/usr/bin/casaplotms-wrapper'|g" /opt/casa-venv/lib/python3.12/site-packages/casaplotms/private/plotmstool.py
        
        # CASAviewer
        /opt/casa-venv/lib/python3.12/site-packages/casaviewer/__bin__/casaviewer-x86_64.AppImage --appimage-extract
        mv squashfs-root casaviewer
        chmod -R go+rx /opt/casaviewer
        sed -i -e "s|app_path = __os.path.join( __os.path.abspath(__os.path.join(__os.path.dirname(__file__),'..')), '__bin__/casaviewer-x86_64.AppImage' )|app_path = '/opt/casaviewer/usr/bin/casaviewer'|g" /opt/casa-venv/lib/python3.12/site-packages/casaviewer/private/config.py
        
        # CASAtablebrowser
        /opt/casa-venv/lib/python3.12/site-packages/casatablebrowser/__bin__/casatablebrowser-x86_64.AppImage --appimage-extract
        mv squashfs-root casatablebrowser
        chmod -R go+rx /opt/casatablebrowser
        sed -i -e "s|app_path = __os.path.abspath(__os.path.dirname(__file__))|app_path = '/opt/casatablebrowser/usr/bin'|g" /opt/casa-venv/lib/python3.12/site-packages/casatablebrowser/__casatablebrowser.py
        sed -i -e 's|app_path = __os.path.join( app_path, "__bin__","casatablebrowser-x86_64.AppImage" )|app_path = __os.path.join( app_path, "casatablebrowser" )|g' /opt/casa-venv/lib/python3.12/site-packages/casatablebrowser/__casatablebrowser.py
        
        # CASAlogger
        /opt/casa-venv/lib/python3.12/site-packages/casalogger/__bin__/casalogger-x86_64.AppImage --appimage-extract
        mv squashfs-root casalogger
        chmod -R go+rx /opt/casalogger
        sed -i -e "s|app_path = os.path.join(|app_path = '/opt/casalogger/usr/bin/casalogger'|g" /opt/casa-venv/lib/python3.12/site-packages/casalogger/casalogger.py
        sed -i '31,33d' /opt/casa-venv/lib/python3.12/site-packages/casalogger/casalogger.py
        
        # CASAfeather (Path fixed to point inside site-packages)
        /opt/casa-venv/lib/python3.12/site-packages/casafeather/__bin__/casafeather-x86_64.AppImage --appimage-extract
        mv squashfs-root casafeather
        chmod -R go+rx /opt/casafeather
        sed -i -e "s|app_path = __os.path.join(|app_path = '/opt/casafeather/usr/bin/casafeather'|g" /opt/casa-venv/lib/python3.12/site-packages/casafeather/casafeather.py
        sed -i '52,54d' /opt/casa-venv/lib/python3.12/site-packages/casafeather/casafeather.py

        deactivate

        # Fix path to casacore data
        echo 'measures.directory: /usr/share/casacore/data' > /opt/.casarc

        # Fix command prompt in Singularity
        printf 'export PS1="\u@$SINGULARITY_NAME:\w$ "' > /.singularity.d/env/999-psvars.sh
        
        # Cleanup container
        apt-get clean
        apt-get autoclean
        
%runscript
    exec /opt/casa-venv/bin/python "$@"
Download casa-casa-modular_v6.7.6-py3.12-2026-08-12.def
#!/bin/sh

    exec /opt/casa-venv/bin/python "$@"
# /.singularity.d/env/90-environment.sh
#!/bin/sh
# Custom environment shell code should follow


        export VIRTUAL_ENV=/opt/casa-venv
        export PATH="/opt/casa-venv/bin:$PATH"
        export PYTHONPATH="/opt/casa-venv/lib/python3.12/site-packages:$PYTHONPATH"
        export PYTHONPATH=$PYTHONPATH:/opt/casaaddons
        
        # Priority LD_LIBRARY_PATH including Qt6 & AppImage paths
        export LD_LIBRARY_PATH=/opt/casaplotms/usr/lib:/opt/casaviewer/usr/lib:/opt/casatablebrowser/usr/lib:/opt/casalogger/usr/lib:/opt/casafeather/usr/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
        
        export PATH=$PATH:/opt/casaplotms/usr/bin
        export PATH=$PATH:/opt/casaviewer/usr/bin
        export PATH=$PATH:/opt/casatablebrowser/usr/bin
        export PATH=$PATH:/opt/casalogger/usr/bin
        export PATH=$PATH:/opt/casafeather/usr/bin
        export PATH=$PATH:~/.local/bin
        export CASARCFILES=/opt/.casarc
        
        # Qt Settings
        export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/casaplotms/usr/plugins/platforms/
        export QT_QPA_PLATFORM=xcb
        export XDG_RUNTIME_DIR=/tmp/runtime-$USER
        export QT_X11_NO_MITSHM=1