Skip to content

Commit

Permalink
rgeedim v0.2.2
Browse files Browse the repository at this point in the history
 - update gd_install() to optionally use system() instead of reticulate.
  • Loading branch information
brownag committed Mar 29, 2023
1 parent b8dd7ea commit 5c49272
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# rgeedim 0.2.2

* Added `gd_install()` for installation of 'numpy', 'earthengine-api', and 'geedim' Python modules via `reticulate::py_install()`
* Added `gd_install()` for installation of 'numpy', 'earthengine-api', and 'geedim' Python modules via `reticulate::py_install()` or a `system()` call

* `gd_bbox()` will now calculate a bounding box extent from one or more {terra} `SpatRaster`, `SpatRasterCollection`, `SpatVector`, `SpatVectorProxy` input (in addition to existing support for `SpatExtent`)

* Note that `gd_region()` allows for more complex boundary input via `SpatVector` or Well-Known Text (WKT) string

* Improved coercion interface for non-terra objects
* Improved coercion interface for non-{terra} objects

* The following inputs are now converted to terra equivalents (or their extents) as needed: WKT string (OGC:CRS84), Spatial* (sp), Raster* & Extent (raster), sf* and bbox (sf). SpatExtent-like objects (Extent, bbox) are assumed to be in OGC:CRS84.
* The following inputs are now converted to {terra} equivalents (or their extents) as needed: WKT string, Spatial* ({sp} package), Raster* & Extent ({raster} package), sf* and bbox ({sf} package). WKT strings and `SpatExtent`-like objects (`Extent`, `bbox`) are assumed to be in the `"OGC:CRS84"` coordinate reference system.

# rgeedim 0.2.1

Expand Down
9 changes: 9 additions & 0 deletions R/AAAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,12 @@ gd_ee_version <- function() {
gev
)
}

.find_python <- function() {
# find python
py_path <- Sys.which("python")
if (nchar(py_path) == 0) {
py_path <- Sys.which("python3")
}
py_path
}
32 changes: 29 additions & 3 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#' that are passed to `reticulate::py_install()`.
#'
#' @param pip Use `pip` package manager? Default: `TRUE`
#' @param system Use a `system()` call to `python -m pip install ...` instead of `reticulate::py_install()`. Default: `FALSE`.
#' @param force Force update (uninstall/reinstall) and ignore existing installed packages? Default: `TRUE`. Applies only to `pip=TRUE`.
#' @param ... Additional arguments passed to `reticulate::py_install()`
#' @return `NULL`, or `try-error` (invisibly) on R code execution error.
#' @export
Expand All @@ -16,14 +18,38 @@
#' # install with pip
#' gd_install()
#'
#' # install with pip
#'
#' # use virtual environment with default name "r-reticulate"
#' gd_install(pip = FALSE, method = "virtualenv")
#'
#' # use "conda" environment named "foo"
#' gd_install(pip = FALSE, method = "conda", envname = "foo")
#'
#' }
gd_install <- function(pip = TRUE, ...) {
invisible(try(reticulate::py_install(c("numpy", "earthengine-api", "geedim"),
pip = pip, pip_ignore_installed = TRUE, ...), silent = FALSE))
gd_install <- function(pip = TRUE, system = FALSE, force = TRUE, ...) {

# alternately, just use a system() call to python -m pip install ...
if (system && pip) {
fp <- .find_python()
if (nchar(fp) > 0) {
return(invisible(system(
paste(
shQuote(fp),
"-m pip install",
ifelse(force, "-U --force", ""),
"geedim earthengine-api numpy"
)
)))
}
}

invisible(try(reticulate::py_install(
c("numpy", "earthengine-api", "geedim"),
pip = pip,
pip_ignore_installed = force,
...
),
silent = FALSE)
)
}
8 changes: 7 additions & 1 deletion man/gd_install.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c49272

Please sign in to comment.