{"id":18758122,"url":"https://github.com/ankargren/package_notes","last_synced_at":"2025-12-01T23:30:15.792Z","repository":{"id":93923739,"uuid":"166093410","full_name":"ankargren/package_notes","owner":"ankargren","description":"Template for RcppArmadillo-dependent packages","archived":false,"fork":false,"pushed_at":"2019-01-21T19:25:22.000Z","size":93,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T03:24:24.338Z","etag":null,"topics":["package","r","rcpp","rcpparmadillo","template"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankargren.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-16T18:54:17.000Z","updated_at":"2024-03-06T23:19:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"91e73632-6cf3-47d2-bd77-17d4529b5c5d","html_url":"https://github.com/ankargren/package_notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankargren%2Fpackage_notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankargren%2Fpackage_notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankargren%2Fpackage_notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankargren%2Fpackage_notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankargren","download_url":"https://codeload.github.com/ankargren/package_notes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239650672,"owners_count":19674789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["package","r","rcpp","rcpparmadillo","template"],"created_at":"2024-11-07T17:45:27.513Z","updated_at":"2025-12-01T23:30:15.730Z","avatar_url":"https://github.com/ankargren.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Package notes\n\nSome things I tend to forget when creating a fresh package with RcppArmadillo, header files and Travis CI and codecov enabled. \n\n## Installation\n\nTo create a package called `my_pkg`:\n```\ndevtools::install_github(\"ankargren/package_notes\")\nskeleton::arma_package_template(name = \"my_pkg\", \n                                path = \"~/Desktop\")\n```\nNext, go to `Tools -\u003e Project options -\u003e Build tools` and add `--clean` to the `Build and Reload` field. (This enables a run of the `cleanup` file after the package has been installed, which removes unnecessary auxiliary files.)\n\n## Documentation\n\nThe files that the template package uses can be found in the `inst` folder here on GitHub. They are also documented below (with slight modifications).\n\n### .Rbuildignore\n\n```\n^.*\\.Rproj$\n^\\.Rproj\\.user$\n^README.rmd$\n^README_cache$\n^codecov.yml$\n^README.md$\n^cran-comments.md$\n^man-roxygen$\n^\\.travis.yml$\n^config.yml$\n^docs$\n^README_files$\n```\n\n### configure file\n\nChange `PKG_NAME` and `PKG_VERSION` in the following `configure.ac`:\n```\n## Rbuildignore\n\n## configure.ac\n\n## -*- mode: autoconf; autoconf-indentation: 4; -*-\n##\n##  Copyright (C) 2016 - 2017  Dirk Eddelbuettel for\n##  the RcppArmadillo package. Licensed under GPL-2 or later\n##  This file is a subset of the configure.ac used by\n##  RcppArmadillo.\n\n## require at least autoconf 2.61\nAC_PREREQ(2.61)\n\n## Process this file with autoconf to produce a configure script.\nAC_INIT([PKG_NAME], PKG_VERSION)\n\n## Set R_HOME, respecting an environment variable if one is set\n: ${R_HOME=$(R RHOME)}\nif test -z \"${R_HOME}\"; then\n\tAC_MSG_ERROR([Could not determine R_HOME.])\nfi\n## Use R to set CXX and CXXFLAGS\nCXX=$(${R_HOME}/bin/R CMD config CXX)\nCXXFLAGS=$(\"${R_HOME}/bin/R\" CMD config CXXFLAGS)\n\n## We are using C++\nAC_LANG(C++)\nAC_REQUIRE_CPP\n\n## Default the OpenMP flag to the empty string.\n## If and only if OpenMP is found, expand to $(SHLIB_OPENMP_CXXFLAGS)\nopenmp_flag=\"\"\nopenmp_cflag=\"\"\n\n## Check for broken systems produced by a corporation based in Cupertino\nAC_MSG_CHECKING([for macOS])\nRSysinfoName=$(\"${R_HOME}/bin/Rscript\" --vanilla -e 'cat(Sys.info()[[\"sysname\"]])')\nif test x\"${RSysinfoName}\" == x\"Darwin\"; then\n   AC_MSG_RESULT([found])\n   AC_MSG_WARN([OpenMP unavailable and turned off.])\n   openmp_flag=\"-DARMA_DONT_USE_OPENMP\"\nelse\n   AC_MSG_RESULT([not found as on ${RSysinfoName}])\n   ## Check for OpenMP\n   AC_MSG_CHECKING([for OpenMP])\n   ## if R has -fopenmp we should be good\n   allldflags=$(${R_HOME}/bin/R CMD config --ldflags)\n   hasOpenMP=$(echo ${allldflags} | grep -- -fopenmp)\n   if test x\"${hasOpenMP}\" == x\"\"; then\n\t  AC_MSG_RESULT([missing])\n\t  openmp_flag=\"-DARMA_DONT_USE_OPENMP\"\n   else\n\t  AC_MSG_RESULT([found])\n\t  openmp_flag='$(SHLIB_OPENMP_CXXFLAGS)'\n\t  openmp_cflag='$(SHLIB_OPENMP_CFLAGS)'\n   fi\nfi\n\nAC_SUBST([OPENMP_CFLAG], [\"${openmp_cflag}\"])\nAC_SUBST([OPENMP_FLAG], [\"${openmp_flag}\"])\nAC_CONFIG_FILES([src/Makevars])\nAC_OUTPUT\n```\n\nThen run `autoconf` in the folder where `configure.ac` is saved. Copy the `configure` file to the package root. If it doesn't show up as an executable, run `chmod +x ~/path/to/file`.\n\n### Makevars.in\n\nThe `Makevars.in` file that goes with the `configure` script is:\n```\nCXX_STD = CXX11\nPKG_CXXFLAGS = @OPENMP_FLAG@ -I../inst/include\nPKG_LIBS = @OPENMP_FLAG@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)\n```\n(Note: Having `@OPENMP_CFLAG@` in `PKG_LIBS` is frowned upon by CRAN, C and C++ flags should not be mixed.)\n\n### Makevars\n\n```\nCXX_STD = CXX11\nPKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) -I../inst/include\nPKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)\n```\n\n### cleanup file\n\nFor most cases, the following is enough:\n```\n#!/bin/sh\n\nrm -f config.* src/Makevars\n```\n\n### Travis CI\n\nA basic `.travis.yml` file:\n```\n# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r\n\nlanguage: R\nsudo: false\ncache: packages\nos:\n  - linux\n  - osx\nr:\n  - oldrel\n  - release\n  - devel\n\nr_check_args: --as-cran\n\nmatrix:\n  exclude:\n    - os: osx\n      r: devel\n\nbranches:\n  only:\n  - master\n\nr_github_packages:\n  - jimhester/covr\nr_binary_packages:\n  - Rcpp\n  - RcppArmadillo\n  - testthat\n  - roxygen2\n  - devtools\n\nafter_success:\n  - tar -C .. -xf $PKG_TARBALL\n- Rscript -e 'covr::codecov()'\n```\n\n### codecov\n\nGo to the codecov site, turn the repo on, get the token. Add the `codecov.yml` file:\n\n```\ncomment: false\n\ncoverage:\n  status:\n    project:\n      default:\n        target: auto\n        threshold: 1%\n    patch:\n      default:\n        target: auto\n        threshold: 1%\n\nlanguage: R\nsudo: false\ncache: packages\nafter_success:\n- Rscript -e 'covr::codecov()'\n```\n\nGo to R and run:\n```\ninstall.packages(\"covr\")\nlibrary(covr)\ncodecov(token = \"YOUR_TOKEN_GOES_HERE\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankargren%2Fpackage_notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankargren%2Fpackage_notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankargren%2Fpackage_notes/lists"}