Skip to content

Commit

Permalink
Merge pull request #79 from huggingface/new_version
Browse files Browse the repository at this point in the history
Revamp the features to have cross product.
  • Loading branch information
Narsil authored Dec 25, 2024
2 parents c1fa796 + 2c9143f commit e2c2c31
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 986 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: ilammy/setup-nasm@v1

- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy, llvm-tools-preview
components: rustfmt, clippy
override: true

- uses: Swatinem/rust-cache@v2

- name: Instal cargo audit
- name: Install cargo audit
run: cargo install cargo-audit

- name: Build
Expand All @@ -37,8 +35,14 @@ jobs:
run: cargo test --all-features --verbose

- name: Run Tests (no ssl)
run: cargo test --no-default-features --verbose --lib
run: cargo test --no-default-features --verbose

- name: Run Tests (ssl cross)
run: |
cargo test --no-default-features --features ureq,native-tls
cargo test --no-default-features --features ureq,rustls-tls
cargo test --no-default-features --features tokio,native-tls
cargo test --no-default-features --features tokio,rustls-tls
- name: Run Audit
# RUSTSEC-2021-0145 is criterion so only within benchmarks
run: cargo audit -D warnings
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hf-hub"
version = "0.3.2"
version = "0.4.0"
edition = "2021"
homepage = "https://github.com/huggingface/hf-hub"
license = "Apache-2.0"
Expand Down Expand Up @@ -28,20 +28,22 @@ reqwest = { version = "0.12.2", optional = true, default-features = false, featu
"json",
] }
rustls = { version = "0.23.4", optional = true }
serde = { version = "1.0.171", features = ["derive"], optional = true }
serde_json = { version = "1.0.103", optional = true }
thiserror = { version = "1.0.43", optional = true }
serde = { version = "1", features = ["derive"], optional = true }
serde_json = { version = "1", optional = true }
thiserror = { version = "2", optional = true }
tokio = { version = "1.29.1", optional = true, features = ["fs", "macros"] }
ureq = { version = "2.8.0", optional = true, features = [
"json",
"socks-proxy",
] }
native-tls = { version = "0.2.12", optional = true }

[features]
default = ["default-tls", "tokio", "ureq"]
# These features are only relevant when used with the `tokio` feature, but this might change in the future.
default-tls = ["dep:reqwest", "reqwest/default"]
rustls-tls = ["dep:reqwest", "dep:rustls", "reqwest/rustls-tls"]
default-tls = []
native-tls = ["dep:reqwest", "reqwest/default", "dep:native-tls", "ureq/native-tls"]
rustls-tls = ["dep:rustls", "reqwest/rustls-tls"]
tokio = [
"dep:futures",
"dep:indicatif",
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ let _filename = repo.get("config.json").unwrap();

# SSL/TLS

This library uses its dependencies' default TLS implementations which are `rustls` for `ureq` (sync) and `native-tls` (openssl) for `tokio`.

If you want control over the TLS backend you can remove the default features and only add the backend you are intending to use.

```bash
cargo add hf-hub -no-default-features --features ureq,rustls-tls
cargo add hf-hub -no-default-features --features ureq,native-tls
cargo add hf-hub -no-default-features --features tokio,rustls-tls
cargo add hf-hub -no-default-features --features tokio,native-tls
```


When using the [`ureq`](https://github.com/algesten/ureq) feature, you will always use its default TLS backend which is [rustls](https://github.com/rustls/rustls).

When using [`tokio`](https://github.com/tokio-rs/tokio), by default `default-tls` will be enabled, which means OpenSSL. If you want/need to use rustls, disable the default features and use `rustls-tls` in conjunction with `tokio`.
Loading

0 comments on commit e2c2c31

Please sign in to comment.