diff --git a/Cargo.lock b/Cargo.lock index 4503ec451..689b8e992 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.19" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -487,7 +487,7 @@ checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832" dependencies = [ "memchr", "once_cell", - "regex-automata", + "regex-automata 0.1.10", "serde", ] @@ -1057,7 +1057,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -1068,7 +1068,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -1166,6 +1166,7 @@ dependencies = [ "itertools", "octocrab", "once_cell", + "parse-display", "platforms", "rayon", "reqwest", @@ -1450,7 +1451,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -2151,7 +2152,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -2171,9 +2172,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -2422,9 +2423,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "onnxruntime" @@ -2560,6 +2561,32 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "parse-display" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6509d08722b53e8dafe97f2027b22ccbe3a5db83cb352931e9716b0aa44bc5c" +dependencies = [ + "once_cell", + "parse-display-derive", + "regex", +] + +[[package]] +name = "parse-display-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68517892c8daf78da08c0db777fcc17e07f2f63ef70041718f8a7630ad84f341" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "regex", + "regex-syntax 0.7.5", + "structmeta", + "syn 2.0.38", +] + [[package]] name = "password-hash" version = "0.4.2" @@ -2758,9 +2785,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -2860,9 +2887,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -2986,13 +3013,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-automata 0.4.1", + "regex-syntax 0.8.1", ] [[package]] @@ -3001,7 +3029,18 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.27", +] + +[[package]] +name = "regex-automata" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.1", ] [[package]] @@ -3010,6 +3049,18 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "regex-syntax" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" + [[package]] name = "reqwest" version = "0.11.13" @@ -3269,7 +3320,7 @@ checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -3351,7 +3402,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -3579,6 +3630,29 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "structmeta" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ad9e09554f0456d67a69c1584c9798ba733a5b50349a6c0d0948710523922d" +dependencies = [ + "proc-macro2", + "quote", + "structmeta-derive", + "syn 2.0.38", +] + +[[package]] +name = "structmeta-derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "strum" version = "0.24.1" @@ -3643,9 +3717,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -3867,7 +3941,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 287e7e854..0c8d7aca3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ clap = { version = "4.0.10", features = ["derive"] } easy-ext = "1.0.1" fs-err = { version = "2.9.0", features = ["tokio"] } itertools = "0.10.5" -once_cell = "1.15.0" -regex = "1.6.0" +once_cell = "1.18.0" +regex = "1.10.0" serde = { version = "1.0.145", features = ["derive"] } serde_json = { version = "1.0.85", features = ["preserve_order"] } strum = { version = "0.24.1", features = ["derive"] } diff --git a/crates/download/Cargo.toml b/crates/download/Cargo.toml index 98a59d60b..c3063a9dc 100644 --- a/crates/download/Cargo.toml +++ b/crates/download/Cargo.toml @@ -17,6 +17,7 @@ indicatif = "0.17.3" itertools.workspace = true octocrab = { version = "0.19.0", default-features = false, features = ["rustls-tls", "stream"] } once_cell.workspace = true +parse-display = "0.8.2" platforms = "3.0.2" rayon = "1.6.1" reqwest = { version = "0.11.13", default-features = false, features = ["rustls-tls", "stream"] } diff --git a/crates/download/src/main.rs b/crates/download/src/main.rs index e52ca45f2..5e77f9ee4 100644 --- a/crates/download/src/main.rs +++ b/crates/download/src/main.rs @@ -36,9 +36,9 @@ const DEFAULT_OUTPUT: &str = if cfg!(windows) { "./voicevox_core" }; -const ORGANIZATION_NAME: &str = "VOICEVOX"; -const CORE_REPO_NAME: &str = "voicevox_core"; -const ADDITIONAL_LIBRARIES_REPO_NAME: &str = "voicevox_additional_libraries"; +const LIB_NAME: &str = "voicevox_core"; +const DEFAULT_CORE_REPO: &str = "VOICEVOX/voicevox_core"; +const DEFAULT_ADDITIONAL_LIBRARIES_REPO: &str = "VOICEVOX/voicevox_additional_libraries"; static OPEN_JTALK_DIC_URL: Lazy = Lazy::new(|| { "https://jaist.dl.sourceforge.net/project/open-jtalk/Dictionary/open_jtalk_dic-1.11/open_jtalk_dic_utf_8-1.11.tar.gz" @@ -75,6 +75,16 @@ struct Args { /// ダウンロードする対象のOSを指定する #[arg(value_enum, long, default_value(Os::default_opt().map(<&str>::from)))] os: Os, + + #[arg(long, value_name("REPOSITORY"), default_value(DEFAULT_CORE_REPO))] + core_repo: RepoName, + + #[arg( + long, + value_name("REPOSITORY"), + default_value(DEFAULT_ADDITIONAL_LIBRARIES_REPO) + )] + additional_libraries_repo: RepoName, } #[derive(Default, ValueEnum, Display, IntoStaticStr, Clone, Copy, PartialEq)] @@ -123,6 +133,13 @@ impl Os { } } +#[derive(parse_display::FromStr, Clone)] +#[from_str(regex = "(?[a-zA-Z0-9_]+)/(?[a-zA-Z0-9_]+)")] +struct RepoName { + owner: String, + repo: String, +} + #[tokio::main(flavor = "multi_thread")] async fn main() -> anyhow::Result<()> { setup_logger(); @@ -135,23 +152,25 @@ async fn main() -> anyhow::Result<()> { device, cpu_arch, os, + core_repo, + additional_libraries_repo, } = Args::parse(); let octocrab = &octocrab()?; - let core = find_gh_asset(octocrab, CORE_REPO_NAME, &version, |tag| { + let core = find_gh_asset(octocrab, core_repo, &version, |tag| { let device = match (os, device) { (Os::Linux, Device::Cuda) => "gpu", (_, device) => device.into(), }; - format!("{CORE_REPO_NAME}-{os}-{cpu_arch}-{device}-{tag}.zip") + format!("{LIB_NAME}-{os}-{cpu_arch}-{device}-{tag}.zip") }) .await?; let additional_libraries = OptionFuture::from((device != Device::Cpu).then(|| { find_gh_asset( octocrab, - ADDITIONAL_LIBRARIES_REPO_NAME, + additional_libraries_repo, &additional_libraries_version, |_| { let device = match device { @@ -169,7 +188,7 @@ async fn main() -> anyhow::Result<()> { info!("対象OS: {os}"); info!("対象CPUアーキテクチャ: {cpu_arch}"); info!("ダウンロードデバイスタイプ: {device}"); - info!("ダウンロード{CORE_REPO_NAME}バージョン: {}", core.tag); + info!("ダウンロード{LIB_NAME}バージョン: {}", core.tag); if let Some(GhAsset { tag, .. }) = &additional_libraries { info!("ダウンロード追加ライブラリバージョン: {tag}"); } @@ -236,7 +255,7 @@ fn octocrab() -> octocrab::Result> { async fn find_gh_asset( octocrab: &Arc, - repo: &str, + repo: RepoName, git_tag_or_latest: &str, asset_name: impl FnOnce(&str) -> String, ) -> anyhow::Result { @@ -246,7 +265,7 @@ async fn find_gh_asset( assets, .. } = { - let repos = octocrab.repos(ORGANIZATION_NAME, repo); + let repos = octocrab.repos(&repo.owner, &repo.repo); let releases = repos.releases(); match git_tag_or_latest { "latest" => releases.get_latest().await, @@ -262,7 +281,7 @@ async fn find_gh_asset( Ok(GhAsset { octocrab: octocrab.clone(), - repo: repo.to_owned(), + repo, tag: tag_name, id, name, @@ -289,7 +308,7 @@ fn download_and_extract_from_gh( Ok(async move { let bytes_stream = octocrab - .repos(ORGANIZATION_NAME, repo) + .repos(&repo.owner, &repo.repo) .releases() .stream_asset(id) .await? @@ -523,7 +542,7 @@ async fn download_and_extract( struct GhAsset { octocrab: Arc, - repo: String, + repo: RepoName, tag: String, id: AssetId, name: String,