How to include R dependency in a python package

31 views Asked by At

I have a python project, that has an R dependency. The R package is available through Biocunductor. It can be installed with the following code

import rpy2.robjects as robjects
import rpy2.robjects.packages as rpackages


utils = rpackages.importr("utils")
if not rpackages.isinstalled("BiocManager"):
    utils.install_packages("BiocManager")
robjects.r('BiocManager::install(pkgs="IsoCorrectoR", ask=FALSE)')

My project is set up with a pyproject.toml file, and a pip install works fine, but the R dependency is not installed.

With the pyproject.toml I see no place to execute the above code snippet. Executing it on runtime would be a possibility, but feels inelegant.

0

There are 0 answers