Skip to content

Commit

Permalink
Suppress/handle any reticulate errors on load
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Feb 4, 2023
1 parent 1366faf commit e5cb014
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rgeedim
Type: Package
Title: Search, Composite, and Download 'Google Earth Engine' Imagery with the 'Python' Module 'geedim'
Version: 0.2.0
Version: 0.2.1
Authors@R: c(person("Andrew", "Brown", role = c("aut", "cre"), email = "[email protected]"),
person("Dugal", "Harris", role = "cph", comment = "'geedim' 'Python' module"))
Maintainer: Andrew Brown <[email protected]>
Expand All @@ -21,7 +21,7 @@ Config/reticulate:
License: Apache License (>= 2)
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
Imports: utils, methods, reticulate, jsonlite
Suggests: terra, raster, tinytest, knitr, rmarkdown
Depends: R (>= 3.5)
Expand Down
10 changes: 6 additions & 4 deletions R/AAAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ gd_ee_version <- function() {
# get reticulate python information
# NB: reticulate::py_config() calls configure_environment() etc.
# .:. use py_discover_config()
x <- reticulate::py_discover_config()
x <- try(reticulate::py_discover_config(), silent = TRUE)

# need python 3 for reticulate
# need python 3.6+ for geedim
if (length(x) > 0) {
if (length(x) > 0 && !inherits(x, 'try-error')) {
if (numeric_version(x$version) >= "3.6") {
return(TRUE)
} else if (numeric_version(x$version) >= "3.0") {
Expand All @@ -82,8 +82,10 @@ gd_ee_version <- function() {
.onLoad <- function(libname, pkgname) {
if (.has_python3()) {
if (!.loadModules()) {
reticulate::configure_environment(pkgname)
.loadModules()
x <- try(reticulate::configure_environment(pkgname), silent = TRUE)
if (!inherits(x, 'try-error')) {
.loadModules()
}
}
}
}
Expand Down

0 comments on commit e5cb014

Please sign in to comment.