From 7b212f016f5bf4155b281bfcd93b61a21455b7d0 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 26 Apr 2024 22:28:22 -0700 Subject: [PATCH 1/5] rm dependency on devtools --- DESCRIPTION | 6 ++++-- NAMESPACE | 6 ------ R/DataPackageR-package.R | 2 +- R/build.R | 12 +++++------- R/dataversion.R | 4 ++-- R/processData.R | 10 +++++----- man/DataPackageR-package.Rd | 2 +- man/assert_data_version.Rd | 2 +- man/data_version.Rd | 2 +- tests/testthat/test-data-version.R | 4 ++-- tests/testthat/test-phantom_loading.R | 11 +++++------ tests/testthat/test-pkg_description.R | 4 ++-- 12 files changed, 29 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0453351..eb6661f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,13 +54,15 @@ Imports: yaml, purrr, roxygen2 (>= 6.0.1), - devtools (>= 1.12.0), stringr, futile.logger, rprojroot, usethis, crayon, - withr + withr, + pkgbuild, + pkgload, + sessioninfo VignetteBuilder: knitr RoxygenNote: 7.3.1 Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index 95d74d0..201a6ad 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,10 +30,6 @@ export(yml_write) importFrom(crayon,bold) importFrom(crayon,green) importFrom(desc,desc) -importFrom(devtools,build) -importFrom(devtools,build_vignettes) -importFrom(devtools,parse_deps) -importFrom(devtools,reload) importFrom(futile.logger,INFO) importFrom(futile.logger,TRACE) importFrom(futile.logger,appender.console) @@ -53,8 +49,6 @@ importFrom(knitr,spin) importFrom(purrr,map) importFrom(rmarkdown,pandoc_available) importFrom(rmarkdown,render) -importFrom(roxygen2,roxygenise) -importFrom(roxygen2,roxygenize) importFrom(rprojroot,is_r_package) importFrom(stringr,str_trim) importFrom(usethis,create_package) diff --git a/R/DataPackageR-package.R b/R/DataPackageR-package.R index c0fc649..4345095 100644 --- a/R/DataPackageR-package.R +++ b/R/DataPackageR-package.R @@ -62,7 +62,7 @@ #' package_build(file.path(tempdir(), pname), install = FALSE) #' #' # "install" the data package -#' devtools::load_all(file.path(tempdir(), pname)) +#' pkgload::load_all(file.path(tempdir(), pname)) #' #' # read the data version #' data_version(pname) diff --git a/R/build.R b/R/build.R index 5c026af..2f5b830 100644 --- a/R/build.R +++ b/R/build.R @@ -11,8 +11,6 @@ #' @param install \code{logical} automatically install and load the package after building. Default FALSE #' @param ... additional arguments passed to \code{install.packages} when \code{install=TRUE}. #' @returns Character vector. File path of the built package. -#' @importFrom roxygen2 roxygenise roxygenize -#' @importFrom devtools build_vignettes build parse_deps reload #' @importFrom usethis use_build_ignore use_rstudio proj_set use_directory #' @importFrom rprojroot is_r_package #' @importFrom rmarkdown pandoc_available @@ -97,15 +95,15 @@ package_build <- function(packageName = NULL, .multilog_trace("Building documentation") local({ on.exit({ - if (packageName %in% devtools::package_info('attached')$package){ - devtools::unload(packageName) + if (packageName %in% sessioninfo::package_info('attached')$package){ + pkgload::unload(packageName) } }) - roxygen2::roxygenise(package_path, clean = TRUE) + roxygen2::roxygenize(package_path, clean = TRUE) }) .multilog_trace("Building package") - location <- build(package_path, - path = dirname(package_path), + location <- pkgbuild::build(path = package_path, + dest_path = dirname(package_path), vignettes = vignettes, quiet = ! getOption('DataPackageR_verbose', TRUE) ) diff --git a/R/dataversion.R b/R/dataversion.R index 82d8ee0..94821a0 100644 --- a/R/dataversion.R +++ b/R/dataversion.R @@ -26,7 +26,7 @@ #' #' package_build(file.path(tempdir(),pname), install = FALSE) #' -#' devtools::load_all(file.path(tempdir(),pname)) +#' pkgload::load_all(file.path(tempdir(),pname)) #' data_version(pname) #' } data_version <- function(pkg, lib.loc = NULL) { @@ -98,7 +98,7 @@ data_version <- function(pkg, lib.loc = NULL) { #' code_files = f) #' package_build(file.path(tempdir(),pname), install = FALSE) #' -#' devtools::load_all(file.path(tempdir(),pname)) +#' pkgload::load_all(file.path(tempdir(),pname)) #' #' assert_data_version(data_package_name = pname,version_string = "0.1.0",acceptable = "equal") #' } diff --git a/R/processData.R b/R/processData.R index 6629597..04ecf53 100644 --- a/R/processData.R +++ b/R/processData.R @@ -769,14 +769,14 @@ document <- function(path = ".", install = FALSE, ...) { .multilog_trace("Rebuilding data package documentation.") local({ on.exit({ - if (basename(path) %in% devtools::package_info('attached')$package){ - devtools::unload(basename(path)) + if (basename(path) %in% sessioninfo::package_info('attached')$package){ + pkgload::unload(basename(path)) } }) - devtools::document(pkg = path) + roxygen2::roxygenize(package.dir = path) }) - location <- devtools::build( - pkg = path, path = dirname(path), + location <- pkgbuild::build( + path = path, dest_path = dirname(path), vignettes = FALSE, quiet = TRUE ) # try to install and then reload the package in the current session diff --git a/man/DataPackageR-package.Rd b/man/DataPackageR-package.Rd index d1abf63..c1660ee 100644 --- a/man/DataPackageR-package.Rd +++ b/man/DataPackageR-package.Rd @@ -70,7 +70,7 @@ datapackage_skeleton(name=pname, package_build(file.path(tempdir(), pname), install = FALSE) # "install" the data package -devtools::load_all(file.path(tempdir(), pname)) +pkgload::load_all(file.path(tempdir(), pname)) # read the data version data_version(pname) diff --git a/man/assert_data_version.Rd b/man/assert_data_version.Rd index 8eb520b..44f650e 100644 --- a/man/assert_data_version.Rd +++ b/man/assert_data_version.Rd @@ -46,7 +46,7 @@ datapackage_skeleton(name = pname, code_files = f) package_build(file.path(tempdir(),pname), install = FALSE) -devtools::load_all(file.path(tempdir(),pname)) +pkgload::load_all(file.path(tempdir(),pname)) assert_data_version(data_package_name = pname,version_string = "0.1.0",acceptable = "equal") } diff --git a/man/data_version.Rd b/man/data_version.Rd index 128b184..c62988b 100644 --- a/man/data_version.Rd +++ b/man/data_version.Rd @@ -33,7 +33,7 @@ datapackage_skeleton(name = pname, package_build(file.path(tempdir(),pname), install = FALSE) - devtools::load_all(file.path(tempdir(),pname)) + pkgload::load_all(file.path(tempdir(),pname)) data_version(pname) } } diff --git a/tests/testthat/test-data-version.R b/tests/testthat/test-data-version.R index 1addb81..df11875 100644 --- a/tests/testthat/test-data-version.R +++ b/tests/testthat/test-data-version.R @@ -25,8 +25,8 @@ test_that("assert_data_version", { code_files = f ) package_build(file.path(tempdir(), pname)) - on.exit(devtools::unload(pname)) - devtools::load_all(file.path(tempdir(), pname)) + on.exit(pkgload::unload(pname)) + pkgload::load_all(file.path(tempdir(), pname)) suppressWarnings(expect_true( data_version(pkg = pname) == numeric_version("0.1.0") )) diff --git a/tests/testthat/test-phantom_loading.R b/tests/testthat/test-phantom_loading.R index 4b2a17a..b2db821 100644 --- a/tests/testthat/test-phantom_loading.R +++ b/tests/testthat/test-phantom_loading.R @@ -7,8 +7,8 @@ testthat::test_that( ) pkg_name <- "mtcars20" on.exit( - if (pkg_name %in% devtools::package_info('attached')$package){ - devtools::unload(pkg_name) + if (pkg_name %in% sessioninfo::package_info('attached')$package){ + pkgload::unload(pkg_name) } ) # remove this directory on exit @@ -24,17 +24,16 @@ testthat::test_that( expect_no_warning(package_build(pkg_path, install = FALSE)) # test phantom pkg loading side effect from roxygen2::roxygenise() expect_false( - res1 <- pkg_name %in% devtools::package_info('attached')$package + res1 <- pkg_name %in% sessioninfo::package_info('attached')$package ) # reset for next test - if (res1) devtools::unload(pkg_name) + if (res1) pkgload::unload(pkg_name) # test phantom pkg loading side effect from roxygen2::roxygenise() - # which is called by devtools::document() expect_no_warning(document(pkg_path, install = FALSE)) expect_false( - res2 <- pkg_name %in% devtools::package_info('attached')$package + res2 <- pkg_name %in% sessioninfo::package_info('attached')$package ) } ) diff --git a/tests/testthat/test-pkg_description.R b/tests/testthat/test-pkg_description.R index ea8d3c5..4f1303a 100644 --- a/tests/testthat/test-pkg_description.R +++ b/tests/testthat/test-pkg_description.R @@ -15,8 +15,8 @@ test_that("can_read_pkg_description, data_version", { r_object_names = c("cars_over_20", "pressure") ) DataPackageR:::read_pkg_description(file.path(tempdir(), "subsetCars")) - on.exit(devtools::unload("subsetCars")) - devtools::load_all(file.path(tempdir(), "subsetCars")) + on.exit(pkgload::unload("subsetCars")) + pkgload::load_all(file.path(tempdir(), "subsetCars")) expected_version <- structure(list(c(0L, 1L, 0L)), class = c("package_version", "numeric_version") From 657d7294d7f6a801d10d208e8efda3fb7c2ad63f Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 26 Apr 2024 22:51:19 -0700 Subject: [PATCH 2/5] rm dependency on sessioninfo --- DESCRIPTION | 3 +-- R/build.R | 2 +- R/processData.R | 2 +- tests/testthat/test-phantom_loading.R | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index eb6661f..4f5cb35 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -61,8 +61,7 @@ Imports: crayon, withr, pkgbuild, - pkgload, - sessioninfo + pkgload VignetteBuilder: knitr RoxygenNote: 7.3.1 Encoding: UTF-8 diff --git a/R/build.R b/R/build.R index 2f5b830..3a47801 100644 --- a/R/build.R +++ b/R/build.R @@ -95,7 +95,7 @@ package_build <- function(packageName = NULL, .multilog_trace("Building documentation") local({ on.exit({ - if (packageName %in% sessioninfo::package_info('attached')$package){ + if (packageName %in% names(utils::sessionInfo()$otherPkgs)){ pkgload::unload(packageName) } }) diff --git a/R/processData.R b/R/processData.R index 04ecf53..ccc6835 100644 --- a/R/processData.R +++ b/R/processData.R @@ -769,7 +769,7 @@ document <- function(path = ".", install = FALSE, ...) { .multilog_trace("Rebuilding data package documentation.") local({ on.exit({ - if (basename(path) %in% sessioninfo::package_info('attached')$package){ + if (basename(path) %in% names(utils::sessionInfo()$otherPkgs)){ pkgload::unload(basename(path)) } }) diff --git a/tests/testthat/test-phantom_loading.R b/tests/testthat/test-phantom_loading.R index b2db821..f4762de 100644 --- a/tests/testthat/test-phantom_loading.R +++ b/tests/testthat/test-phantom_loading.R @@ -7,7 +7,7 @@ testthat::test_that( ) pkg_name <- "mtcars20" on.exit( - if (pkg_name %in% sessioninfo::package_info('attached')$package){ + if (pkg_name %in% names(utils::sessionInfo()$otherPkgs)){ pkgload::unload(pkg_name) } ) @@ -24,7 +24,7 @@ testthat::test_that( expect_no_warning(package_build(pkg_path, install = FALSE)) # test phantom pkg loading side effect from roxygen2::roxygenise() expect_false( - res1 <- pkg_name %in% sessioninfo::package_info('attached')$package + res1 <- pkg_name %in% names(utils::sessionInfo()$otherPkgs) ) # reset for next test @@ -33,7 +33,7 @@ testthat::test_that( # test phantom pkg loading side effect from roxygen2::roxygenise() expect_no_warning(document(pkg_path, install = FALSE)) expect_false( - res2 <- pkg_name %in% sessioninfo::package_info('attached')$package + res2 <- pkg_name %in% names(utils::sessionInfo()$otherPkgs) ) } ) From a2ba1ac501efac9b483a12961b1aec71ed372e85 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 26 Apr 2024 22:56:32 -0700 Subject: [PATCH 3/5] roxygen2 6.0.1 is very old now --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4f5cb35..2586db3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,7 +53,7 @@ Imports: desc, yaml, purrr, - roxygen2 (>= 6.0.1), + roxygen2, stringr, futile.logger, rprojroot, From 9b561906a718563ee68474f49bf772cada6bc67c Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 26 Apr 2024 23:12:21 -0700 Subject: [PATCH 4/5] withr from Imports to Suggests --- DESCRIPTION | 2 +- NAMESPACE | 1 - R/processData.R | 6 ++++-- R/skeleton.R | 4 +++- R/yamlR.R | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2586db3..f3e7e37 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -59,7 +59,6 @@ Imports: rprojroot, usethis, crayon, - withr, pkgbuild, pkgload VignetteBuilder: knitr @@ -70,6 +69,7 @@ Suggests: testthat, covr, data.tree, + withr URL: https://github.com/ropensci/DataPackageR/, https://docs.ropensci.org/DataPackageR/ diff --git a/NAMESPACE b/NAMESPACE index 201a6ad..d4f17a7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -58,7 +58,6 @@ importFrom(usethis,use_build_ignore) importFrom(usethis,use_data_raw) importFrom(usethis,use_directory) importFrom(usethis,use_rstudio) -importFrom(withr,with_options) importFrom(yaml,as.yaml) importFrom(yaml,read_yaml) importFrom(yaml,write_yaml) diff --git a/R/processData.R b/R/processData.R index ccc6835..1488742 100644 --- a/R/processData.R +++ b/R/processData.R @@ -32,7 +32,9 @@ #' @noRd DataPackageR <- function(arg = NULL, deps = TRUE) { if (! getOption('DataPackageR_verbose', TRUE)){ - withr::local_options(list(usethis.quiet = TRUE)) + old_usethis_quiet <- getOption('usethis.quiet') + on.exit(options(usethis.quiet = old_usethis_quiet)) + options(usethis.quiet = TRUE) } pkg_dir <- arg if (getOption('DataPackageR_verbose', TRUE)) cat("\n") @@ -40,7 +42,7 @@ DataPackageR <- function(arg = NULL, deps = TRUE) { #set the option that DataPackageR is building the package. On exit ensures when it leaves, it will set it back to false options("DataPackageR_packagebuilding" = TRUE) - on.exit(options("DataPackageR_packagebuilding" = FALSE)) + on.exit(options("DataPackageR_packagebuilding" = FALSE), add = TRUE) # validate that render_root exists. # if it's an old temp dir, what then? diff --git a/R/skeleton.R b/R/skeleton.R index 11fab03..c7dbfd6 100644 --- a/R/skeleton.R +++ b/R/skeleton.R @@ -53,7 +53,9 @@ datapackage_skeleton <- raw_data_dir = character(), dependencies = character()) { if (! getOption('DataPackageR_verbose', TRUE)){ - withr::local_options(list(usethis.quiet = TRUE)) + old_usethis_quiet <- getOption('usethis.quiet') + on.exit(options(usethis.quiet = old_usethis_quiet)) + options(usethis.quiet = TRUE) } if (is.null(name)) { stop("Must supply a package name", call. = FALSE) diff --git a/R/yamlR.R b/R/yamlR.R index 9570eb7..06640f5 100644 --- a/R/yamlR.R +++ b/R/yamlR.R @@ -6,7 +6,6 @@ #' @description Edit a yaml configuration file via an API. #' @details Add, remove files and objects, enable or disable parsing of specific files, list objects or files in a yaml config, or write a config back to a package. #' @importFrom yaml yaml.load_file as.yaml write_yaml -#' @importFrom withr with_options #' @export #' #' @examples From 8a73c02d6e7e1f5826209fed4a1686193859daeb Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 26 Apr 2024 23:32:33 -0700 Subject: [PATCH 5/5] url tweaks --- DESCRIPTION | 4 ++-- man/DataPackageR-package.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f3e7e37..4480cc1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -71,8 +71,8 @@ Suggests: data.tree, withr URL: - https://github.com/ropensci/DataPackageR/, + https://github.com/ropensci/DataPackageR, https://docs.ropensci.org/DataPackageR/ BugReports: https://github.com/ropensci/DataPackageR/issues -SystemRequirements: pandoc (>= 1.12.3) - http://pandoc.org +SystemRequirements: pandoc (>= 1.12.3) - https://pandoc.org Language: en-US diff --git a/man/DataPackageR-package.Rd b/man/DataPackageR-package.Rd index c1660ee..a369fc6 100644 --- a/man/DataPackageR-package.Rd +++ b/man/DataPackageR-package.Rd @@ -91,7 +91,7 @@ readLines(list.files(pattern="R", path = file.path(tempdir(),pname,"R"), full = \seealso{ Useful links: \itemize{ - \item \url{https://github.com/ropensci/DataPackageR/} + \item \url{https://github.com/ropensci/DataPackageR} \item \url{https://docs.ropensci.org/DataPackageR/} \item Report bugs at \url{https://github.com/ropensci/DataPackageR/issues} }