diff --git a/r/sedonadb/.Rbuildignore b/r/sedonadb/.Rbuildignore index 7e7df631..d18da406 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 51673914..f550038b 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 5b9a784d..bf18f8b5 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 20bc812e..6f8dd822 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 00000000..e51c0d92 --- /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)