-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make rand an optional dependency #674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
# 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" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can accommodate it when there's demand |
||
|
||
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"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't clearly articulate what's happening, compared to what's being changed. How about: "In order to compile Arrow for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated using your suggested text |
||
``` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. side noteWhen compiling to [patch.crates-io]
prettytable-rs = { git = "https://github.com/phsym/prettytable-rs", branch = "master"} This is mentioned in polars but I'm not sure if this fits the arrow README so I didn't include it. The arrow2 project recently changed to comfy-table because prettytable-rs is not maintained (see jorgecarleitao/arrow2#251). I don't think that comfy-table compiles to wasm32-wasi but that's minor for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
## Examples | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically for
wasm32-wasi
there is no real need to exclude test dependencies socargo build --features=simd --target wasm32-wasi
orcargo build --target wasm32-wasi
also work. However, I don't see a real reason to include it.