This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new d2ccd6e feat(r/sedonadb): Use the "bootstrap.R" mechanism to copy
necessary Rust source codes (#146)
d2ccd6e is described below
commit d2ccd6e4563ee3f8b1486a2232dd37225b587a8a
Author: Hiroaki Yutani <[email protected]>
AuthorDate: Thu Sep 25 03:43:58 2025 +0900
feat(r/sedonadb): Use the "bootstrap.R" mechanism to copy necessary Rust
source codes (#146)
---
r/sedonadb/.Rbuildignore | 1 +
r/sedonadb/DESCRIPTION | 3 ++-
r/sedonadb/README.Rmd | 6 ++----
r/sedonadb/README.md | 6 ++----
r/sedonadb/bootstrap.R | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 59 insertions(+), 9 deletions(-)
diff --git a/r/sedonadb/.Rbuildignore b/r/sedonadb/.Rbuildignore
index 7e7df63..d18da40 100644
--- a/r/sedonadb/.Rbuildignore
+++ b/r/sedonadb/.Rbuildignore
@@ -10,3 +10,4 @@
^compile_commands\.json$
^\.vscode$
^README\.Rmd$
+^bootstrap\.R$
diff --git a/r/sedonadb/DESCRIPTION b/r/sedonadb/DESCRIPTION
index cd9d95e..6f20973 100644
--- a/r/sedonadb/DESCRIPTION
+++ b/r/sedonadb/DESCRIPTION
@@ -17,7 +17,8 @@ Suggests:
testthat (>= 3.0.0),
withr,
wk
-Config/testthat/edition: 3
Imports:
geoarrow,
nanoarrow
+Config/testthat/edition: 3
+Config/build/bootstrap: TRUE
diff --git a/r/sedonadb/README.Rmd b/r/sedonadb/README.Rmd
index 5b9a784..bf18f8b 100644
--- a/r/sedonadb/README.Rmd
+++ b/r/sedonadb/README.Rmd
@@ -42,10 +42,8 @@ The goal of sedonadb is to provide an R interface to [Apache
SedonaDB](https://s
You can install the development version of sedonadb from
[GitHub](https://github.com/) with:
-``` shell
-git clone https://github.com/apache/sedona-db.git
-cd sedona-db/r/sedonadb
-R CMD INSTALL .
+``` r
+pak::pkg_install("apache/sedona-db/r/sedonadb")
```
Installing a development version of sedonadb requires a [Rust
compiler](https://rustup.rs) and a GEOS system dependency (e.g., `brew install
geos` or `apt-get install libgeos-dev`). Install instructions for these
dependencies on other platforms can be found on the [sf package
homepage](https://r-spatial.github.io/sf).
diff --git a/r/sedonadb/README.md b/r/sedonadb/README.md
index 20bc812..6f8dd82 100644
--- a/r/sedonadb/README.md
+++ b/r/sedonadb/README.md
@@ -33,10 +33,8 @@ SQL with high function coverage and GeoParquet IO.
You can install the development version of sedonadb from
[GitHub](https://github.com/) with:
-``` shell
-git clone https://github.com/apache/sedona-db.git
-cd sedona-db/r/sedonadb
-R CMD INSTALL .
+``` r
+pak::pkg_install("apache/sedona-db/r/sedonadb")
```
Installing a development version of sedonadb requires a [Rust
diff --git a/r/sedonadb/bootstrap.R b/r/sedonadb/bootstrap.R
new file mode 100644
index 0000000..e51c0d9
--- /dev/null
+++ b/r/sedonadb/bootstrap.R
@@ -0,0 +1,52 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# R builds a package by copying only the sources under the directory of the R
+# package, which means it cannot refer to the Rust files above the directory.
+# So, this R script copies the necessary Rust crates under the R package dir.
+# Note that, this is not a standard mechanism of R, but is only invoked by
+# pkgbuild (cf. https://github.com/r-lib/pkgbuild/pull/157)
+
+# Tweak Cargo.toml
+cargo_toml <- "src/rust/Cargo.toml"
+lines <- readLines(cargo_toml)
+writeLines(
+ gsub("../../../../", "../", lines, fixed = TRUE),
+ cargo_toml
+)
+
+dir.create("src/dep_crates/")
+file.copy(
+ c(
+ "../../rust",
+ "../../c",
+ "../../Cargo.toml",
+ "../../Cargo.lock"
+ ),
+ "src/",
+ recursive = TRUE
+)
+
+# Tweak workspace Cargo.toml
+top_cargo_toml <- "src/Cargo.toml"
+lines <- readLines(top_cargo_toml)
+# change the path to the R package's Rust code
+lines <- gsub("r/sedonadb/src/rust", "rust", lines, fixed = TRUE)
+# remove unnecessary workspace members
+lines <- gsub('"python/sedonadb",', "", lines, fixed = TRUE)
+lines <- gsub('"sedona-cli",', "", lines, fixed = TRUE)
+writeLines(lines, top_cargo_toml)