Skip to content

Commit

Permalink
[skip ci] make rattler-package-streaming compile with wasm!
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Aug 23, 2023
1 parent e286552 commit fae9930
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 13 deletions.
1 change: 1 addition & 0 deletions crates/rattler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rustls-tls = ['reqwest/rustls-tls', 'rattler_package_streaming/rustls-tls']

[dependencies]
anyhow = "1.0.71"
# async-compression = { version = "0.4.1", path = "../../../async-compression", features = ["gzip", "tokio", "bzip2", "zstd"] }
async-compression = { version = "0.4.1", features = ["gzip", "tokio", "bzip2", "zstd"] }
bytes = "1.4.0"
chrono = { version = "0.4.26", default-features = false, features = ["std", "serde", "alloc"] }
Expand Down
28 changes: 21 additions & 7 deletions crates/rattler_conda_types/src/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,27 @@ impl Channel {
Channel::from_url(url, platforms, config)
} else if is_path(channel) {
let path = PathBuf::from(channel);
let absolute_path = absolute_path(&path);
let url = Url::from_directory_path(absolute_path)
.map_err(|_| ParseChannelError::InvalidPath(path))?;
Self {
platforms,
base_url: url,
name: Some(channel.to_owned()),

#[cfg(not(target_arch = "wasm32"))]
{
let absolute_path = absolute_path(&path);
let url = Url::from_directory_path(absolute_path)
.map_err(|_| ParseChannelError::InvalidPath(path))?;
Self {
platforms,
base_url: url,
name: Some(channel.to_owned()),
}
}

#[cfg(target_arch = "wasm32")]
{
let url = Url::try_from("https://anaconda.org").unwrap();
Self {
platforms,
base_url: url,
name: Some(channel.to_owned()),
}
}
} else {
Channel::from_name(channel, platforms, config)
Expand Down
3 changes: 3 additions & 0 deletions crates/rattler_conda_types/src/match_spec/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ fn parse(input: &str) -> Result<MatchSpec, ParseMatchSpecError> {
if is_package_file(input) {
let _url = match Url::parse(input) {
Ok(url) => url,
#[cfg(target_arch = "wasm32")]
Err(_) => return Err(ParseMatchSpecError::InvalidPackagePathOrUrl),
#[cfg(not(target_arch = "wasm32"))]
Err(_) => match PathBuf::from_str(input) {
Ok(path) => Url::from_file_path(path)
.map_err(|_| ParseMatchSpecError::InvalidPackagePathOrUrl)?,
Expand Down
4 changes: 3 additions & 1 deletion crates/rattler_conda_types/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl Platform {
target_os = "emscripten",
windows
)))]
compile_error!("unsupported target os");
{
return Platform::Linux64;
}
}

/// Returns a string representation of the platform.
Expand Down
4 changes: 2 additions & 2 deletions crates/rattler_networking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

//! Networking utilities for Rattler, specifically authenticating requests

use std::path::PathBuf;
use std::{path::PathBuf, sync::Arc};

pub use authentication_storage::{authentication::Authentication, storage::AuthenticationStorage};
use reqwest::{Client, IntoUrl, Method, Url};
use reqwest::{Client, ClientBuilder, IntoUrl, Method, Url};

pub mod authentication_storage;
pub mod retry_policies;
Expand Down
6 changes: 3 additions & 3 deletions crates/rattler_package_streaming/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.workspace = true
readme.workspace = true

[dependencies]
bzip2 = { version = "0.4" }
bzip2 = { version = "0.4", path = "../../../bzip2-rs" }
chrono = "0.4.26"
futures-util = { version = "0.3.28", optional = true }
itertools = "0.11.0"
Expand All @@ -24,8 +24,8 @@ tokio = { version = "1", optional = true }
tokio-util = { version = "0.7", optional = true }
reqwest = { version = "0.11.18", optional = true, default-features = false }
url = "2.4.0"
zip = { version = "0.6.6" }
zstd = "0.12.3"
zip = { version = "0.6.6", default-features = false, features = ["deflate", "time"] }
zstd = { version = "0.12.3", features = ["wasm"], default-features = false }
rattler_networking = { version = "0.7.0", path = "../rattler_networking", default-features = false }

[features]
Expand Down
1 change: 1 addition & 0 deletions crates/rattler_repodata_gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ license.workspace = true
readme.workspace = true

[dependencies]
# async-compression = { version = "0.4.1", path = "../../../async-compression", features = ["gzip", "tokio", "bzip2", "zstd"] }
async-compression = { version = "0.4.1", features = ["gzip", "tokio", "bzip2", "zstd"] }
blake2 = "0.10.6"
cache_control = "0.2.0"
Expand Down

0 comments on commit fae9930

Please sign in to comment.