This banner placeholder was generated by Gemini 3 Banana Pro using already made asset like the pixi, apptainer and singularity logo
Pixi is a fast, easy and fun to use tool that allows you to manage multiple dependencies in multiple environment very easily. It has a great support either by its developers or community on discord.
Singularity/Apptainer is very used in bioinformatics, it's at the hearth of analyzes pipelines, but it's a headache to put in place. In another hand, pixi is fast, easy to use, but it's not a container and so harder to keep intact for a long period of time. The idea behind pixitainer is to put a pixi environment into an Apptainer container, so you can freeze your fast pace working environment into a container easily !
Apptainer is more the "public library" version of the software, while Singularity is more like a "corporate bookstore." Because Apptainer is hosted by the Linux Foundation, it is designed specifically for the scientific community to ensure that your research code remains free, accessible and without being tied to a private company’s profit goals.
Singularity is often found on high-performance computing (HPC) clusters and is maintained by Sylabs. Pixitainer supports both!
- FastDedup a PCR deduplication tool written in Rust optimized for speed and low memory usage.
- Install pixi
curl -fsSL https://pixi.sh/install.sh | shInstall pixitainer (Apptainer) or pixitainer-singularity (Singularity) globaly on pixi:
# For Apptainer
pixi global install -c https://prefix.dev/raphaelribes -c https://prefix.dev/conda-forge pixitainer
# For Singularity
pixi global install -c https://prefix.dev/raphaelribes -c https://prefix.dev/conda-forge pixitainer-singularity- Clone this repo
git clone https://github.com/RaphaelRibes/pixitainer.git
cd pixitainer- Build the pixitainer extension
pixi build- Install the pixitainer extension
# Apptainer
pixi global install pixitainer --path pixitainer-0.6.1*.conda --channel conda-forge
# Singularity
pixi global install pixitainer-singularity --path pixitainer-singularity-0.6.1*.conda --channel conda-forgeYou actually have two ways of using pixitainer:
- Manually
- Seamlessly
We put ourselves in an environment with one task defined like
[tasks]
make_dir = 'mkdir testdir'# For Apptainer
pixi containerize
# For Singularity
pixi containerize-singularityThen you can use pixi in your image
# Apptainer
apptainer run -f pixitainer.sif pixi run --as-is -m /opt/conf/pixi.toml make_dir
# Singularity
singularity run -f pixitainer.sif pixi run --as-is -m /opt/conf/pixi.toml make_dirWe add --as-is to make sure it sticks to the pixi.lock file, and it only uses the installed binaries and doesn't try to install others.
WARNING:
-m /opt/conf/pixi.tomlis mandatory or pixi will use the default one in your current working directory.
Use the pixitainer extension command after installing it with the seamless option (-s, --seamless).
# For Apptainer
pixi containerize -s
# For Singularity
pixi containerize-singularity -sYou can then turn your task like pixi is not even here
# Apptainer
apptainer run -f pixitainer.sif make_dir
# Singularity
singularity run -f pixitainer.sif make_dirWARNING: the seamless mode makes that every commands run through the image are ran like so
pixi run --as-is -m /opt/conf/pixi.toml "$@"Meaning that you only have access to
pixi run.
Since v0.6.0, you can configure pixitainer options directly in your project manifest (pixi.toml or pyproject.toml) using the [tool.pixitainer] table. This avoids passing long command-line arguments every time you build.
[tool.pixitainer]
output = "my_image.sif"
base-image = "ubuntu:24.04"
seamless = true
env = ["default"]
add-file = ["data/config.yaml:/opt/config.yaml"]
post-command = ["echo 'Setup done' > /opt/setup.log"]
label = ["APP_VERSION:1.0.0", "AUTHOR:me"]
keep-def = false
dry-run = false
quiet = false
verbose = falseNote: All keys mirror the long-form CLI option names (without the
--prefix). Boolean options usetrue/false, and array options (env,add-file,post-command,label) use TOML array syntax.
Command-line arguments always take precedence over values set in the [tool.pixitainer] table. This lets you define sensible defaults in your manifest while overriding them on a per-build basis:
# Uses TOML defaults, but overrides the output path
pixi containerize -o custom_output.sifWhen launching a command in the pixi shell, the cwd of tasks will be changed into the one of the pixi workplace (PIXI_PROJECT_ROOT).
Let's create a task
[tasks]
make_dir = 'mkdir testdir'If you run this task, it's going to create $PIXI_PROJECT_ROOT/testdir (/opt/conf/testdir) and not $INIT_CWD/testdir ($(pwd)/testdir).
What you want is to run pixi in the INIT_CWD so take the time to change your ./something to $INIT_CWD/something.
Note: The container now defaults to
/opt/confas the working directory (pwd -Preturns/opt/conf). This ensures compatibility with internal path resolutions, but you should rely on$INIT_CWDfor input/output relative to where you run the container. If you have files to import in the container (ex: your build) you can put it in/opt/confand it will allow normal execution. However, be conscious that your outputs will also be in/opt/confand not in your current working directory. Since you cannot write in a container, you will have to specify the outputs with$INIT_CWDand bind the folder where you want your outputs to be.
This is related to the previous problem: pixi is using PIXI_PROJECT_ROOT as the cwd.
It's going to try to write in /opt/conf wich is not allowed because the sif image is in read only.
To fix it, replace your mkdir test byt mkdir $INIT_CWD/test.
However, sometimes pixi may write something in its cache so don't hesitate to use --writable-tmpfs.
The best thing to do will be to add this way as a pixi extension, so we just have to type pixi containerize, some option and tada !
Note that pixitainer will install pixi with the same version that you have on your machine, you can change it with options look down below.
TODO:
- Receipe that works.
- Pixi package that I can add as an extension.
- Adding options to the extension.
- Core Options
- Output image path (
-o,--output) - Working directory (
-p,--path) - Enable seamless execution (
-s,--seamless)
- Output image path (
- Environment & Image Setup
- Specify base image (
-b,--base-image) - Specific environment selection (
-e,--env) - No installation of environment in the container (
-n,--no-install)
- Specify base image (
- Pixi Versioning
- Specify pixi version (
-V,--pixi-version) - Latest pixi version (
-L,--latest)
- Specify pixi version (
- Advanced Modifications
- Add extra files/folders (
-a,--add-file) - Run extra post commands (
-c,--post-command) - Add extra labels (
-l,--label) - Export the
.deffile (-k,--keep-def)
- Add extra files/folders (
- Output Options
- Dry-run (
-d,--dry-run)
- Dry-run (
- General Options
- Quiet mode (
-q,--quiet) - Verbose mode (
-v,--verbose)
- Quiet mode (
- Core Options
- Support the options in a
[tool.pixitainer]table in the manifest - Support of container solutions
- Apptainer
- Singularity
- Docker
Note that by default pixitainer is made with Apptainer in mind so it will be an option to install other container solutions.
- Testings.
- Publish
- Go back to step 3 until WW3, messiah or death of the internet
Pixitainer is licensed under the BSD 3-Clause License. See the LICENSE file for more details.