From 0d40ac03fb714b33e6dd819e7890793fce8c4d1d Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Thu, 2 Nov 2023 14:57:21 -0700 Subject: [PATCH] internal: Migrate to proto v0.21 version types. (#4) --- Cargo.lock | 170 ++++++++++++++++++++++--------------------------- Cargo.toml | 13 ++-- README.md | 2 +- src/proto.rs | 23 +++++-- src/version.rs | 12 +--- 5 files changed, 103 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0171602..6e683f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,13 +130,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -245,7 +245,7 @@ dependencies = [ "ahash", "cached_proc_macro", "cached_proc_macro_types", - "hashbrown 0.14.0", + "hashbrown 0.14.2", "instant", "once_cell", "thiserror", @@ -693,7 +693,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -715,7 +715,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -897,9 +897,9 @@ dependencies = [ [[package]] name = "extism" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a94848d5b49906bd97b83cf5a8bd25082dbc6f8bdfe98f12687910228734552" +checksum = "67e81d3e7d1592412579984e773bd553703a664bbfb1ddded742bf6dfae63847" dependencies = [ "anyhow", "extism-manifest", @@ -942,14 +942,14 @@ checksum = "d2be216330f7304de051e0faf1578880e9e0dc1ecbd2c0fea5765c63a079d0ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] name = "extism-runtime" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b0ba8ef6ecbf59c0f6e47fd2feea575ebc3a09e81603d06a41af92fe61cdfa" +checksum = "126b884cfa74fc386eedff1095bac8ef6c2ae5efdb656e508f12a41434d0bf0c" dependencies = [ "anyhow", "cbindgen", @@ -1016,9 +1016,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -1092,7 +1092,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -1247,9 +1247,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash", "allocator-api2", @@ -1440,7 +1440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.2", ] [[package]] @@ -1749,7 +1749,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -1854,12 +1854,12 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "once_map" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "169e72192bc84493725bfca5d47da4ee2abc8acf155586d8127eb17f022497f4" +checksum = "3388ad2ab0b17d90355995011856a3337e0a98147950f076ee9a73ad5d4a553e" dependencies = [ "ahash", - "hashbrown 0.14.0", + "hashbrown 0.14.2", "parking_lot", "stable_deref_trait", ] @@ -2008,18 +2008,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "proto_core" -version = "0.20.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3ec2a09d2419150c2a05f4a02a0db67daa01bdf7579b9109772d0861327b8b" +checksum = "4ea826b40e2682f5eb5ee90d1065e09a710ec74807f5c7db85aa3c5fb397623e" dependencies = [ "cached", "extism", @@ -2028,7 +2028,6 @@ dependencies = [ "minisign-verify", "once_cell", "proto_pdk_api", - "proto_wasm_plugin", "regex", "reqwest", "semver", @@ -2049,9 +2048,9 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63fb8a833e33fcb2ea79324ef89b5e631b8aadc3c7c11bdf4bc7ca25ec716858" +checksum = "ce0b4fe64801579bbf1c341db7c6bf9b67cd2d58e3bf32d28b6fd69908cfe102" dependencies = [ "anyhow", "extism-pdk", @@ -2061,9 +2060,9 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c05662171d4984a9fd57e7fc33a071e0822bb2e993b7a1d06ce9dc5847698b6" +checksum = "a0d49bf81e0c2033a4660270a2c8ff6f331ba0cb61500c6d3dc41d8f18cd5ce3" dependencies = [ "anyhow", "semver", @@ -2071,33 +2070,20 @@ dependencies = [ "serde_json", "system_env", "thiserror", + "version_spec", "warpgate_api", ] [[package]] name = "proto_pdk_test_utils" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cc75a9923b630193bef09734147636f45e5857ff33d8511fbb1e3ccffe5e1ad" +checksum = "fb47a6bf9be024ae8690f62e6e9c3e0c2537e9071c1562a74564bf70378b8a80" dependencies = [ "extism", "proto_core", "proto_pdk_api", - "proto_wasm_plugin", - "serde_json", -] - -[[package]] -name = "proto_wasm_plugin" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4ff89bb77f5f4ce5dd9536200c73140acaef632d33cacb59e12a2a8c8f3d7d" -dependencies = [ - "extism", - "proto_pdk_api", "serde_json", - "starbase_utils", - "tracing", ] [[package]] @@ -2125,7 +2111,6 @@ name = "python_plugin" version = "0.1.2" dependencies = [ "extism-pdk", - "once_cell", "proto_pdk", "proto_pdk_test_utils", "regex", @@ -2523,9 +2508,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] @@ -2542,13 +2527,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -2564,9 +2549,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -2691,9 +2676,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "starbase_archive" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ad85bff80a5ec20265e65a69102eee54ae1e4dac9f977256fbf770c7153fa1" +checksum = "935856c30da2f62a73bcc57eecb5508bedd313287bc0e00e7e7c4b7a07fb5995" dependencies = [ "flate2", "miette", @@ -2705,14 +2690,14 @@ dependencies = [ "tracing", "xz2", "zip", - "zstd 0.12.4", + "zstd 0.13.0", ] [[package]] name = "starbase_events" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f172a2185991dbfb2a3446c47749ade52d66d2aaea724d19bd45607527ebd9d" +checksum = "455a107aab23fa941399ed716e42776ac8e200f5f92706b7ce59b08949aaf153" dependencies = [ "async-trait", "miette", @@ -2722,21 +2707,21 @@ dependencies = [ [[package]] name = "starbase_macros" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63159597180d00c01353e4bf4d4401328a30eb618c0130adf7b9371db4df3d3a" +checksum = "70da3be1ac772cd1cf5b71a725988b64829da92664b8fc362be765462c28638c" dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] name = "starbase_sandbox" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2c63f6daf91fb1cb95ac13ff5f5bf57d0657060519d137cfff6d1a0a690dbc" +checksum = "49d8cc34f93dd97db45ad1a7240bc03e01ee8478af003f8d945e8031585a4f11" dependencies = [ "assert_cmd", "assert_fs", @@ -2761,9 +2746,9 @@ dependencies = [ [[package]] name = "starbase_utils" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b5dc77ea8ee6706f6485f931653277a4bfe04a2d127727e018b082fbfe52b3" +checksum = "f9faf731068b919569efae7f6c7c6c3d2e29411c1cba666ef0c6fe20b82f50a1" dependencies = [ "dirs 5.0.1", "fs4", @@ -2777,7 +2762,7 @@ dependencies = [ "starbase_styles", "thiserror", "tokio", - "toml 0.8.2", + "toml 0.8.6", "tracing", "wax", ] @@ -2811,9 +2796,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.31" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -2859,9 +2844,9 @@ dependencies = [ [[package]] name = "system_env" -version = "0.0.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1a5b2f67543171658346f56eba6978221227dd79541a6b1fdb2b2f9116ed640" +checksum = "a9a9eb72230d28d8116aab631232e98675a7fd3e69b81b046d54205bd21e16d5" dependencies = [ "serde", "serde_json", @@ -2946,7 +2931,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -3033,7 +3018,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -3083,21 +3068,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.2" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.20.7", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -3117,9 +3102,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ "indexmap 2.0.0", "serde", @@ -3154,7 +3139,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", ] [[package]] @@ -3294,9 +3279,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "version_spec" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5babc3fe9e74e0559d8f8a825b6dcfec6f0dbf04db30926eaaf3caddcb4fb8ef" +checksum = "e5e3bdf3e63b4025522cf6a324e3c4f8f0f29a9148de2392d980c10f22b134c7" dependencies = [ "human-sort", "once_cell", @@ -3335,9 +3320,9 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.5.10" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52eeb90e962c1310c0bfe7d066f4a7fe032f01dd94f6ee3d983167c90596a7f7" +checksum = "31378533107129c8dcc2cc8b2333768a21374ccecc735d33c468b4ebe747b225" dependencies = [ "extism", "miette", @@ -3442,7 +3427,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -3476,7 +3461,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4259,11 +4244,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" dependencies = [ - "zstd-safe 6.0.6", + "zstd-safe 7.0.0", ] [[package]] @@ -4278,11 +4263,10 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.6" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" dependencies = [ - "libc", "zstd-sys", ] diff --git a/Cargo.toml b/Cargo.toml index eac6de4..b9b612e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,15 +10,14 @@ crate-type = ['cdylib'] [dependencies] extism-pdk = "0.3.4" -once_cell = "1.18.0" -proto_pdk = { version = "0.8.0" } # , path = "../../proto/crates/pdk" } -regex = "1.10.2" -serde = "1.0.189" +proto_pdk = { version = "0.9.0" } # , path = "../../proto/crates/pdk" } +regex = { version = "1.10.2", default-features = false, features = ["std"] } +serde = "1.0.190" [dev-dependencies] -proto_pdk_test_utils = { version = "0.8.2" } # , path = "../../proto/crates/pdk-test-utils" } -starbase_sandbox = "0.1.11" -tokio = "1.33.0" +proto_pdk_test_utils = { version = "0.9.1" } # , path = "../../proto/crates/pdk-test-utils" } +starbase_sandbox = "0.1.12" +tokio = { version = "1.33.0", features = ["full"] } [profile.release] codegen-units = 1 diff --git a/README.md b/README.md index 45674e8..8b91997 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Caveats -If `python-build` exists on the host machine, this will be used to install python. Otherwise, a pre-built version will be downloaded from [indygreg/python-build-standalone](https://github.com/indygreg/python-build-standalone), which doesn't support all versions, only Python 3. +This will install a pre-built version from [indygreg/python-build-standalone](https://github.com/indygreg/python-build-standalone), which doesn't support all versions, only Python 3. Building from source directly (with `python-build`), and supporting Python 2, will be fully supported in the future. diff --git a/src/proto.rs b/src/proto.rs index b237f2e..0230d11 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -1,8 +1,9 @@ use crate::version::from_python_version; use extism_pdk::*; use proto_pdk::*; +use regex::Regex; use serde::Deserialize; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::fs; #[host_fn] @@ -62,16 +63,21 @@ pub fn download_prebuilt( Json(input): Json, ) -> FnResult> { let env = get_proto_environment()?; - let version = input.context.version; + let version = &input.context.version; - if version == "canary" { + if version.is_canary() { return err!(PluginError::UnsupportedCanary { tool: NAME.into() }.into()); } - let releases: HashMap> = + let releases: BTreeMap> = fetch_url("https://raw.githubusercontent.com/moonrepo/python-plugin/master/releases.json")?; - let Some(release_triples) = releases.get(&version) else { + let release_triples = match version { + VersionSpec::Version(v) => releases.get(v), + _ => None, + }; + + let Some(release_triples) = release_triples else { return err!("No pre-built available for version {}!", version); }; @@ -132,10 +138,15 @@ pub fn locate_bins(Json(input): Json) -> FnResult) -> FnResult> { let tags = load_git_tags("https://github.com/python/cpython")?; + let regex = Regex::new( + r"v?(?[0-9]+)\.(?[0-9]+)(?:\.(?[0-9]+))?(?:(?
a|b|c|rc)(?[0-9]+))?",
+    )
+    .unwrap();
+
     let tags = tags
         .into_iter()
         .filter(|t| t != "legacy-trunk")
-        .filter_map(from_python_version)
+        .filter_map(|t| from_python_version(t, ®ex))
         .collect::>();
 
     Ok(Json(LoadVersionsOutput::from(tags)?))
diff --git a/src/version.rs b/src/version.rs
index bc6582a..9a9e514 100644
--- a/src/version.rs
+++ b/src/version.rs
@@ -1,17 +1,9 @@
 #![allow(dead_code)]
 
-use once_cell::sync::Lazy;
 use regex::Regex;
 
-pub static VERSION_PATTERN: Lazy = Lazy::new(|| {
-    Regex::new(
-        r"v?(?\d+)\.(?\d+)(?:\.(?\d+))?(?:(?
a|b|c|rc)(?\d+))?",
-    )
-    .unwrap()
-});
-
-pub fn from_python_version(version: String) -> Option {
-    let Some(caps) = VERSION_PATTERN.captures(&version) else {
+pub fn from_python_version(version: String, regex: &Regex) -> Option {
+    let Some(caps) = regex.captures(&version) else {
         return None;
     };