Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
"" \
"or dispatch the Build GDAL (Windows) workflow with \`gdal_version=${upstream_tag}\`." \
"" \
"After publishing, rebuild gdalraster against the new bundle and verify with \`gdalraster.windows::verify_gdalraster_runtime()\`, then update the README latest-release line and the default \`gdal_version\` in build.yml.")"
"After publishing, rebuild gdalraster against the new bundle and verify with \`gdalraster.windows::gdal_verify()\`, then update the README latest-release line and the default \`gdal_version\` in build.yml.")"

# ─────────────────────────────────────────────────────────────────────────────
# JOB 1 — Build GDAL from source
Expand Down Expand Up @@ -525,7 +525,6 @@ jobs:
```r
pak::pak("${{ github.repository }}")
gdalraster.windows::gdal_setup(
user_lib = TRUE,
tag = "${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || steps.names.outputs.release_tag }}"
)
library(gdalraster)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
tag <- Sys.getenv("RUNTIME_TAG", unset = "latest")
if (!nzchar(tag)) tag <- "latest"
gdalraster.windows::gdal_setup(
user_lib = TRUE,
tag = tag,
verify = TRUE
)
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/edge-cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
tag <- Sys.getenv("RUNTIME_TAG", unset = "latest")
scenario <- Sys.getenv("SCENARIO")
gdalraster.windows::gdal_setup(
user_lib = scenario != "foreign-gdalraster",
isolated = scenario == "foreign-gdalraster",
tag = tag,
verify = scenario != "foreign-gdalraster"
)
Expand Down Expand Up @@ -104,7 +104,6 @@ jobs:
path.expand("~/.Rprofile")
)
state <- gdalraster.windows::gdal_sitrep(
user_lib = TRUE,
network = FALSE,
quiet = TRUE
)
Expand Down Expand Up @@ -150,6 +149,7 @@ jobs:

if (scenario == "foreign-gdalraster") {
state <- gdalraster.windows::gdal_sitrep(
isolated = TRUE,
network = FALSE,
quiet = TRUE
)
Expand All @@ -168,7 +168,6 @@ jobs:
)
stopifnot(is.null(result))
stopifnot(gdalraster.windows::gdal_verify(
user_lib = TRUE,
python = FALSE,
quiet = TRUE
))
Expand Down
12 changes: 7 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ Primary user flow:

```r
pak::pak("jimbrig/gdalraster.windows")
gdalraster.windows::gdal_setup(user_lib = TRUE)
gdalraster.windows::gdal_setup()

# every later session
library(gdalraster)
gdalraster::gdal_global_reg_names()
```

The non-destructive setup default uses an isolated package-managed library.
Users opt into replacement in `.libPaths()[1]` with `user_lib = TRUE`.
Setup, sitrep, verify, and update default to `.libPaths()[1]`. Pass `lib`
for a custom library, or `isolated = TRUE` for the package-managed isolated
library under `tools::R_user_dir("gdalraster.windows", "data")/library`.

## required system behavior

Expand All @@ -39,7 +40,7 @@ Users opt into replacement in `.libPaths()[1]` with `user_lib = TRUE`.
persist or export `PYTHONPATH`.
8. Verify in fresh processes that the Algorithm API, required drivers, first
Parquet open, CRS support, and GeoPackage validator work.
9. Keep installs non-destructive by default.
9. Default installs target the user library; isolated installs are opt-in.

## responsibility split

Expand Down Expand Up @@ -74,7 +75,8 @@ There is no runtime activation API, auto-bootstrap, `.Rprofile` hook,
- Use `rlang::caller_env()` and `rlang::caller_arg()` in validators.
- Use `withr` for scoped state.
- Stage complete package replacements before changing an installed package.
- Preserve the isolated library as the default build destination.
- Default `gdalraster` installs to `.libPaths()[1]`; isolated library
installs are opt-in via `isolated = TRUE`.
- Never add Parquet initialization or session-order workarounds; Arrow/TLS
correctness belongs to the bundle build.

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gdalraster.windows
Title: Self-Contained gdalraster Builds for Windows
Version: 0.4.0
Version: 0.5.0
Authors@R:
person("Jimmy", "Briggs", , "jimmy.briggs@jimbrig.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7489-8787"))
Expand Down
34 changes: 32 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# gdalraster.windows 0.5.0

## Breaking changes

- Porcelain functions (`gdal_setup()`, `gdal_sitrep()`, `gdal_verify()`,
`gdal_update()`, `gdal_uninstall()`, `gdal_build_gdalraster()`, and
`gdal_enable_python()`) now default to `.libPaths()[1]`, the library used
by `library(gdalraster)`. Pass `lib` for a custom library, or
`isolated = TRUE` for the package-managed isolated library. `user_lib`
remains accepted as a deprecated alias (`user_lib = FALSE` is equivalent
to `isolated = TRUE`).

## Sitrep and runtime selection

- `gdal_home()` and the default data/library paths are slash-normalized.
- Latest runtime selection uses the newest published `gdal-v*` GDAL bundle,
not R package tags such as `v0.3.1` that still carry a leftover zip.
- `gdal_sitrep()` reports the installed `gdalraster` package version on the
gdalraster line, not the GDAL runtime tag. It prints the inspected
`gdal_home` and library paths, reports missing build provenance instead of
`NA`, and no longer warns about other `libgdal` DLLs merely present on
`PATH`.

## Migration from 0.4.0

- Bare `gdal_setup()` / `gdal_sitrep()` now target `.libPaths()[1]`. Isolated
leftovers under `tools::R_user_dir("gdalraster.windows", "data")/library`
are unused unless you pass `isolated = TRUE`. Remove them with
`gdal_uninstall(isolated = TRUE, runtime = FALSE, python = FALSE)`.

# gdalraster.windows 0.4.0

## Breaking redesign
Expand Down Expand Up @@ -54,8 +84,8 @@
removed activation helpers.
2. Remove persistent GDAL-related `PATH`, `GDAL_DATA`, `PROJ_DATA`, `PROJ_LIB`,
and `PYTHONPATH` workarounds.
3. Run `gdal_setup(user_lib = TRUE)` once for plain
`library(gdalraster)` discovery, or omit `user_lib` for an isolated install.
3. Run `gdal_setup()` once for plain `library(gdalraster)` discovery, or
`gdal_setup(isolated = TRUE)` for an isolated install.

# gdalraster.windows 0.3.1

Expand Down
6 changes: 5 additions & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# ------------------------------------------------------------------------
#
# Title : Shared Package Resources
Expand Down Expand Up @@ -26,6 +25,11 @@
#' @keywords internal
.bundle_asset_pattern <- "gdal-(bundle|ucrt64)-.*\\.zip$"

#' Regex selecting GDAL runtime bundle release tags
#' @noRd
#' @keywords internal
.bundle_tag_pattern <- "^gdal-v"

# stale runtime naming -------------------------------------------------------

#' Suffix marking sibling directories that hold moved-aside runtime files
Expand Down
43 changes: 29 additions & 14 deletions R/gdal_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#' installed package, then records build provenance.
#'
#' @param gdal_home Installed GDAL build runtime.
#' @param lib Destination library. The default is an isolated package-managed
#' library.
#' @param user_lib Install into `.libPaths()[1]`. This is destructive when an
#' existing `gdalraster` is installed there and requires `force = TRUE` in
#' non-interactive sessions.
#' @param lib Destination library. Defaults to `.libPaths()[1]`.
#' @param isolated Install into the package-managed isolated library instead of
#' `.libPaths()[1]`. Ignored when `lib` is set.
#' @param user_lib Deprecated. `user_lib = TRUE` is now the default;
#' `user_lib = FALSE` is equivalent to `isolated = TRUE`.
#' @param source_tarball Optional local `gdalraster` source tarball.
#' @param repo Upstream source repository.
#' @param ref Git reference used for the source archive.
Expand All @@ -24,7 +24,8 @@
gdal_build_gdalraster <- function(
gdal_home = default_gdal_home(),
lib = NULL,
user_lib = FALSE,
isolated = FALSE,
user_lib = NULL,
source_tarball = NULL,
repo = .gdalraster_repo,
ref = "HEAD",
Expand All @@ -35,7 +36,8 @@ gdal_build_gdalraster <- function(
) {
abort_if_not_windows()
abort_if_no_build_tools()
check_flag(user_lib)
check_flag(isolated)
check_optional_flag(user_lib)
check_flag(upgrade)
check_flag(force)
check_flag(enable_python)
Expand All @@ -57,7 +59,7 @@ gdal_build_gdalraster <- function(
)
}

lib <- resolve_gdalraster_lib(lib = lib, user_lib = user_lib)
lib <- resolve_gdalraster_lib(lib = lib, isolated = isolated, user_lib = user_lib)
package_dir <- file.path(lib, "gdalraster")
if ("gdalraster" %in% loadedNamespaces()) {
cli::cli_abort(
Expand Down Expand Up @@ -106,8 +108,12 @@ gdal_build_gdalraster <- function(
makevars <- c(
GDAL_HOME = gdal_home,
PKG_CPPFLAGS = paste0("-I\"", file.path(gdal_home, "include"), "\""),
# --allow-multiple-definition is a linker workaround for symbol overlap
# between the bundle import library and residual Rtools GDAL archives on
# the search path. see #3. do not treat this as a permanent contract.
PKG_LIBS = paste0(
"-L\"", file.path(gdal_home, "lib"),
"-L\"",
file.path(gdal_home, "lib"),
"\" -lgdal -Wl,--allow-multiple-definition"
)
)
Expand Down Expand Up @@ -180,12 +186,21 @@ gdal_build_gdalraster <- function(

#' @keywords internal
#' @noRd
resolve_gdalraster_lib <- function(lib = NULL, user_lib = FALSE) {
if (isTRUE(user_lib)) {
return(normalizePath(.libPaths()[[1L]], winslash = "/", mustWork = FALSE))
resolve_gdalraster_lib <- function(
lib = NULL,
isolated = FALSE,
user_lib = NULL
) {
if (!is.null(user_lib)) {
isolated <- !isTRUE(user_lib)
}
if (!is.null(lib)) {
return(normalize_pkg_path(lib))
}
if (isTRUE(isolated)) {
return(default_gdalraster_lib())
}
lib <- if (is.null(lib)) default_gdalraster_lib() else lib
normalizePath(lib, winslash = "/", mustWork = FALSE)
normalize_pkg_path(.libPaths()[[1L]])
}

#' @keywords internal
Expand Down
14 changes: 12 additions & 2 deletions R/gdal_python.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#' does not affect isolated virtual environments.
#'
#' @param lib Library containing the self-contained `gdalraster` package.
#' Defaults to `.libPaths()[1]`.
#' @param isolated Use the package-managed isolated library instead of
#' `.libPaths()[1]`. Ignored when `lib` is set.
#' @param user_lib Deprecated. `user_lib = TRUE` is now the default;
#' `user_lib = FALSE` is equivalent to `isolated = TRUE`.
#' @param python Optional path to the CPython executable GDAL embeds.
#' @param site_packages Optional explicit `site-packages` directory.
#' @param quiet Suppress status messages.
Expand All @@ -14,17 +19,22 @@
#' located.
#' @export
gdal_enable_python <- function(
lib = default_gdalraster_lib(),
lib = NULL,
isolated = FALSE,
user_lib = NULL,
python = NULL,
site_packages = NULL,
quiet = FALSE
) {
abort_if_not_windows()
check_string(lib)
check_flag(isolated)
check_optional_flag(user_lib)
check_optional_string(python)
check_optional_string(site_packages)
check_flag(quiet)

lib <- resolve_gdalraster_lib(lib, isolated = isolated, user_lib = user_lib)

package_python <- file.path(
normalizePath(lib, winslash = "/", mustWork = FALSE),
"gdalraster",
Expand Down
9 changes: 6 additions & 3 deletions R/gdal_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Resolution order is the `gdalraster.windows.gdal_home` option, the
#' `GDALRASTER_WINDOWS_GDAL_HOME` environment variable, then the package-managed
#' user data directory.
#' user data directory. The returned path is normalized to forward slashes.
#'
#' @return A single path.
#' @export
Expand Down Expand Up @@ -95,8 +95,11 @@ gdal_install_runtime <- function(
) {
cli::cli_alert_warning(
paste0(
"GDAL runtime ", manifest_value(installed, "Bundle-Tag", "unknown"),
" is installed; ", asset$tag, " is available. Run gdal_update() to upgrade."
"GDAL runtime ",
manifest_value(installed, "Bundle-Tag", "unknown"),
" is installed; ",
asset$tag,
" is available. Run gdal_update() to upgrade."
)
)
return(invisible(gdal_home))
Expand Down
Loading