# Description: R-package torch # URL: https://cran.r-project.org/web/packages/torch # Maintainer: Petar Petrov, slackalaxy at gmail dot com # Depends on: r r4-bit64 r4-callr r4-cli r4-coro r4-desc r4-glue r4-jsonlite r4-magrittr r4-r6 r4-rcpp r4-rlang r4-safetensors r4-scales r4-withr # Optional: r4-covr r4-katex r4-knitr r4-mvtnorm r4-numderiv r4-palmerpenguins r4-rmarkdown r4-testthat name=r4-torch version=0.17.0 release=2 source=(https://cloud.r-project.org/src/contrib/torch_${version}.tar.gz https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.8.0+cpu.zip https://torch-cdn.mlverse.org/binaries/refs/heads/cran/v${version}/latest/lantern-$version+cpu+x86_64-Linux.zip) build() { cd torch mkdir -p $PKG/usr/lib/R/library R CMD INSTALL . -l $PKG/usr/lib/R/library # The code below will automatically fetch and install libtorch and lantern at build time. # Bake libtorch + lantern into the package itself at build time, # so end users never hit the runtime download/permission issue. #export TORCH_HOME=$PKG/usr/lib/R/library/torch #Rscript -e '.libPaths(c("'"$PKG"'/usr/lib/R/library", .libPaths())); torch::install_torch()' # We do it manually: cp -a $SRC/libtorch/* $PKG/usr/lib/R/library/torch/ cp -a $SRC/lantern-$version+cpu+x86_64-Linux/* $PKG/usr/lib/R/library/torch/ }