Skip to content

Commit

Permalink
feat(js): compile rattler_solve and rattler_repodata_gateway (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra authored Feb 28, 2025
1 parent b7835ae commit ea22fe9
Show file tree
Hide file tree
Showing 56 changed files with 6,850 additions and 5,041 deletions.
6 changes: 5 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ rustflags = [
"-Wfuture_incompatible",
"-Wnonstandard_style",
"-Wrust_2018_idioms",
]
]

[target.'wasm32-unknown-unknown']
# See https://docs.rs/getrandom/latest/getrandom/#webassembly-support
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
7 changes: 6 additions & 1 deletion .github/workflows/js-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ concurrency:
permissions:
contents: read

env:
RUST_LOG: info
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings --cfg getrandom_backend=\"wasm_js\""

jobs:
format_lint_test:
name: Format, Lint and Test the JS bindings
Expand Down Expand Up @@ -58,7 +63,7 @@ jobs:
working-directory: js-rattler
- run: npm run fmt:check
working-directory: js-rattler
- run: npm run build --if-present
- run: npm run build
working-directory: js-rattler
- run: npm test
working-directory: js-rattler
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
CARGO_TERM_COLOR: always
DEFAULT_FEATURES: indicatif,tokio,serde,wasm,reqwest,sparse,gateway,resolvo,libsolv_c,s3
DEFAULT_FEATURES: indicatif,tokio,serde,reqwest,sparse,gateway,resolvo,libsolv_c,s3

jobs:
check-rustdoc-links:
Expand Down
103 changes: 37 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ base64 = "0.22.1"
bindgen = "0.71.1"
blake2 = "0.10.6"
bytes = "1.10.0"
bzip2 = "0.5.1"
bzip2 = "0.5.2"
cache_control = "0.2.0"
cfg-if = "1.0"
chrono = { version = "0.4.40", default-features = false, features = [
Expand Down Expand Up @@ -96,7 +96,6 @@ itertools = "0.14.0"
json-patch = "3.0.1"
keyring = "3.6.1"
lazy-regex = "3.4.1"
lazy_static = "1.5.0"
libc = { version = "0.2" }
libloading = "0.8.6"
libz-sys = { version = "1.1.21", default-features = false }
Expand All @@ -108,7 +107,6 @@ nom = "7.1.3"
num_cpus = "1.16.0"
opendal = { version = "0.51.2", default-features = false }
once_cell = "1.20.3"
ouroboros = "0.18.5"
parking_lot = "0.12.3"
pathdiff = "0.2.3"
pep440_rs = { version = "0.7.3" }
Expand All @@ -123,14 +121,15 @@ rayon = "1.10.0"
reflink-copy = "0.1.23"
regex = "1.11.1"
reqwest = { version = "0.12.12", default-features = false }
reqwest-middleware = "0.4.0"
reqwest-middleware = "0.4.1"
reqwest-retry = "0.7.0"
resolvo = { version = "0.8.6" }
retry-policies = { version = "0.4.0", default-features = false }
rmp-serde = { version = "1.3.0" }
rstest = { version = "0.24.0" }
rstest_reuse = "0.7.0"
simd-json = { version = "0.14.3", features = ["serde_impl"] }
self_cell = "1.1.0"
serde = { version = "1.0.218" }
serde_json = { version = "1.0.139" }
serde_repr = "0.1"
Expand Down Expand Up @@ -171,6 +170,7 @@ url = { version = "2.5.4" }
unicode-normalization = "0.1.24"
uuid = { version = "1.13.1", default-features = false }
walkdir = "2.5.0"
wasmtimer = "0.4.1"
which = "7.0.2"
windows-sys = { version = "0.59.0", default-features = false }
winver = { version = "1.0.0" }
Expand Down
4 changes: 3 additions & 1 deletion crates/rattler_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ edition.workspace = true
readme.workspace = true

[dependencies]

[target.'cfg(not( target_arch = "wasm32" ))'.dependencies]
anyhow.workspace = true
dashmap.workspace = true
dirs.workspace = true
futures.workspace = true
fs-err.workspace = true
fs4 = { workspace = true, features = ["fs-err3-tokio", "tokio"] }
fxhash.workspace = true
itertools.workspace = true
parking_lot.workspace = true
Expand All @@ -30,7 +33,6 @@ url.workspace = true
thiserror.workspace = true
reqwest-middleware.workspace = true
digest.workspace = true
fs4 = { workspace = true, features = ["fs-err3-tokio", "tokio"] }
simple_spawn_blocking = { version = "1.1.0", path = "../simple_spawn_blocking", features = ["tokio"] }
rayon = { workspace = true }
serde_json = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/rattler_cache/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#[cfg(not(target_arch = "wasm32"))]
use std::path::PathBuf;

#[cfg(not(target_arch = "wasm32"))]
pub mod package_cache;
#[cfg(not(target_arch = "wasm32"))]
pub mod run_exports_cache;

#[cfg(not(target_arch = "wasm32"))]
pub mod validation;

mod consts;
Expand All @@ -11,6 +15,7 @@ pub use consts::{PACKAGE_CACHE_DIR, REPODATA_CACHE_DIR, RUN_EXPORTS_CACHE_DIR};
/// Determines the default cache directory for rattler.
/// It first checks the environment variable `RATTLER_CACHE_DIR`.
/// If not set, it falls back to the standard cache directory provided by `dirs::cache_dir()/rattler/cache`.
#[cfg(not(target_arch = "wasm32"))]
pub fn default_cache_dir() -> anyhow::Result<PathBuf> {
std::env::var("RATTLER_CACHE_DIR")
.map(PathBuf::from)
Expand Down
6 changes: 3 additions & 3 deletions crates/rattler_networking/src/authentication_middleware.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! `reqwest` middleware that authenticates requests with data from the `AuthenticationStorage`
use crate::authentication_storage::AuthenticationStorageError;
use crate::{Authentication, AuthenticationStorage};
use async_trait::async_trait;
use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use reqwest::{Request, Response};
Expand All @@ -16,7 +15,8 @@ pub struct AuthenticationMiddleware {
auth_storage: AuthenticationStorage,
}

#[async_trait]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
impl Middleware for AuthenticationMiddleware {
async fn handle(
&self,
Expand Down Expand Up @@ -148,7 +148,7 @@ mod tests {
pub captured_tx: tokio::sync::mpsc::Sender<reqwest::Request>,
}

#[async_trait]
#[async_trait::async_trait]
impl Middleware for CaptureAbortMiddleware {
async fn handle(
&self,
Expand Down
Loading

0 comments on commit ea22fe9

Please sign in to comment.