Skip to content

r-laminr on conda-forge #184

@ap--

Description

@ap--

Hello everyone 👋

If laminr would be available on conda-forge (or some other conda-channel) it would simplify shipping working lamin conda-environments bundling R and Python dependencies via pixi.

I played around with this and managed to install a complete working conda env (with jupyter and lamindb and laminr) from (basically) one pixi.toml file (and ship the entire env as a relocatable packaged conda env). It seems that pixi-pack might get s3 support: Quantco/pixi-pack#91 which would then enable deploying fully working conda-envs (with cross OS support) with python or python&R by providing a single s3 uri to pixi-pack.

This is currently very crude and verbose, but here's an example POC:

[project]
channels = ["conda-forge", "bioconda"]
name = "jupyter-lamin"
platforms = ["linux-64"]

[tasks]
start = "jupyter lab"

[dependencies]
# python deps (should move as many upstream deps here)
#   (lamindb is not available on conda, but also doesn't have to)
python = "3.12.*"
ipython = "*"
ipywidgets = "*"
jupyterlab = "*"
scipy = "<1.15.0"
urllib3 = "<2"
zarr = "<3"
universal_pathlib = "==0.2.6"
fsspec = ">2024.10.0,<=2025.2.0"
pip = "*"
# R dependencies all from conda
r-base = ">=4.4.0"
r-irkernel = ">=1"
r-cli = "*"
r-purrr = "*"
"r-r.utils" = "*"
r-r6 = "*"
r-reticulate = "*"
r-rlang = "*"
r-withr = "*"
r-anndata = "*"  # not avialable on osx64 for R>=4.4
r-arrow = "*"
r-jsonlite = "*"
r-knitr = "*"
r-nanoparquet = "*"
r-quarto = "*"
r-readr = "*"
r-rstudioapi = "*"
r-rsvg = "*"
r-seurat = "*"
r-testthat = "*"
r-yaml = "*"

[pypi-dependencies]
lamindb = { version = ">=1.3", extras = ["bionty", "gcp", "jupyter", "wetlab", "zarr"] }

[activation]
scripts = [".pixi_support/fix_reticulate.sh", ".pixi_support/ensure_laminr.sh"]

[activation.env]
PIXI_R_LIBS = "$CONDA_PREFIX/lib/R/library"
R_LIBS = "$PIXI_R_LIBS"
R_LIBS_USER = "$PIXI_R_LIBS"
RETICULATE_PYTHON= "$CONDA_PREFIX/bin/python"  # needed to point reticulate to the conda python

In this example there are currently two support scripts that work around issues with this.

  1. .pixi_support/fix_reticulate.sh is due to Support for pixi environments? rstudio/reticulate#1650 and basically applies the conda history fix suggested in this issue
  2. .pixi_support/ensure_laminr.sh just checks if laminr is installed in the R enviroment and installs it if not (because you can't afaik have cran dependencies in conda environment.ymls)
#!/bin/bash
# .pixi_support/ensure_laminr.sh

# pixi install does not support postrun hooks, which is what we'd need.
# that or a r-laminr conda-forge package

$CONDA_PREFIX/bin/Rscript -e "library(laminr)" > /dev/null && exit_status=$? || exit_status=$? ; true

if [ $exit_status -ne 0 ]; then
        echo "INSTALLING LAMINR"
        $CONDA_PREFIX/bin/Rscript -e 'install.packages("laminr", dependencies=TRUE, repos="http://cran.us.r-project.org")'
else
        echo "laminr is installed"
fi
#!/bin/bash
# .pixi_support/fix_reticulate.sh

echo -e "# cmd: $CONDA_PREFIX/bin/conda" > $CONDA_PREFIX/conda-meta/history

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions