Difference between revisions of "R package guidelines"

From ArchWiki
Jump to: navigation, search
(Remove extra space)
(simplification and beautification of wikilinks (interactive))
(Tag: wiki-scripts)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Package development]]
 
[[Category:Package development]]
 +
[[ja:R パッケージガイドライン]]
 +
[[pt:R package guidelines]]
 
{{Package guidelines}}
 
{{Package guidelines}}
 
This document covers standards and guidelines on writing [[PKGBUILD]]s for [[R]] packages.
 
This document covers standards and guidelines on writing [[PKGBUILD]]s for [[R]] packages.
Line 20: Line 22:
  
 
== Dependencies ==
 
== Dependencies ==
R packages listed in {{ic|Depends}}, {{ic|Imports}}, or the {{ic|LinkingTo}} fields in a package's {{ic|DESCRIPTION}} file should be listed under depends.
+
R packages listed in {{ic|Depends}}, {{ic|Imports}}, or the {{ic|LinkingTo}} fields in a package's {{ic|DESCRIPTION}} file should be listed under [[PKGBUILD#depends|depends]].
  
R packages listed in {{ic|Suggests}} should be listed as optdepends.
+
R packages listed in {{ic|Suggests}} should be listed as [[optdepends]].
  
 
Some packages require external tools, these are listed under {{ic|SystemRequirements}}.
 
Some packages require external tools, these are listed under {{ic|SystemRequirements}}.
  
{{Pkg|gcc-fortran}} is needed as a makedepends for some packages but is not always listed in the {{ic|DESCRIPTION}} file.
+
{{Pkg|gcc-fortran}} is needed as a [[PKGBUILD#makedepends|makedepends]] for some packages but is not always listed in the {{ic|DESCRIPTION}} file.
  
 
== Source ==
 
== Source ==
All R packages available on CRAN are available at the website {{ic|https://cran.r-project.org/src/contrib/cranname_cranversion.tar.gz}} where cranname is the name of the package on CRAN and cranversion the cran version.
+
All R packages available on CRAN are available at the website {{ic|<nowiki>https://cran.r-project.org/src/contrib/</nowiki>''cranname''_''cranversion''.tar.gz}} where ''cranname'' is the name of the package on CRAN and ''cranversion'' the cran version.
  
 
== Build and Package ==
 
== Build and Package ==
Line 38: Line 40:
 
   }
 
   }
 
   package() {
 
   package() {
       install -d "$pkgdir"/usr/lib/R/library
+
       install -dm0775 "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership pkgname "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership pkgname "$pkgdir"/usr/lib/R/library
 
   }
 
   }
Line 61: Line 63:
 
   }
 
   }
 
   package() {
 
   package() {
       install -d "$pkgdir"/usr/lib/R/library
+
       install -dm0755 "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership RcppEigen "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership RcppEigen "$pkgdir"/usr/lib/R/library
 
   }
 
   }
Line 86: Line 88:
 
   }
 
   }
 
   package() {
 
   package() {
       install -d "$pkgdir"/usr/lib/R/library
+
       install -dm0755 "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership XML "$pkgdir"/usr/lib/R/library
 
       cp -a --no-preserve=ownership XML "$pkgdir"/usr/lib/R/library
 
   }
 
   }

Latest revision as of 16:52, 19 August 2018

Package creation guidelines

CLRCrossEclipseFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyVCSWebWine

This document covers standards and guidelines on writing PKGBUILDs for R packages. Most information can be obtained by looking at the package's DESCRIPTION file. You can get most of this from inside R by running tools::CRAN_package_db().

Package naming

Packages should be named r-pkgname, where pkgname is taken from the Package field from the DESCRIPTION file. The package name should be lowercase.

Package Version

Take it from the Version field. R allows packages to have colons and hyphens in their version, this is disallowed in PKGBUILDs. Convert these to a period or underscore.

Arch

See PKGBUILD#arch. If the package's CRAN webpage has NeedsCompilation: yes it is likely architecture-specific. Otherwise, it is likely not.

Dependencies

R packages listed in Depends, Imports, or the LinkingTo fields in a package's DESCRIPTION file should be listed under depends.

R packages listed in Suggests should be listed as optdepends.

Some packages require external tools, these are listed under SystemRequirements.

gcc-fortran is needed as a makedepends for some packages but is not always listed in the DESCRIPTION file.

Source

All R packages available on CRAN are available at the website https://cran.r-project.org/src/contrib/cranname_cranversion.tar.gz where cranname is the name of the package on CRAN and cranversion the cran version.

Build and Package

R has built-in support for building packages, we just need to install and copy over the built package afterwards:

 build(){
     R CMD INSTALL pkg.tar.gz -l "$srcdir"
 }
 package() {
     install -dm0775 "$pkgdir"/usr/lib/R/library
     cp -a --no-preserve=ownership pkgname "$pkgdir"/usr/lib/R/library
 }

Examples

RcppEigen

 pkgname=r-rcppeigen
 pkgver=0.3.3.4.0
 pkgrel=1
 pkgdesc="Rcpp Integration for the Eigen Templated Linear Algebra Library"
 arch=('x86_64')
 url="https://cran.r-project.org/package=RcppEigen"
 license=('GPL')
 depends=('r' 'r-rcpp')
 optdepends=('r-inline' 'r-runit' 'r-pkgkitten')
 source=("https://cran.r-project.org/src/contrib/RcppEigen_$pkgver.tar.gz")
 md5sums=('78ee1ef7c6043efa875434ae5fcea2ec')
 
 build(){
     R CMD INSTALL RcppEigen_"$pkgver".tar.gz -l "$srcdir"
 }
 package() {
     install -dm0755 "$pkgdir"/usr/lib/R/library
     cp -a --no-preserve=ownership RcppEigen "$pkgdir"/usr/lib/R/library
 }

XML

An example where the R package has characters not allowed in pkgver:

 _cranver=3.98-1.11
 pkgname=r-xml
 pkgver=${_cranver//[:-]/.}
 pkgrel=1
 pkgdesc='Tools for Parsing and Generating XML Within R and S-Plus'
 arch=('x86_64')
 url='https://cran.r-project.org/package=XML'
 license=('BSD')
 depends=('r' 'libxml2')
 optdepends=('r-bitops' 'r-rcurl')
 replaces=('r-cran-xml')
 source=("https://cran.r-project.org/src/contrib/XML_$_cranver.tar.gz")
 md5sums=('6c67f5730ada3456372520773a920b8e')
 
 build(){
     R CMD INSTALL XML_"$_cranver".tar.gz -l "$srcdir"
 }
 package() {
     install -dm0755 "$pkgdir"/usr/lib/R/library
     cp -a --no-preserve=ownership XML "$pkgdir"/usr/lib/R/library
 }