diff --git a/.Rbuildignore b/.Rbuildignore index cb782c7..d162f1e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,5 @@ main.R build.R project_files ^\.covrignore$ +.idea +Makefile \ No newline at end of file diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..81b960f --- /dev/null +++ b/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/.circleci/config.yml b/.circleci/config.yml index a9d5cbd..5748cbf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,12 @@ jobs: - r-pkg-cache-{{ arch }}-{{ .Branch }} - r-pkg-cache-{{ arch }}- - checkout + - run: + name: Update pip + command: | + apt-get install python3 + apt-get install python3-pip + pip install --upgrade pip - run: name: Install package dependencies command: | diff --git a/.gitignore b/.gitignore index 9fb05bf..7399b3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .Renviron .Rproj.user +.idea +.env diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c5ec7bf --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +.PHONY: all style document generate check r_env clean + +all: style document build + +style: + @echo 'Styling R Directory' + R -e "styler::style_dir('R')" + +document: + @echo "Documenting Package" + rm -rf man | echo 'man does not exist' + rm NAMESPACE | echo 'NAMESPACE does not exist' + R -e "devtools::document()" + R -e "devtools::build_manual(path='project_files')" + +build: + @echo "Building Package..." + R -e "devtools::build()" + R -e "devtools::install()" + +check: + @echo "Checking Packages" + R -e "devtools::check()" + R -e "covr::package_coverage()" + R -e "covr::report()" + +r_env: + @echo "Setting Up Environment..." + pip install --upgrade pip + @rm -rf renv | echo 'deleting renv if exists' + @rm -rf .Rprofile | echo 'deleting .Rprofile if exists' + R -e "install.packages('renv')" + R -e "renv::consent(provided=TRUE)" + R -e "renv::init()" + R -e "renv::restore()" + R -e "renv::use_python(type='virtualenv')" + R -e "reticulate::virtualenv_install(packages = 'boto3')" + R -e "reticulate::import('boto3')" + +clean: + @echo "Removing unnecessary files" + rm *.zip | echo "No ZIP Files" + rm *.csv | echo "No CSV Files" + rm *.xlsx | echo "No XLSX Files" + rm *.txt | echo "No TXT files" + rm *.pdf | echo "No PDF files" diff --git a/R/client.R b/R/client.R index 58e8eb3..0f3a346 100644 --- a/R/client.R +++ b/R/client.R @@ -38,7 +38,7 @@ boto3 <- function() { client <- function(service = NULL, key_access = NULL, key_secret = NULL, region = NULL) { client <- boto3()$client - client <- client$client( + client( service, aws_access_key_id = key_access, aws_secret_access_key = key_secret, diff --git a/project_files/biggr2_0.1.1.pdf b/project_files/biggr2_0.1.1.pdf new file mode 100644 index 0000000..8f0b546 Binary files /dev/null and b/project_files/biggr2_0.1.1.pdf differ diff --git a/renv.lock b/renv.lock new file mode 100644 index 0000000..d144621 --- /dev/null +++ b/renv.lock @@ -0,0 +1,689 @@ +{ + "R": { + "Version": "4.0.3", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://cloud.r-project.org" + } + ] + }, + "Packages": { + "BH": { + "Package": "BH", + "Version": "1.72.0-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8f9ce74c6417d61f0782cbae5fd2b7b0" + }, + "DT": { + "Package": "DT", + "Version": "0.16", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "acac794cc3e393ca65f916e5ced5c1d2" + }, + "Matrix": { + "Package": "Matrix", + "Version": "1.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "08588806cba69f04797dab50627428ed" + }, + "R.cache": { + "Package": "R.cache", + "Version": "0.14.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1ca02d43e1a4d49e616bd23bb39b17e6" + }, + "R.methodsS3": { + "Package": "R.methodsS3", + "Version": "1.8.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4bf6453323755202d5909697b6f7c109" + }, + "R.oo": { + "Package": "R.oo", + "Version": "1.24.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5709328352717e2f0a9c012be8a97554" + }, + "R.utils": { + "Package": "R.utils", + "Version": "2.10.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a9e316277ff12a43997266f2f6567780" + }, + "R6": { + "Package": "R6", + "Version": "2.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b203113193e70978a696b2809525649d" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "125dc7a0ed375eb68c0ce533b48d291f" + }, + "askpass": { + "Package": "askpass", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e8a22846fff485f0be3770c2da758713" + }, + "assertthat": { + "Package": "assertthat", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "50c838a310445e954bc13f26f26a6ecf" + }, + "backports": { + "Package": "backports", + "Version": "1.1.10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "05ffd2d4acb51aee70f1de68ad7a6aed" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, + "brew": { + "Package": "brew", + "Version": "1.0-6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "92a5f887f9ae3035ac7afde22ba73ee9" + }, + "callr": { + "Package": "callr", + "Version": "3.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b7d7f1e926dfcd57c74ce93f5c048e80" + }, + "cli": { + "Package": "cli", + "Version": "2.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0b316487b21d21f99ebf98abe179b1ea" + }, + "clipr": { + "Package": "clipr", + "Version": "0.7.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaa97ac99cc2daf04e77eecc7b781d7" + }, + "commonmark": { + "Package": "commonmark", + "Version": "1.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0f22be39ec1d141fd03683c06f3a6e67" + }, + "conflicted": { + "Package": "conflicted", + "Version": "1.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "43c5107cc96f47043a56736768ecc59d" + }, + "covr": { + "Package": "covr", + "Version": "3.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6d80a9fc3c0c8473153b54fa54719dfd" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f9df472593124299aef98fba2c96dfd3" + }, + "crayon": { + "Package": "crayon", + "Version": "1.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0d57bc8e27b7ba9e45dba825ebc0de6b" + }, + "crosstalk": { + "Package": "crosstalk", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ae55f5d7c02f0ab43c58dd050694f2b4" + }, + "curl": { + "Package": "curl", + "Version": "4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2b7d10581cc730804e9ed178c8374bd6" + }, + "desc": { + "Package": "desc", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6c8fe8fa26a23b79949375d372c7b395" + }, + "devtools": { + "Package": "devtools", + "Version": "2.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "415656f50722f5b6e6bcf80855ce11b9" + }, + "digest": { + "Package": "digest", + "Version": "0.6.27", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a0cbe758a531d054b537d16dff4d58a1" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d0509913b27ea898189ee664b6030dc2" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fd2844b3a43ae2d27e70ece2df1b4e2a" + }, + "evaluate": { + "Package": "evaluate", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" + }, + "fansi": { + "Package": "fansi", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7fce217eaaf8016e72065e85c73027b5" + }, + "fs": { + "Package": "fs", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "44594a07a42e5f91fac9f93fda6d0109" + }, + "generics": { + "Package": "generics", + "Version": "0.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b8cff1d1391fd1ad8b65877f4c7f2e53" + }, + "gh": { + "Package": "gh", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "89ea5998938d1ad55f035c8a86f96b74" + }, + "git2r": { + "Package": "git2r", + "Version": "0.27.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "531a82d1beed1f545beb25f4f5945bf7" + }, + "glue": { + "Package": "glue", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6efd734b14c6471cfe443345f3e35e29" + }, + "highr": { + "Package": "highr", + "Version": "0.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + }, + "hms": { + "Package": "hms", + "Version": "0.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "726671f634529d470545f9fd1a9d1869" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7d651b7131794fe007b1ad6f21aaa401" + }, + "htmlwidgets": { + "Package": "htmlwidgets", + "Version": "1.5.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0aaf56b7960bb066646e1868cadcaf07" + }, + "httr": { + "Package": "httr", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a525aba14184fec243f9eaec62fbed43" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6154ec2223172bce8162d4153cda21f7" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.7.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1ec84e070b88b37ed169f19def40d47c" + }, + "knitr": { + "Package": "knitr", + "Version": "1.30", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "eed7ee0d02eee88d53881cdc92457c62" + }, + "later": { + "Package": "later", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d0a62b247165aabf397fded504660d8a" + }, + "lattice": { + "Package": "lattice", + "Version": "0.20-41", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd9285028b0263d76d18c95ae51a53d" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d908914ae53b04d4c0c0fd72ecc35370" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "0.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "361811f31f71f8a617a9a68bf63f1f42" + }, + "lubridate": { + "Package": "lubridate", + "Version": "1.7.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fc1c91e2e8d9e1fc932e75aa1ed989b7" + }, + "magrittr": { + "Package": "magrittr", + "Version": "1.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1bb58822a20301cee84a41678e25d9b7" + }, + "markdown": { + "Package": "markdown", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "61e4a10781dd00d7d81dd06ca9b94e95" + }, + "memoise": { + "Package": "memoise", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "58baa74e4603fcfb9a94401c58c8f9b1" + }, + "mime": { + "Package": "mime", + "Version": "0.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e87a35ec73b157552814869f45a63aa3" + }, + "openssl": { + "Package": "openssl", + "Version": "1.4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a399e4773075fc2375b71f45fca186c4" + }, + "pillar": { + "Package": "pillar", + "Version": "1.4.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "bdf26e55ccb7df3e49a490150277f002" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "404684bc4e3685007f9720adf13b06c1" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a555924add98c99d2f411e37e7d25e9f" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" + }, + "processx": { + "Package": "processx", + "Version": "3.4.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "03446ed0b8129916f73676726cb3c48f" + }, + "promises": { + "Package": "promises", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a8730dcbdd19f9047774909f0ec214a4" + }, + "ps": { + "Package": "ps", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f5d7d94cc097aa9dade988e3e6715067" + }, + "purrr": { + "Package": "purrr", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "97def703420c8ab10d8f0e6c72101e02" + }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8c8298583adbbe76f3c2220eef71bebc" + }, + "rcmdcheck": { + "Package": "rcmdcheck", + "Version": "1.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ed95895886dab6d2a584da45503555da" + }, + "readr": { + "Package": "readr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2639976851f71f330264a9c9c3d43a61" + }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "remotes": { + "Package": "remotes", + "Version": "2.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "430a0908aee75b1fcba0e62857cab0ce" + }, + "renv": { + "Package": "renv", + "Version": "0.12.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7340c71f46a0fd16506cfa804e224e44" + }, + "reticulate": { + "Package": "reticulate", + "Version": "1.18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd35cac6ae7554d0e4f440bca1adf3a" + }, + "rex": { + "Package": "rex", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "093584b944440c5cd07a696b3c8e0e4c" + }, + "rlang": { + "Package": "rlang", + "Version": "0.4.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "843a6af51414bce7f8a8e372f11d6cd0" + }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "20a0a94af9e8f7040510447763aab3e9" + }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fcd94e00cc409b25d07ca50f7bf339f5" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "1.3-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f6a407ae5dd21f6f80a6708bbb6eb3ae" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.11", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "33a5b27a03da82ac4b1d43268f80088a" + }, + "rversions": { + "Package": "rversions", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0ec41191f744d0f5afad8c6f35cc36e4" + }, + "sessioninfo": { + "Package": "sessioninfo", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "308013098befe37484df72c39cf90d6e" + }, + "stringi": { + "Package": "stringi", + "Version": "1.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a063ebea753c92910a4cca7b18bc1f05" + }, + "stringr": { + "Package": "stringr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0759e6b6c0957edb1311028a49a35e76" + }, + "styler": { + "Package": "styler", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "60b23effde8d08a56a64ebeb92a32749" + }, + "sys": { + "Package": "sys", + "Version": "3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b227d13e29222b4574486cfcbde077fa" + }, + "testthat": { + "Package": "testthat", + "Version": "2.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0829b987b8961fb07f3b1b64a2fbc495" + }, + "tibble": { + "Package": "tibble", + "Version": "3.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "71dffd8544691c520dd8e41ed2d7e070" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6ea435c354e8448819627cf686f66e0a" + }, + "tinytex": { + "Package": "tinytex", + "Version": "0.26", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "db6477efcfbffcd9b3758c3c2882cf58" + }, + "usethis": { + "Package": "usethis", + "Version": "1.6.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c541a7aed5f7fb3b487406bf92842e34" + }, + "utf8": { + "Package": "utf8", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0bc90078aeee42f2520b1d0a33bd6758" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ca970b96d894e90397ed20637a0c1bbe" + }, + "withr": { + "Package": "withr", + "Version": "2.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7307d79f58d1885b38c4f4f1a8cb19dd" + }, + "xfun": { + "Package": "xfun", + "Version": "0.18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d1c0b777b432e4b4c039c8aaecc54e0f" + }, + "xml2": { + "Package": "xml2", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d4d71a75dd3ea9eb5fa28cc21f9585e2" + }, + "xopen": { + "Package": "xopen", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6c85f015dee9cc7710ddd20f86881f58" + }, + "yaml": { + "Package": "yaml", + "Version": "2.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2826c5d9efb0a88f657c7a679c7106db" + } + }, + "Python": { + "Version": "3.8.3", + "Type": "virtualenv" + } +} diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000..82740ba --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,3 @@ +library/ +python/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000..ff7e655 --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,349 @@ + +local({ + + # the requested version of renv + version <- "0.12.0" + + # the project directory + project <- getwd() + + # avoid recursion + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) + return(invisible(TRUE)) + + # signal that we're loading renv during R startup + Sys.setenv("RENV_R_INITIALIZING" = "true") + on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) + return(invisible(TRUE)) + + # otherwise, unload and attempt to load the correct version of renv + unloadNamespace("renv") + + } + + # load bootstrap tools + bootstrap <- function(version, library) { + + # read repos (respecting override if set) + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (is.na(repos)) + repos <- getOption("repos") + + # fix up repos + on.exit(options(repos = repos), add = TRUE) + repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" + options(repos = repos) + + # attempt to download renv + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) + + # now attempt to install + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + download.file( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + } + + renv_bootstrap_download <- function(version) { + + methods <- list( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive, + renv_bootstrap_download_github + ) + + for (method in methods) { + path <- tryCatch(method(version), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("failed to download renv ", version) + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + # check for renv on CRAN matching this version + db <- as.data.frame(available.packages(), stringsAsFactors = FALSE) + + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) { + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + } + + message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE) + + info <- tryCatch( + download.packages("renv", destdir = tempdir()), + condition = identity + ) + + if (inherits(info, "condition")) { + message("FAILED") + return(FALSE) + } + + message("OK") + info[1, 2] + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- getOption("repos") + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) { + message("OK") + return(destfile) + } + + } + + message("FAILED") + return(FALSE) + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) { + message("FAILED") + return(FALSE) + } + + message("Done!") + return(destfile) + + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + r <- file.path(bin, exe) + args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status + + } + + renv_bootstrap_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- Sys.getenv("RENV_PATHS_PREFIX") + if (nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_library_root <- function(project) { + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(path) + + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(path)) + return(file.path(path, basename(project))) + + file.path(project, "renv/library") + + } + + renv_bootstrap_validate_version <- function(version) { + + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) + return(TRUE) + + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") + + fmt <- paste( + "renv %1$s was loaded from project library, but renv %2$s is recorded in lockfile.", + "Use `renv::record(\"%3$s\")` to record this version in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) + + FALSE + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # load the project + renv::load(project) + + TRUE + + } + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # attempt to load + if (renv_bootstrap_load(project, libpath, version)) + return(TRUE) + + # load failed; attempt to bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("Successfully installed and loaded renv ", version, ".") + return(renv::load()) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + +}) diff --git a/renv/settings.dcf b/renv/settings.dcf new file mode 100644 index 0000000..11a53ea --- /dev/null +++ b/renv/settings.dcf @@ -0,0 +1,6 @@ +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +snapshot.type: implicit +use.cache: TRUE +vcs.ignore.library: TRUE diff --git a/tests/testthat/test-client.R b/tests/testthat/test-client.R index 7d1da82..f1dec29 100644 --- a/tests/testthat/test-client.R +++ b/tests/testthat/test-client.R @@ -1,11 +1,7 @@ - -# AWS_ACCESS = system('echo $AWS_ACCESS') -# AWS_SECRET = system('echo $AWS_SECRET') -# AWS_REGION = system('echo $AWS_REGION') - -test_that("boto3 imports as expected", { +testthat::test_that("boto3 imports as expected", { testthat::expect_equal( class(biggr2::boto3()), c("python.builtin.module", "python.builtin.object") ) }) +