This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new fc04931 Make rand an optional dependency (#674)
fc04931 is described below
commit fc0493198194265eed16fa5d41d6d70760756363
Author: Roee Shlomo <[email protected]>
AuthorDate: Mon Aug 9 14:31:07 2021 +0300
Make rand an optional dependency (#674)
Closes #671
Signed-off-by: roee88 <[email protected]>
---
.github/workflows/rust.yml | 4 +++-
arrow/Cargo.toml | 13 ++++++-------
arrow/README.md | 6 ++++--
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 5579072..d76192c 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -327,12 +327,14 @@ jobs:
rustup override set ${{ matrix.rust }}
rustup component add rustfmt
rustup target add wasm32-unknown-unknown
+ rustup target add wasm32-wasi
- name: Build arrow crate
run: |
export CARGO_HOME="/github/home/.cargo"
export CARGO_TARGET_DIR="/github/home/target"
cd arrow
- cargo build --features=js --target wasm32-unknown-unknown
+ cargo build --no-default-features --features=csv,ipc,simd --target
wasm32-unknown-unknown
+ cargo build --no-default-features --features=csv,ipc,simd --target
wasm32-wasi
# test builds with various feature flags
default-build:
diff --git a/arrow/Cargo.toml b/arrow/Cargo.toml
index f5a3e24..0c8ca76 100644
--- a/arrow/Cargo.toml
+++ b/arrow/Cargo.toml
@@ -40,10 +40,7 @@ serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
indexmap = "1.6"
-rand = { version = "0.8", default-features = false }
-# getrandom is a dependency of rand, not (directly) of arrow
-# need to specify `js` feature to build on wasm
-getrandom = { version = "0.2", optional = true }
+rand = { version = "0.8", optional = true }
num = "0.4"
csv_crate = { version = "1.1", optional = true, package="csv" }
regex = "1.3"
@@ -64,16 +61,18 @@ csv = ["csv_crate"]
ipc = ["flatbuffers"]
simd = ["packed_simd"]
prettyprint = ["prettytable-rs"]
-js = ["getrandom/js"]
# The test utils feature enables code used in benchmarks and tests but
-# not the core arrow code itself
-test_utils = ["rand/std", "rand/std_rng"]
+# not the core arrow code itself. Be aware that `rand` must be kept as
+# an optional dependency for supporting compile to wasm32-unknown-unknown
+# target without assuming an environment containing JavaScript.
+test_utils = ["rand"]
# this is only intended to be used in single-threaded programs: it verifies
that
# all allocated memory is being released (no memory leaks).
# See README for details
memory-check = []
[dev-dependencies]
+rand = "0.8"
criterion = "0.3"
flate2 = "1"
tempfile = "3"
diff --git a/arrow/README.md b/arrow/README.md
index c5fdb11..298a5cf 100644
--- a/arrow/README.md
+++ b/arrow/README.md
@@ -59,11 +59,13 @@ println!("{:?}", array.value(1));
## Building for WASM
-In order to compile Arrow for Web Assembly (the `wasm32-unknown-unknown` WASM
target), you will likely need to turn off this crate's default features and use
the `js` feature.
+Arrow can compile to WebAssembly using the `wasm32-unknown-unknown` and
`wasm32-wasi` targets.
+
+In order to compile Arrow for `wasm32-unknown-unknown` you will need to
disable default features, then include the desired features, but exclude test
dependencies (the `test_utils` feature). For example, use this snippet in your
`Cargo.toml`:
```toml
[dependencies]
-arrow = { version = "5.0", default-features = false, features = ["js"] }
+arrow = { version = "5.0", default-features = false, features = ["csv", "ipc",
"simd"] }
```
## Examples