From 9fd23f79ed99bf814312cb1f1eb319e48f26f167 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 12 Jun 2025 15:48:21 +0700 Subject: [PATCH] Drop some PyOxidizer-related files --- .gitmodules | 6 - qt/bundle/Cargo.lock | 629 --------------------------------------- qt/bundle/Cargo.toml | 60 ---- qt/bundle/PyOxidizer | 1 - qt/bundle/build.rs | 95 ------ qt/bundle/pyoxidizer.bzl | 189 ------------ qt/bundle/qt.exclude | 10 - qt/bundle/src/anki.rs | 35 --- qt/bundle/src/main.rs | 32 -- 9 files changed, 1057 deletions(-) delete mode 100644 qt/bundle/Cargo.lock delete mode 100644 qt/bundle/Cargo.toml delete mode 160000 qt/bundle/PyOxidizer delete mode 100644 qt/bundle/build.rs delete mode 100644 qt/bundle/pyoxidizer.bzl delete mode 100644 qt/bundle/qt.exclude delete mode 100644 qt/bundle/src/anki.rs delete mode 100644 qt/bundle/src/main.rs diff --git a/.gitmodules b/.gitmodules index 90cec9ca9..50b5aa9f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,9 +6,3 @@ path = ftl/qt-repo url = https://github.com/ankitects/anki-desktop-ftl.git shallow = true -[submodule "qt/bundle/PyOxidizer"] - path = qt/bundle/PyOxidizer - url = https://github.com/ankitects/PyOxidizer.git - shallow = true - update = none - diff --git a/qt/bundle/Cargo.lock b/qt/bundle/Cargo.lock deleted file mode 100644 index 544276d6f..000000000 --- a/qt/bundle/Cargo.lock +++ /dev/null @@ -1,629 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] - -[[package]] -name = "anki" -version = "0.0.0" -dependencies = [ - "embed-resource", - "jemallocator", - "libc", - "libc-stdhandle", - "mimalloc", - "pyembed", - "snmalloc-rs", - "winapi", -] - -[[package]] -name = "anyhow" -version = "1.0.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cc" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "charset" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f426e64df1c3de26cbf44593c6ffff5dbfd43bbf9de0d075058558126b3fc73" -dependencies = [ - "base64 0.10.1", - "encoding_rs", -] - -[[package]] -name = "cmake" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b858541263efe664aead4a5209a4ae5c5d2811167d4ed4ee0944503f8d2089" -dependencies = [ - "cc", -] - -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - -[[package]] -name = "dunce" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "embed-resource" -version = "1.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85505eb239fc952b300f29f0556d2d884082a83566768d980278d8faf38c780d" -dependencies = [ - "cc", - "vswhom", - "winreg", -] - -[[package]] -name = "encoding_rs" -version = "0.8.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "fs_extra" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" - -[[package]] -name = "indoc" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "itertools" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" -dependencies = [ - "either", -] - -[[package]] -name = "jemalloc-sys" -version = "0.5.2+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134163979b6eed9564c98637b710b40979939ba351f59952708234ea11b5f3f8" -dependencies = [ - "cc", - "fs_extra", - "libc", -] - -[[package]] -name = "jemallocator" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c2514137880c52b0b4822b563fadd38257c1f380858addb74a400889696ea6" -dependencies = [ - "jemalloc-sys", - "libc", -] - -[[package]] -name = "libc" -version = "0.2.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013" - -[[package]] -name = "libc-stdhandle" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dac2473dc28934c5e0b82250dab231c9d3b94160d91fe9ff483323b05797551" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "libmimalloc-sys" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" -dependencies = [ - "cc", - "cty", - "libc", -] - -[[package]] -name = "lock_api" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "mailparse" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee6e1ca1c8396da58f8128176f6980dd57bec84c8670a479519d3655f2d6734" -dependencies = [ - "base64 0.13.0", - "charset", - "quoted_printable", -] - -[[package]] -name = "memchr" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" - -[[package]] -name = "memmap2" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memory-module-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbdce2925c681860b08875119254fb5543dbf6337c56ff93afebeed9c686da3" -dependencies = [ - "cc", - "libc", - "winapi", -] - -[[package]] -name = "mimalloc" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" -dependencies = [ - "libmimalloc-sys", -] - -[[package]] -name = "once_cell" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "proc-macro2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "pyembed" -version = "0.24.0-pre" -dependencies = [ - "anyhow", - "dunce", - "jemalloc-sys", - "libc", - "libmimalloc-sys", - "once_cell", - "pyo3", - "pyo3-build-config", - "python-oxidized-importer", - "python-packaging", - "snmalloc-sys", -] - -[[package]] -name = "pyo3" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268be0c73583c183f2b14052337465768c07726936a260f480f0857cb95ba543" -dependencies = [ - "cfg-if", - "indoc", - "libc", - "memoffset", - "parking_lot", - "pyo3-build-config", - "pyo3-ffi", - "pyo3-macros", - "unindent", -] - -[[package]] -name = "pyo3-build-config" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fcd1e73f06ec85bf3280c48c67e731d8290ad3d730f8be9dc07946923005c8" -dependencies = [ - "once_cell", - "target-lexicon", -] - -[[package]] -name = "pyo3-ffi" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6cb136e222e49115b3c51c32792886defbfb0adead26a688142b346a0b9ffc" -dependencies = [ - "libc", - "pyo3-build-config", -] - -[[package]] -name = "pyo3-macros" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94144a1266e236b1c932682136dc35a9dee8d3589728f68130c7c3861ef96b28" -dependencies = [ - "proc-macro2", - "pyo3-macros-backend", - "quote", - "syn", -] - -[[package]] -name = "pyo3-macros-backend" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8df9be978a2d2f0cdebabb03206ed73b11314701a5bfe71b0d753b81997777f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "python-oxidized-importer" -version = "0.9.0-pre" -dependencies = [ - "anyhow", - "memmap2", - "memory-module-sys", - "once_cell", - "pyo3", - "python-packaging", - "python-packed-resources", - "simple-file-manifest", - "winapi", -] - -[[package]] -name = "python-packaging" -version = "0.16.0-pre" -dependencies = [ - "anyhow", - "byteorder", - "encoding_rs", - "itertools", - "mailparse", - "once_cell", - "python-packed-resources", - "regex", - "simple-file-manifest", - "spdx", - "walkdir", -] - -[[package]] -name = "python-packed-resources" -version = "0.12.0-pre" -dependencies = [ - "anyhow", - "byteorder", -] - -[[package]] -name = "quote" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "quoted_printable" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1238256b09923649ec89b08104c4dfe9f6cb2fea734a5db5384e44916d59e9c5" - -[[package]] -name = "redox_syscall" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "simple-file-manifest" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd19be0257552dd56d1bb6946f89f193c6e5b9f13cc9327c4bc84a357507c74" - -[[package]] -name = "smallvec" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" - -[[package]] -name = "snmalloc-rs" -version = "0.2.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36acaace2719c972eab3ef6a6b3aee4495f0bf300f59715bb9cff6c5acf4ae20" -dependencies = [ - "snmalloc-sys", -] - -[[package]] -name = "snmalloc-sys" -version = "0.2.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35a7e6e7d5fe756bee058ddedefc7e0a9f9c8dbaa9401b48ed3c17d6578e40b5" -dependencies = [ - "cc", - "cmake", -] - -[[package]] -name = "spdx" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a346909b3fd07776f9b96b98d4a58e3666f831c9a672c279b10f795a34c36425" -dependencies = [ - "smallvec", -] - -[[package]] -name = "syn" -version = "1.0.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "target-lexicon" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - -[[package]] -name = "unindent" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" - -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f5402d3d0e79a069714f7b48e3ecc60be7775a2c049cb839457457a239532" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] diff --git a/qt/bundle/Cargo.toml b/qt/bundle/Cargo.toml deleted file mode 100644 index 920e890d0..000000000 --- a/qt/bundle/Cargo.toml +++ /dev/null @@ -1,60 +0,0 @@ -[package] -name = "anki" -version = "0.0.0" -authors = ["Ankitects Pty Ltd and contributors "] -build = "build.rs" -edition = "2021" -license = "AGPL-3.0-or-later" -publish = false -rust-version = "1.64" - -[dependencies] -pyembed = { path = "./PyOxidizer/pyembed", default-features = false } - -[target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["wincon"] } -libc = "0.2" -libc-stdhandle = "=0.1.0" - -[dependencies.jemallocator] -version = "0.5" -optional = true - -[dependencies.mimalloc] -version = "0.1" -optional = true -features = ["local_dynamic_tls", "override", "secure"] - -[dependencies.snmalloc-rs] -version = "0.2" -optional = true - -[build-dependencies] -embed-resource = "1.6" - -[features] -default = ["build-mode-standalone"] - -global-allocator-jemalloc = ["jemallocator"] -global-allocator-mimalloc = ["mimalloc"] -global-allocator-snmalloc = ["snmalloc-rs"] - -allocator-jemalloc = ["pyembed/allocator-jemalloc"] -allocator-mimalloc = ["pyembed/allocator-mimalloc"] -allocator-snmalloc = ["pyembed/allocator-snmalloc"] - -# Build this crate in isolation, without using PyOxidizer. -build-mode-standalone = [] - -# Build this crate by executing a `pyoxidizer` executable to build -# required artifacts. -build-mode-pyoxidizer-exe = [] - -# Build this crate by reusing artifacts generated by `pyoxidizer` out-of-band. -# In this mode, the PYOXIDIZER_ARTIFACT_DIR environment variable can refer -# to the directory containing build artifacts produced by `pyoxidizer`. If not -# set, OUT_DIR will be used. -build-mode-prebuilt-artifacts = [] - -[profile.release] -lto = true diff --git a/qt/bundle/PyOxidizer b/qt/bundle/PyOxidizer deleted file mode 160000 index 12a249f68..000000000 --- a/qt/bundle/PyOxidizer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 12a249f686484c5e212ba800e1e7f18c7c4b1b27 diff --git a/qt/bundle/build.rs b/qt/bundle/build.rs deleted file mode 100644 index 4b0318dbf..000000000 --- a/qt/bundle/build.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Based off PyOxidizer's 'init-rust-project'. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. - -use std::path::{Path, PathBuf}; - -use embed_resource; - -const DEFAULT_PYTHON_CONFIG_FILENAME: &str = "default_python_config.rs"; -const DEFAULT_PYTHON_CONFIG: &str = "\ -pub fn default_python_config<'a>() -> pyembed::OxidizedPythonInterpreterConfig<'a> { - pyembed::OxidizedPythonInterpreterConfig::default() -} -"; - -/// Build by calling a `pyoxidizer` executable to generate build artifacts. -fn build_with_pyoxidizer_exe(exe: Option, resolve_target: Option<&str>) { - let pyoxidizer_exe = if let Some(path) = exe { - path - } else { - "pyoxidizer".to_string() - }; - - let mut args = vec!["run-build-script", "build.rs"]; - if let Some(target) = resolve_target { - args.push("--target"); - args.push(target); - } - - match std::process::Command::new(pyoxidizer_exe) - .args(args) - .status() - { - Ok(status) => { - if !status.success() { - panic!("`pyoxidizer run-build-script` failed"); - } - } - Err(e) => panic!("`pyoxidizer run-build-script` failed: {}", e.to_string()), - } -} - -#[allow(clippy::if_same_then_else)] -fn main() { - if std::env::var("CARGO_FEATURE_BUILD_MODE_STANDALONE").is_ok() { - let path = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR not defined")); - let path = path.join(DEFAULT_PYTHON_CONFIG_FILENAME); - - std::fs::write(&path, DEFAULT_PYTHON_CONFIG.as_bytes()) - .expect("failed to write default python config"); - println!( - "cargo:rustc-env=DEFAULT_PYTHON_CONFIG_RS={}", - path.display() - ); - } else if std::env::var("CARGO_FEATURE_BUILD_MODE_PYOXIDIZER_EXE").is_ok() { - let target = if let Ok(target) = std::env::var("PYOXIDIZER_BUILD_TARGET") { - Some(target) - } else { - None - }; - - build_with_pyoxidizer_exe( - std::env::var("PYOXIDIZER_EXE").ok(), - target.as_ref().map(|target| target.as_ref()), - ); - } else if std::env::var("CARGO_FEATURE_BUILD_MODE_PREBUILT_ARTIFACTS").is_ok() { - // relative to src/ - let artifacts = Path::new("../../../out/bundle/artifacts/"); - let config_rs = artifacts.join("default_python_config.rs"); - println!( - "cargo:rustc-env=DEFAULT_PYTHON_CONFIG_RS={}", - config_rs.display() - ); - let config_txt = artifacts.join("pyo3-build-config-file.txt"); - println!("cargo:rustc-env=PYO3_CONFIG_FILE={}", config_txt.display()); - - let link_arg = if cfg!(target_os = "macos") { - "-rdynamic" - } else { - "-Wl,-export-dynamic" - }; - println!("cargo:rustc-link-arg={link_arg}"); - } else { - panic!("build-mode-* feature not set"); - } - - let target_family = - std::env::var("CARGO_CFG_TARGET_FAMILY").expect("CARGO_CFG_TARGET_FAMILY not defined"); - - // embed manifest and icon - if target_family == "windows" { - embed_resource::compile("win/anki-manifest.rc"); - } -} diff --git a/qt/bundle/pyoxidizer.bzl b/qt/bundle/pyoxidizer.bzl deleted file mode 100644 index dc4870606..000000000 --- a/qt/bundle/pyoxidizer.bzl +++ /dev/null @@ -1,189 +0,0 @@ -# type: ignore - -set_build_path(VARS.get("build")) - -excluded_source_prefixes = [ - "ctypes.test", - "distutils.tests", - "idlelib", - "lib2to3.tests", - "test", - "tkinter", - "win32comext", - "win32com", - "win32", - "pythonwin", - "PyQt6", - "pip", - "setuptools", - "google" -] - -excluded_resource_suffixes = [ - ".pyi", - ".pyc", - "py.typed", -] - -included_resource_packages = [ - "anki", - "aqt", - "_aqt", - "lib2to3", - "certifi", - "jsonschema", -] - - -def handle_resource(policy, resource): - if type(resource) == "PythonModuleSource": - resource.add_include = True - for prefix in excluded_source_prefixes: - if resource.name.startswith(prefix) and not resource.name.startswith("pip_system_certs"): - resource.add_include = False - - # if resource.add_include: - # print("src", resource.name, resource.add_include) - - elif type(resource) == "PythonExtensionModule": - resource.add_include = True - if resource.name.startswith("win32") or resource.name.startswith("PyQt6"): - resource.add_include = False - - # print("ext", resource.name, resource.add_include) - - elif type(resource) == "PythonPackageResource": - for prefix in included_resource_packages: - if resource.package.startswith(prefix): - resource.add_include = True - if resource.package == "certifi": - resource.add_location = "filesystem-relative:lib" - for suffix in excluded_resource_suffixes: - if resource.name.endswith(suffix): - resource.add_include = False - - # aqt web resources can be stored in binary - if resource.package.endswith("aqt"): - if not resource.name.startswith("data/web"): - resource.add_location = "filesystem-relative:lib" - - # if resource.add_include: - # print("rsrc", resource.package, resource.name, resource.add_include) - - elif type(resource) == "PythonPackageDistributionResource": - # print("dist", resource.package, resource.name, resource.add_include) - pass - - # elif type(resource) == "File": - # print(resource.path) - - elif type(resource) == "File": - if ( - resource.path.startswith("win32") - or resource.path.startswith("pythonwin") - or resource.path.startswith("pywin32") - ): - exclude = ( - "tests" in resource.path - or "benchmark" in resource.path - or "__pycache__" in resource.path - ) - if not exclude: - # print("add", resource.path) - resource.add_include = True - resource.add_location = "filesystem-relative:lib" - - if ".dist-info" in resource.path: - resource.add_include = False - - else: - print("unexpected type", type(resource)) - - -def make_exe(): - if BUILD_TARGET_TRIPLE == "x86_64-unknown-linux-gnu": - dist = PythonDistribution( - url = "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64_v2-unknown-linux-gnu-pgo-full.tar.zst", - sha256 = "7ccdc1b19599a6660040ec2f0ade755b32bb45c897ea75d0b7826236146b78cf", - ) - elif BUILD_TARGET_TRIPLE == "x86_64-apple-darwin": - dist = PythonDistribution( - url = "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64-apple-darwin-pgo-full.tar.zst", - sha256 = "b2f06f0f0ebbbed0eae87a6e8eede2e0d838735386a8b84257d4f02d16b9baec", - ) - elif BUILD_TARGET_TRIPLE == "aarch64-apple-darwin": - dist = PythonDistribution( - url = "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-aarch64-apple-darwin-pgo-full.tar.zst", - sha256 = "154dfa7cd6f9a6047a58811f84bef69b019ea459e5b42991c8af63e1285b445f", - ) - elif BUILD_TARGET_TRIPLE == "x86_64-pc-windows-msvc": - dist = PythonDistribution( - url = "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64-pc-windows-msvc-shared-pgo-full.tar.zst", - sha256 = "3b9c7d6ed94260b83ed8f44ee9a7b8fce392259ce6591e538601f7353061a884", - ) - else: - fail("unexpected arch") - - policy = dist.make_python_packaging_policy() - - policy.file_scanner_classify_files = True - policy.include_classified_resources = False - - policy.allow_files = True - policy.file_scanner_emit_files = True - policy.include_file_resources = False - - policy.include_distribution_sources = False - policy.include_distribution_resources = False - policy.include_non_distribution_sources = False - policy.include_test = False - - policy.resources_location = "in-memory" - policy.resources_location_fallback = "filesystem-relative:lib" - - policy.register_resource_callback(handle_resource) - - policy.bytecode_optimize_level_zero = False - policy.bytecode_optimize_level_two = True - - python_config = dist.make_python_interpreter_config() - - # detected libs do not need this, but we add extra afterwards - python_config.module_search_paths = ["$ORIGIN/lib"] - python_config.optimization_level = 2 - - python_config.run_command = "import aqt; aqt.run()" - - exe = dist.to_python_executable( - name="anki", - packaging_policy=policy, - config=python_config, - ) - - exe.windows_runtime_dlls_mode = "always" - - # set in main.rs - exe.windows_subsystem = "console" - - resources = exe.read_virtualenv(VARS.get("venv")) - exe.add_python_resources(resources) - - return exe - - -def make_embedded_resources(exe): - return exe.to_embedded_resources() - - -def make_install(exe): - files = FileManifest() - files.add_python_resource(".", exe) - return files - - -register_target("exe", make_exe) -register_target( - "resources", make_embedded_resources, depends=["exe"], default_build_script=True -) -register_target("install", make_install, depends=["exe"], default=True) -resolve_targets() diff --git a/qt/bundle/qt.exclude b/qt/bundle/qt.exclude deleted file mode 100644 index e5a6f252b..000000000 --- a/qt/bundle/qt.exclude +++ /dev/null @@ -1,10 +0,0 @@ -qml -bindings -uic -lupdate -qsci -*.pyc -*.pyi -*.sip -py.typed -__pycache__ diff --git a/qt/bundle/src/anki.rs b/qt/bundle/src/anki.rs deleted file mode 100644 index 3cf960028..000000000 --- a/qt/bundle/src/anki.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -pub(super) fn init() { - #[cfg(target_os = "windows")] - attach_console(); - - println!("Anki starting..."); -} - -/// If parent process has a console (eg cmd.exe), redirect our output there. -#[cfg(target_os = "windows")] -fn attach_console() { - use std::ffi::CString; - - use libc_stdhandle::*; - use winapi::um::wincon; - - let console_attached = unsafe { wincon::AttachConsole(wincon::ATTACH_PARENT_PROCESS) }; - if console_attached == 0 { - return; - } - - let conin = CString::new("CONIN$").unwrap(); - let conout = CString::new("CONOUT$").unwrap(); - let r = CString::new("r").unwrap(); - let w = CString::new("w").unwrap(); - - // Python uses the CRT for I/O, and it requires the descriptors are reopened. - unsafe { - libc::freopen(conin.as_ptr(), r.as_ptr(), stdin()); - libc::freopen(conout.as_ptr(), w.as_ptr(), stdout()); - libc::freopen(conout.as_ptr(), w.as_ptr(), stderr()); - } -} diff --git a/qt/bundle/src/main.rs b/qt/bundle/src/main.rs deleted file mode 100644 index d424d4f26..000000000 --- a/qt/bundle/src/main.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Based off PyOxidizer's 'init-rust-project'. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#![windows_subsystem = "windows"] - -mod anki; - -use pyembed::{MainPythonInterpreter, OxidizedPythonInterpreterConfig}; - -#[cfg(feature = "global-allocator-jemalloc")] -#[global_allocator] -static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; - -include!(env!("DEFAULT_PYTHON_CONFIG_RS")); - -fn main() { - anki::init(); - - let exit_code = { - let config: OxidizedPythonInterpreterConfig = default_python_config(); - match MainPythonInterpreter::new(config) { - Ok(interp) => interp.run(), - Err(msg) => { - eprintln!("error instantiating embedded Python interpreter: {}", msg); - 1 - } - } - }; - std::process::exit(exit_code); -}