Skip to content

Commit d2ccd6e

Browse files
feat(r/sedonadb): Use the "bootstrap.R" mechanism to copy necessary Rust source codes (#146)
1 parent 2138362 commit d2ccd6e

File tree

5 files changed

+59
-9
lines changed

5 files changed

+59
-9
lines changed

r/sedonadb/.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
^compile_commands\.json$
1111
^\.vscode$
1212
^README\.Rmd$
13+
^bootstrap\.R$

r/sedonadb/DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Suggests:
1717
testthat (>= 3.0.0),
1818
withr,
1919
wk
20-
Config/testthat/edition: 3
2120
Imports:
2221
geoarrow,
2322
nanoarrow
23+
Config/testthat/edition: 3
24+
Config/build/bootstrap: TRUE

r/sedonadb/README.Rmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ The goal of sedonadb is to provide an R interface to [Apache SedonaDB](https://s
4242

4343
You can install the development version of sedonadb from [GitHub](https://github.com/) with:
4444

45-
``` shell
46-
git clone https://github.com/apache/sedona-db.git
47-
cd sedona-db/r/sedonadb
48-
R CMD INSTALL .
45+
``` r
46+
pak::pkg_install("apache/sedona-db/r/sedonadb")
4947
```
5048

5149
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).

r/sedonadb/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ SQL with high function coverage and GeoParquet IO.
3333
You can install the development version of sedonadb from
3434
[GitHub](https://github.com/) with:
3535

36-
``` shell
37-
git clone https://github.com/apache/sedona-db.git
38-
cd sedona-db/r/sedonadb
39-
R CMD INSTALL .
36+
``` r
37+
pak::pkg_install("apache/sedona-db/r/sedonadb")
4038
```
4139

4240
Installing a development version of sedonadb requires a [Rust

r/sedonadb/bootstrap.R

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# R builds a package by copying only the sources under the directory of the R
19+
# package, which means it cannot refer to the Rust files above the directory.
20+
# So, this R script copies the necessary Rust crates under the R package dir.
21+
# Note that, this is not a standard mechanism of R, but is only invoked by
22+
# pkgbuild (cf. https://github.com/r-lib/pkgbuild/pull/157)
23+
24+
# Tweak Cargo.toml
25+
cargo_toml <- "src/rust/Cargo.toml"
26+
lines <- readLines(cargo_toml)
27+
writeLines(
28+
gsub("../../../../", "../", lines, fixed = TRUE),
29+
cargo_toml
30+
)
31+
32+
dir.create("src/dep_crates/")
33+
file.copy(
34+
c(
35+
"../../rust",
36+
"../../c",
37+
"../../Cargo.toml",
38+
"../../Cargo.lock"
39+
),
40+
"src/",
41+
recursive = TRUE
42+
)
43+
44+
# Tweak workspace Cargo.toml
45+
top_cargo_toml <- "src/Cargo.toml"
46+
lines <- readLines(top_cargo_toml)
47+
# change the path to the R package's Rust code
48+
lines <- gsub("r/sedonadb/src/rust", "rust", lines, fixed = TRUE)
49+
# remove unnecessary workspace members
50+
lines <- gsub('"python/sedonadb",', "", lines, fixed = TRUE)
51+
lines <- gsub('"sedona-cli",', "", lines, fixed = TRUE)
52+
writeLines(lines, top_cargo_toml)

0 commit comments

Comments
 (0)