changed 2 months ago
Linked with GitHub

uv and pixi on computer centers

uv - https://docs.astral.sh/uv/

An extremely fast Python package and project manager, written in Rust.
A single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.

Install and configure uv

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Redirect cache and tools in project folder
export UV_CACHE_DIR=/crex/proj/uppmax-xxx/user/nobackup/.UV_CACHE_DIR
export UV_TOOL_DIR=/crex/proj/uppmax-xxx/user/nobackup/.UV_TOOL_DIR
# make the folders
mkdir -p $UV_CACHE_DIR $UV_TOOL_DIR

Run python tools without installation

# run python tool without installing it
uvx nf-core

Install python tools

Python modules (tools) that are executable will be installed in own environment and made available in your $PATH to run them directly. Example installation with nf-core

# install nf-core
uv install nf-core

# list tools
uv tool list

# update tool
uv tool update nf-core
# update all tools
uv tool update --all

# uninstall tool
uv tool uninstall nf-core

Maintaining uv

# update uv
uv self update

# clean cache
uv cache clean

For more details - follow the documentation online.

Offline installation with uv

Examples

forest - https://github.com/onnela-lab/forest
​​​# Load uv on Rackham (or computer with uv installed and Internet)
​​​source /sw/generic/uv-tools/setup/source.me
​​​
​​​# Clone the repository
​​​git clone https://github.com/onnela-lab/forest.git
​​​cd forest 
​​​mkdir cache              
​​​
​​​# Create the .venv that will also download the required packages
​​​uv sync --cache-dir cache
​​​# Remove the .venv - it will be recreated on Bianca
​​​rm -r .venv
​​​
​​​# On Bianca
​​​# Load uv on Bianca 
​​​source /sw/generic/uv-tools/setup/source.me
​​​
​​​# copy or move the forest folder in your project 
​​​cd forest
​​​uv sync --cache-dir cache --offline
​​​source .venv/bin/activate

​​​(beiwe-forest) [user@sensXXXXXXX-bianca forest]$ python3
​​​Python 3.13.3 (main, May 17 2025, 13:49:13) [Clang 20.1.4 ] on linux
​​​Type "help", "copyright", "credits" or "license" for more information.
​​​>>> import datetime
​​​>>> from forest.bonsai.simulate_log_data import sim_log_data
​​​>>> from forest.bonsai.simulate_gps_data import sim_gps_data, gps_to_csv
​​​... from forest.jasmine.traj2stats import Frequency, gps_stats_main
​​​... from forest.willow.log_stats import log_stats_main
​​​...      
​​​>>>      

​​​deactivate

pixi - https://pixi.sh/latest/

Pixi is a package management tool for developers. It allows the developer to install libraries and applications in a reproducible way. Use pixi cross-platform, on Windows, Mac and Linux.

Install and configure pixi

# Install pixi
curl -fsSL https://pixi.sh/install.sh | bash

# Redirect cache and globals in project folder
export PIXI_CACHE_DIR=/crex/proj/uppmax-xxx/user/nobackup/.PIXI_CACHE_DIR
export PIXI_HOME=/crex/proj/uppmax-xxx/user/nobackup/.PIXI_HOME
# make the folders
mkdir -p $PIXI_CACHE_DIR $PIXI_HOME

# add global bin to $PATH
export PATH=$PATH:$PIXI_HOME/bin

Install tools globally available

pixi global install -c bioconda -c conda-forge samtools
Global environments as specified in '/sw/apps/pixi/manifests/pixi-global.toml'
└── samtools: 1.9 (installed)
    └─ exposes: ace2sam, blast2sam, bowtie2sam, export2sam, interpolate_sam, maq2sam-long, maq2sam-short, md5fa, md5sum-lite, novo2sam, plot-bamstats, psl2sam, sam2vcf, samtools, seq_cache_populate, soap2sam, wgsim, wgsim_eval, zoom2sam


# list global tools
pixi global list
Global environments as specified in '/crex/proj/uppmax-xxx/user/nobackup/.PIXI_HOME/manifests/pixi-global.toml'
└── samtools: 1.9 
    └─ exposes: ace2sam, blast2sam, bowtie2sam, export2sam, interpolate_sam, maq2sam-long, maq2sam-short, md5fa, md5sum-lite, novo2sam, plot-bamstats, psl2sam, sam2vcf, samtools, seq_cache_populate, soap2sam, wgsim, wgsim_eval, zoom2sam

    
# Update global tool
pixi global update samtools
# Update all tools 
pixi global update

Maintain pixi

# Update pixi
pixi self-update

# clean cache
pixi clean cache

pixi-pack

https://pixi.sh/latest/deployment/pixi_pack/
There is a convenient way to pack whole environment/project (download all necessary packages and wrap them in a single file) and unpack it on another machine into a new environment (even without conda or pixi available on that machine).

# Install pixi-pack as global tool
pixi global install pixi-pack

# Init new project
pixi init --platform linux-64 -c conda-forge -c bioturing -c bioconda CellTrek

# Add packages
cd CellTrek
pixi add bioturing::r-celltrek "r-seurat<5.0" "r-seuratobject<5.0" bioconda::bioconductor-consensusclusterplus

pixi-pack pack --use-cache ./cache
# Then unpack on the other computer with
pixi-pack unpack environment.tar

# or create executable that can unpack itself
pixi-pack pack --create-executable --use-cache ./cache
# on the other machine create folder and run to unpack
./environment.sh

# Use conda to activate the environment
conda activate /full/path_to_env

Examples

gsMap
pixi init --platform linux-64 -c conda-forge -c bioconda gsMap
cd gsMap
pixi add "python>=3.10" bioconda::gsmap

# Test the setup
pixi shell

(gsMap) gsmap -v
gsMap version 1.73.5

exit 
# then pixi-pack ... and so on...

Contacts:

Select a repo