uv (and direnv) on DelftBlue: testing with ASE¶
These instructions install uv
and direnv
in your home directory.
uv
is a very fast and powerful Python installer, package manager and virtual environment manager written in Rust.direnv
is a shell extensions that automatically loads or unloads environment variables when you enter or leave a directory. This allows you to activate or deactivate a Python virtual environment when entering or leaving a directory.
In this tutorial, you’ll use uv
to create a virtual environment with the Python version from the 2025 software stack, install the ASE package, and run an ASE example script on DelftBlue using sbatch
.
Install uv¶
Install uv
in your $HOME/.local/
:
curl -LsSf https://astral.sh/uv/install.sh | sh
Ensure that $HOME/.local/bin
is included in your PATH
(e.g. .bashrc
).
Install direnv¶
Install direnv
in your $HOME/.local/
:
curl -sfL https://direnv.net/install.sh | bash
Add the following line to your shell startup file (e.g. ~/.bashrc):
eval "$(direnv hook bash)"
Reload your shell afterward, or manually execute this line in your current shell.
Load DelftBlue Python module¶
In this example we use the Python version of the current 2025 stack
module load 2025 python
Check wheter uv
finds this version and note the correct Python version number for later (3.11.9
):
uv python list
Example output (truncated):
cpython-3.15.0a1-linux-x86_64-gnu <download available>
cpython-3.11.13-linux-x86_64-gnu /usr/bin/python3.11
cpython-3.11.9-linux-x86_64-gnu /apps/arch/2025/software/linux-rhel8-cascadelake/gcc-13.3.0/python-3.11.9-y7fulttvp6obrlg7fu55qwdhcvbhlcrd/bin/python3.11
cpython-3.11.9-linux-x86_64-gnu /apps/arch/2025/software/linux-rhel8-cascadelake/gcc-13.3.0/python-3.11.9-y7fulttvp6obrlg7fu55qwdhcvbhlcrd/bin/python3 -> python3.11
cpython-3.11.9-linux-x86_64-gnu /apps/arch/2025/software/linux-rhel8-cascadelake/gcc-13.3.0/python-3.11.9-y7fulttvp6obrlg7fu55qwdhcvbhlcrd/bin/python -> /apps/arch/2025/software/linux-rhel8-cascadelake/gcc-13.3.0/python-3.11.9-y7fulttvp6obrlg7fu55qwdhcvbhlcrd/bin/python3
graalpy-3.8.5-linux-x86_64-gnu <download available>
Initialise ASE project¶
Create a new project directory, initialize it with uv, and set up a virtual environment using the detected Python version:
cd ~
uv init ase_project
cd ase_project
uv venv --python 3.11.9
Next, enable automatic activation of this virtual environment using direnv:
echo "source .venv/bin/activate" > .envrc
direnv allow
From now on, the virtual environment will activate automagically whenever you enter this directory (or its subdirectories).
Add the ASE package¶
Install the ASE package into your virtual environment:
uv add ase
Copy the ASE example from the Linux Command Line Course¶
From the DCSE Linux Command Line Course, locate the directory:
Exercises/ssh/delftblue_examples/03_gen_mod_folders
Copy this entire directory into your ase_project directory, then modify the sub_to_queue.sh
file as follows:
#!/bin/bash
#
#SBATCH --job-name="gen_mol"
#SBATCH --time=00:05:00
#SBATCH --partition=compute
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=1GB
#SBATCH --account=education-eemcs-courses-linuxcli
# Run Python script:
module load 2025
module load python
source $HOME/ase_project/.venv/bin/activate
srun python gen_mol_folders.py
Note: the python package modules have been removed as they are now installed as dependencies of ase
and provided as such in the virtual environment. \
Also note the source
line ‘activating’ this virtual environment.
Submit the job¶
You can now run sbatch
and inspect the resulting molecules
directory and .out
file:
sbatch sub_to_queue.sh