diff --git a/.github/workflows/publish-crates.io.yml b/.github/workflows/publish-crates.io.yml new file mode 100644 index 0000000..db546a7 --- /dev/null +++ b/.github/workflows/publish-crates.io.yml @@ -0,0 +1,18 @@ +name: Publish on crates.io + +on: + workflow_dispatch: + +jobs: + publish-rust: + runs-on: ubuntu-latest + environment: crates.io + permissions: + id-token: write + steps: + - uses: actions/checkout@v7 + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + - run: cargo publish -p utile + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/Cargo.lock b/Cargo.lock index ddfa2f4..f584a7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", - "cpufeatures", + "cpufeatures 0.2.17", ] [[package]] @@ -859,6 +859,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "rand_core 0.10.1", +] + [[package]] name = "charset" version = "0.1.5" @@ -1004,6 +1015,15 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "content_disposition" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc14a88e1463ddd193906285abe5c360c7e8564e05ccc5d501755f7fbc9ca9c" +dependencies = [ + "charset", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -1039,6 +1059,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.5.0" @@ -1778,11 +1807,25 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", +] + [[package]] name = "glob" version = "0.3.3" @@ -2019,12 +2062,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "humansize" version = "2.1.3" @@ -2116,21 +2153,6 @@ dependencies = [ "windows-registry", ] -[[package]] -name = "hyperx" -version = "1.4.0" -source = "git+https://github.com/QuartzLibrary/hyperx?rev=b4bf9e31a8a8676bb0ce229fec36a140e0d096f7#b4bf9e31a8a8676bb0ce229fec36a140e0d096f7" -dependencies = [ - "base64 0.22.1", - "bytes", - "http", - "httpdate", - "language-tags", - "mime", - "percent-encoding", - "unicase", -] - [[package]] name = "iana-time-zone" version = "0.1.64" @@ -2473,7 +2495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cfc352a66ba903c23239ef51e809508b6fc2b0f90e3476ac7a9ff47e863ae95" dependencies = [ "scopeguard", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2485,12 +2507,6 @@ dependencies = [ "log", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy-regex" version = "3.4.2" @@ -3733,6 +3749,12 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "radium" version = "0.7.0" @@ -3770,6 +3792,17 @@ dependencies = [ "rand_core 0.9.3", ] +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + [[package]] name = "rand_chacha" version = "0.3.1" @@ -3809,6 +3842,12 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + [[package]] name = "rand_xorshift" version = "0.4.0" @@ -4120,7 +4159,6 @@ dependencies = [ "getrandom 0.2.16", "getrandom 0.3.4", "gloo-timers", - "hyperx", "indicatif", "log", "nohash-hasher", @@ -4750,7 +4788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest", ] @@ -4761,7 +4799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest", ] @@ -5526,20 +5564,21 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utile" -version = "0.1.0" +version = "0.1.1" dependencies = [ "ahash 0.8.12", "bytes", + "content_disposition", "futures", "getrandom 0.2.16", "getrandom 0.3.4", + "getrandom 0.4.3", "gloo-timers", - "hyperx", "log", "nohash-hasher", "pin-project", "plotly", - "rand 0.9.2", + "rand 0.10.2", "regex", "reqwest", "rmp-serde", diff --git a/puv/README.md b/puv/README.md index 8f1fcd6..2fc22c5 100644 --- a/puv/README.md +++ b/puv/README.md @@ -16,7 +16,7 @@ This crate allows you to run plain PEP 723 scripts, or scripts that expose a `pr ```python # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = ["numpy"] # /// @@ -38,7 +38,7 @@ def process(x: Input) -> int: let function = PythonFunction { function: r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = ["numpy"] # /// @@ -98,7 +98,7 @@ struct Output { let function = PythonFunction { function: r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = ["pydantic"] # /// diff --git a/puv/src/function.rs b/puv/src/function.rs index ea4d67a..2e1a5f9 100644 --- a/puv/src/function.rs +++ b/puv/src/function.rs @@ -285,7 +285,7 @@ impl PythonFunction { pub(super) fn simple() -> (Self, Vec) { const FUNCTION: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// @@ -314,7 +314,7 @@ def process(input: int) -> int: pub(super) fn dep() -> (Self, Vec) { const FUNCTION: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = ["numpy", "pandas"] # /// @@ -343,7 +343,7 @@ def process(x: int) -> list[int]: pub(super) fn exception() -> (Self, Vec) { const FUNCTION: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// @@ -380,7 +380,7 @@ Exception: This is a test pub(super) fn invalid_function() -> (Self, Vec) { const FUNCTION: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// @@ -410,7 +410,7 @@ def pro cess(input: int) -> int: pub(super) fn invalid_import() -> (Self, Vec) { const FUNCTION: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// diff --git a/puv/src/script.rs b/puv/src/script.rs index 7777eb3..eb359ad 100644 --- a/puv/src/script.rs +++ b/puv/src/script.rs @@ -151,7 +151,7 @@ mod tests { const TEST_SCRIPT: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// @@ -200,7 +200,7 @@ mod exception_tests { const TEST_EXCEPTION_SCRIPT: &str = r#" # /// script -# requires-python = "==3.10" +# requires-python = "==3.10.*" # dependencies = [] # /// diff --git a/resource/Cargo.toml b/resource/Cargo.toml index 306721a..883a529 100644 --- a/resource/Cargo.toml +++ b/resource/Cargo.toml @@ -17,7 +17,6 @@ bytes = "1" directories = "6" flate2 = "1" futures = "0.3" -hyperx = { version = "1", git = "https://github.com/QuartzLibrary/hyperx", rev = "b4bf9e31a8a8676bb0ce229fec36a140e0d096f7" } # branch = "bump" indicatif = { version = "0.17", features = ["tokio"] } log = "0.4" nohash-hasher = "0.2" diff --git a/utile/Cargo.toml b/utile/Cargo.toml index ee5cc30..935330e 100755 --- a/utile/Cargo.toml +++ b/utile/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "utile" -version = "0.1.0" +version = "0.1.1" edition = "2024" +license = "MIT OR Apache-2.0" +description = "Utility library" [features] nightly = [] @@ -9,15 +11,15 @@ nightly = [] [dependencies] ahash = "0.8" bytes = "1" +content_disposition = "0.4" futures = "0.3" -hyperx = { version = "1", git = "https://github.com/QuartzLibrary/hyperx", rev = "b4bf9e31a8a8676bb0ce229fec36a140e0d096f7" } # branch = "bump" log = "0.4" nohash-hasher = "0.2" pin-project = "1" plotly = "0.12" -rand = "0.9" +rand = "0.10" regex = "1" -reqwest = { version = "0.12", features = ["blocking", "stream"] } +reqwest = { version = "0.12" } rmp-serde = "1.3.0" serde = { version = "1", features = ["derive"] } serde_json = "1" @@ -32,8 +34,9 @@ web-time = "1.1.0" [target.'cfg(target_arch = "wasm32")'.dependencies] gloo-timers = { version = "0.3.0", features = ["futures"] } wasm-bindgen-futures = "0.4" -getrandom = { version = "0.3", features = ["wasm_js"] } -_getrandom = { version = "0.2", features = ["js"], package = "getrandom" } +_getrandom4 = { version = "0.4", features = ["wasm_js"], package = "getrandom" } +_getrandom3 = { version = "0.3", features = ["wasm_js"], package = "getrandom" } +_getrandom2 = { version = "0.2", features = ["js"], package = "getrandom" } [dev-dependencies] tokio = { version = "1", features = ["macros"] } diff --git a/utile/src/fs/safe_path.rs b/utile/src/fs/safe_path.rs index a43794a..eff0169 100755 --- a/utile/src/fs/safe_path.rs +++ b/utile/src/fs/safe_path.rs @@ -169,7 +169,7 @@ fn decode_component(c: &str) -> String { #[cfg(test)] mod tests { - use rand::{Rng, SeedableRng, rngs::SmallRng, seq::IndexedRandom}; + use rand::{Rng, RngExt, SeedableRng, rngs::SmallRng, seq::IndexedRandom}; use super::*; diff --git a/utile/src/io.rs b/utile/src/io.rs index 33df4c1..12bf7ab 100755 --- a/utile/src/io.rs +++ b/utile/src/io.rs @@ -1,6 +1,5 @@ use std::{fmt, io::BufRead, path::Path, str::FromStr}; -use hyperx::header::{ContentDisposition, DispositionParam, DispositionType, Header}; use reqwest::header::{CONTENT_DISPOSITION, CONTENT_LENGTH, HeaderMap}; pub mod read_ext { @@ -211,24 +210,8 @@ pub fn not_found_error(e: std::io::Error, path: impl AsRef) -> std::io::Er } pub fn get_filename_from_headers(headers: &HeaderMap) -> Option { - let header_value = headers.get(CONTENT_DISPOSITION)?; - let mut content_disposition = ContentDisposition::parse_header(&header_value).ok()?; - - if content_disposition.disposition == DispositionType::Ext("attachement".to_owned()) { - content_disposition.disposition = DispositionType::Attachment; - } - - if content_disposition.disposition != DispositionType::Attachment { - return None; - } - - content_disposition.parameters.iter().find_map(|param| { - if let DispositionParam::Filename(_, _, bytes) = param { - String::from_utf8(bytes.clone()).ok() - } else { - None - } - }) + let value = headers.get(CONTENT_DISPOSITION)?.to_str().ok()?; + content_disposition::parse_content_disposition(value).filename_full() } pub fn get_filesize_from_headers(headers: &HeaderMap) -> Option { headers.get(CONTENT_LENGTH)?.to_str().ok()?.parse().ok() diff --git a/utile/src/range.rs b/utile/src/range.rs index 26a3d39..847d838 100755 --- a/utile/src/range.rs +++ b/utile/src/range.rs @@ -1,8 +1,8 @@ #[cfg(feature = "nightly")] use std::iter::Step; -use std::ops::{Add, Range, Sub}; #[cfg(feature = "nightly")] use std::ops::RangeInclusive; +use std::ops::{Add, Range, Sub}; /// Some helper methods for ranges. /// @@ -184,7 +184,7 @@ range_len!(isize); mod tests { use std::collections::HashSet; - use rand::{Rng, SeedableRng, rngs::SmallRng}; + use rand::{RngExt, SeedableRng, rngs::SmallRng}; use crate::range::RangeExt;