Github messages for voidlinux
 help / color / mirror / Atom feed
From: fosslinux <fosslinux@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] WIP: anki: update to 2.1.26
Date: Sat, 30 May 2020 03:53:04 +0200	[thread overview]
Message-ID: <20200530015304.IP3WqiKGhU8tOV0pclrBaNLd7esnPdpKrXCDbC3ZhxE@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22219@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]

There is an updated pull request by fosslinux against master on the void-packages repository

https://github.com/fosslinux/void-packages anki-2.1.26
https://github.com/void-linux/void-packages/pull/22219

WIP: anki: update to 2.1.26
This has a wide variety of changes as if you have heard my ranting in #xbps it has turned into a Bad Build System - there is rust (nightly!), nodejs, python, etc etc, no proper install target...

A few things to note:

- python3-mypy is updated as mypy-protobuf needs the new version, otherwise the build failed.
- same thing with python-protobuf, but for anki and at runtime
- maturin is some weird build system at the intersection of rust and python.
- mypy-protobuf-python is what anki uses for binding python and rust together, partly.
- mypy-protobuf-go is the go implementation of mypy-protobuf-python that I thought should be packaged anywway.
- python-stringcase is a new dependency.
- anki is an archd package (not nocross), because the rust code is obviously platform specific.
- anki uses rustup. This is because it and some of its dependencies require archd code (notably pyo3). This is unavoidable, afaict.

Still todo:

- [x] Apply archlinux's aqt_build patch, which stops it from polluting /usr directly (:vomiting_face:)
- [x] Update python3-protobuf - hopefully will fix `AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'`.
- [ ] Look into travis musl error. https://github.com/rust-lang/rust/issues/40174. Hopefully, using rust 1.44 as the rust version *should* fix this. What a PITA. I understand that this is because it works when I cross-compile to x86_64-musl from x86_64 but we need it to work native build from x86_64-musl for the builders...
- [ ] Travis wth on i686?
- [x] Make it open.
- [ ] More extensive runtime testing.
- [ ] Runtime test on musl.

Questions:

- Is there any problems with removing `arch=nocross`?
- Does the rustup stuff look (somewhat) sane?
- Are the patches sane?

A patch file from https://github.com/void-linux/void-packages/pull/22219.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-anki-2.1.26-22219.patch --]
[-- Type: text/x-diff, Size: 31713 bytes --]

From 78816216511379aa1b82f106aeffe9266c10ca18 Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sun, 24 May 2020 15:37:00 +1000
Subject: [PATCH 1/7] python-protobuf: update to 3.12.1

---
 srcpkgs/python-protobuf/template | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/srcpkgs/python-protobuf/template b/srcpkgs/python-protobuf/template
index 1a2d37a0a1e..a96fd539894 100644
--- a/srcpkgs/python-protobuf/template
+++ b/srcpkgs/python-protobuf/template
@@ -1,19 +1,19 @@
 # Template file for 'python-protobuf'
 pkgname=python-protobuf
-version=3.10.0
-revision=2
+version=3.12.1
+revision=1
 archs=noarch
 wrksrc="protobuf-${version}"
+build_wrksrc="python"
 build_style=python-module
-pycompile_module="google/protobuf"
-hostmakedepends="python-setuptools python3-setuptools"
+hostmakedepends="python-setuptools python3-setuptools protobuf"
 depends="python-setuptools python-six"
 short_desc="Python2 bindings for Google Protocol Buffers"
 maintainer="Charles E. Lehner <cel@celehner.com>"
 license="BSD-3-Clause"
 homepage="https://developers.google.com/protocol-buffers/"
-distfiles="${PYPI_SITE}/p/protobuf/protobuf-${version}.tar.gz"
-checksum=db83b5c12c0cd30150bb568e6feb2435c49ce4e68fe2d7b903113f0e221e58fe
+distfiles="https://github.com/protocolbuffers/protobuf/archive/v${version}.tar.gz"
+checksum=cb9b3f9d625b5739a358268eb3421de11cacd90025f5f7672c3930553eca810e
 
 post_install() {
 	sed -n 1,29p google/protobuf/__init__.py >LICENSE
@@ -22,7 +22,6 @@ post_install() {
 
 python3-protobuf_package() {
 	archs=noarch
-	pycompile_module="google/protobuf"
 	depends="python3-setuptools python3-six"
 	short_desc="${short_desc/Python2/Python3}"
 	pkg_install() {

From 7712eb76d5743a2c0c3d75747bc3ea0f5f2e4e0b Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:33:01 +1000
Subject: [PATCH 2/7] python3-mypy: update to 0.770, claim maintainership

---
 srcpkgs/python3-mypy/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/python3-mypy/template b/srcpkgs/python3-mypy/template
index 5d7f93d5772..bde1e7f4be6 100644
--- a/srcpkgs/python3-mypy/template
+++ b/srcpkgs/python3-mypy/template
@@ -1,19 +1,18 @@
 # Template file for 'python3-mypy'
 pkgname=python3-mypy
-version=0.761
+version=0.770
 revision=1
 archs=noarch
 wrksrc="mypy-${version}"
 build_style=python3-module
-pycompile_module="mypy"
 hostmakedepends="python3-setuptools"
 depends="python3-mypy_extensions python3-typed-ast python3-typing_extensions"
 short_desc="Optional static typing for Python3"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="fosslinux <fosslinux@aussies.space>"
 license="MIT"
 homepage="https://github.com/python/mypy"
 distfiles="${PYPI_SITE}/m/mypy/mypy-${version}.tar.gz"
-checksum=85baab8d74ec601e86134afe2bcccd87820f79d2f8d5798c889507d1088287bf
+checksum=8a627507ef9b307b46a1fea9513d5c98680ba09591253082b4c48697ba05a4ae
 
 post_install() {
 	vlicense LICENSE

From 6efdf584b76652d8f2df4ea2130474e3b1576340 Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:34:38 +1000
Subject: [PATCH 3/7] New package: maturin-0.8.1

---
 .../patches/cross-compile-setup-py.patch      | 14 +++++++++++++
 srcpkgs/maturin/template                      | 21 +++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 srcpkgs/maturin/patches/cross-compile-setup-py.patch
 create mode 100644 srcpkgs/maturin/template

diff --git a/srcpkgs/maturin/patches/cross-compile-setup-py.patch b/srcpkgs/maturin/patches/cross-compile-setup-py.patch
new file mode 100644
index 00000000000..e57189cb7ab
--- /dev/null
+++ b/srcpkgs/maturin/patches/cross-compile-setup-py.patch
@@ -0,0 +1,14 @@
+--- setup.py	2020-04-30 22:36:01.000000000 +1000
++++ setup.py	2020-05-20 14:31:40.404994499 +1000
+@@ -56,9 +56,9 @@
+                     "(https://www.rust-lang.org/tools/install) and try again"
+                 )
+             subprocess.check_call(
+-                ["cargo", "rustc", "--bin", "maturin", "--", "-C", "link-arg=-s"]
++                ["cargo", "rustc", "--bin", "maturin", "--release", "--target", os.environ["RUST_TARGET"], "--", "-C", "link-arg=-s", "-C", "linker=" + os.environ["CC"].split(" ", 1)[0]]
+             )
+-            source = os.path.join(source_dir, "target", "debug", executable_name)
++            source = os.path.join(source_dir, "target", os.environ["RUST_TARGET"], "release", executable_name)
+         # run this after trying to build with cargo (as otherwise this leaves
+         # venv in a bad state: https://github.com/benfred/py-spy/issues/69)
+         install.run(self)
diff --git a/srcpkgs/maturin/template b/srcpkgs/maturin/template
new file mode 100644
index 00000000000..7eba36204f9
--- /dev/null
+++ b/srcpkgs/maturin/template
@@ -0,0 +1,21 @@
+# Template file for 'maturin'
+pkgname=maturin
+version=0.8.1
+revision=1
+build_style=python3-module
+hostmakedepends="cargo python3-setuptools python3-toml"
+makedepends="rust rust-std llvm9"
+short_desc="Build and publish crates with python bindings"
+maintainer="fosslinux <fosslinux@aussies.space>"
+license="Apache-2.0, MIT"
+homepage="https://github.com/PyO3/maturin"
+distfiles="https://github.com/PyO3/maturin/archive/v${version}.tar.gz"
+checksum=b72a9885cda3ba4e53906a43aab101acb790622218ade6405b2ddf1ef1461f8f
+
+post_install() {
+	# Dynamic detection of python version
+	PYTHON_VERSION=$(python3 --version | sed "s/^Python //" | rev | sed "s/^[0-9]*.//" | rev)
+	mkdir -p "${DESTDIR}/usr/lib/python${PYTHON_VERSION}/site-packages/"
+	mv "${DESTDIR}/maturin" "${DESTDIR}/usr/lib/python${PYTHON_VERSION}/site-packages/"
+	vlicense license-mit
+}

From bf0b313f13c558529acb46ef74b3841997b9d5d9 Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:35:25 +1000
Subject: [PATCH 4/7] New package: mypy-protobuf-python-1.13

---
 srcpkgs/mypy-protobuf-python/template | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 srcpkgs/mypy-protobuf-python/template

diff --git a/srcpkgs/mypy-protobuf-python/template b/srcpkgs/mypy-protobuf-python/template
new file mode 100644
index 00000000000..391d75f0c9e
--- /dev/null
+++ b/srcpkgs/mypy-protobuf-python/template
@@ -0,0 +1,23 @@
+# Template file for 'mypy-protobuf-python'
+#
+# WARNING: THIS TEMPLATE SHOULD BE SYNCRONISED WITH mypy-protobuf-go
+#
+pkgname=mypy-protobuf-python
+version=1.13
+revision=1
+wrksrc="mypy-protobuf-${version}"
+build_wrksrc=python
+build_style=python3-module
+hostmakedepends="python3-setuptools"
+depends="python3-mypy python3-typing_extensions python3-protobuf protobuf"
+short_desc="Generate mypy stubs from protobufs - Python implementation"
+maintainer="fosslinux <fosslinux@aussies.space>"
+license="Apache-2.0"
+homepage="https://github.com/dropbox/mypy-protobuf"
+distfiles="https://github.com/dropbox/mypy-protobuf/archive/v${version}.tar.gz"
+checksum=7d86dfc076f8b51814fbfd3a66998a0b570fd1b82ebeda68ae6728cd538adb74
+
+post_install() {
+	# We are not windows, remove the batch file
+	rm "${DESTDIR}/usr/bin/protoc_gen_mypy.bat"
+}

From 0e9530bdee8b9d76ea8bfd4e50087eac4294e2af Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:35:37 +1000
Subject: [PATCH 5/7] New package: mypy-protobuf-go-1.13

---
 .../patches/remote-go-improt.patch            | 11 +++++++++++
 srcpkgs/mypy-protobuf-go/template             | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 srcpkgs/mypy-protobuf-go/patches/remote-go-improt.patch
 create mode 100644 srcpkgs/mypy-protobuf-go/template

diff --git a/srcpkgs/mypy-protobuf-go/patches/remote-go-improt.patch b/srcpkgs/mypy-protobuf-go/patches/remote-go-improt.patch
new file mode 100644
index 00000000000..300504bc70d
--- /dev/null
+++ b/srcpkgs/mypy-protobuf-go/patches/remote-go-improt.patch
@@ -0,0 +1,11 @@
+--- go/src/protoc-gen-mypy/main.go.orig	2020-05-22 11:58:07.760761664 +1000
++++ go/src/protoc-gen-mypy/main.go	2020-05-22 11:58:00.595762190 +1000
+@@ -6,7 +6,7 @@
+ 	"sort"
+ 	"strings"
+ 
+-	"proto/mypy"
++	"github.com/dropbox/mypy-protobuf/go/src/proto/mypy"
+ 
+ 	"github.com/gogo/protobuf/proto"
+ 	"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
diff --git a/srcpkgs/mypy-protobuf-go/template b/srcpkgs/mypy-protobuf-go/template
new file mode 100644
index 00000000000..8f00e43d8a8
--- /dev/null
+++ b/srcpkgs/mypy-protobuf-go/template
@@ -0,0 +1,19 @@
+# Template file for 'mypy-protobuf-go'
+#
+# WARNING: THIS TEMPLATE SHOULD BE SYNCRONISED WITH mypy-protobuf-python
+#
+pkgname=mypy-protobuf-go
+version=1.13
+revision=1
+wrksrc="mypy-protobuf-${version}"
+build_style=go
+go_import_path="github.com/dropbox/mypy-protobuf"
+go_package="${go_import_path}/go/src/protoc-gen-mypy"
+hostmakedepends="git"
+depends="protobuf"
+short_desc="Generate mypy stubs from protobufs - go implementation"
+maintainer="fosslinux <fosslinux@aussies.space>"
+license="Apache-2.0"
+homepage="https://github.com/dropbox/mypy-protobuf"
+distfiles="https://github.com/dropbox/mypy-protobuf/archive/v${version}.tar.gz"
+checksum=7d86dfc076f8b51814fbfd3a66998a0b570fd1b82ebeda68ae6728cd538adb74

From 7dbe4213090b5647b997d079f3a7823e15cfba0d Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:33:36 +1000
Subject: [PATCH 6/7] New package: python-stringcase-1.2.0

---
 srcpkgs/python-stringcase/template | 28 ++++++++++++++++++++++++++++
 srcpkgs/python3-stringcase         |  1 +
 2 files changed, 29 insertions(+)
 create mode 100644 srcpkgs/python-stringcase/template
 create mode 120000 srcpkgs/python3-stringcase

diff --git a/srcpkgs/python-stringcase/template b/srcpkgs/python-stringcase/template
new file mode 100644
index 00000000000..849e677c784
--- /dev/null
+++ b/srcpkgs/python-stringcase/template
@@ -0,0 +1,28 @@
+# Template file for 'python-stringcase'
+pkgname=python-stringcase
+version=1.2.0
+revision=1
+wrksrc="stringcase-${version}"
+build_style=python-module
+hostmakedepends="python-devel python3-devel"
+makedepends="${hostmakedepends}"
+depends="python"
+short_desc="String case converter for Python2"
+maintainer="fosslinux <fosslinux@aussies.space>"
+license="MIT"
+homepage="https://github.com/okunishinishi/python-stringcase"
+distfiles="${PYPI_SITE}/s/stringcase/stringcase-${version}.tar.gz"
+checksum=48a06980661908efe8d9d34eab2b6c13aefa2163b3ced26972902e3bdfd87008
+
+post_install() {
+	vlicense LICENSE
+}
+
+python3-stringcase_package() {
+	depends="python3"
+	short_desc="${short_desc/Python2/Python3}"
+	pkg_install() {
+		vmove usr/lib/python3*
+		vlicense LICENSE
+	}
+}
diff --git a/srcpkgs/python3-stringcase b/srcpkgs/python3-stringcase
new file mode 120000
index 00000000000..53938bd1f0c
--- /dev/null
+++ b/srcpkgs/python3-stringcase
@@ -0,0 +1 @@
+python-stringcase
\ No newline at end of file

From 0100907ae5898f4915af97f93030dca784dc4909 Mon Sep 17 00:00:00 2001
From: fosslinux <fosslinux@aussies.space>
Date: Sat, 23 May 2020 14:36:21 +1000
Subject: [PATCH 7/7] anki: update to 2.1.26

Has turned into a Bad Build System. Now uses rust nightly, python
(with bindings!), qt5, nodejs... the list goes on. There are quite
a few hacks and the like.
---
 srcpkgs/anki/patches/aqt_data-fhs.patch       |  45 +++
 srcpkgs/anki/patches/rust-nightly-fix.patch   | 274 ++++++++++++++++++
 .../anki/patches/rustc-cross-compile.patch    |  11 +
 .../patches/update-rust-nightly-version.patch |   5 +
 srcpkgs/anki/patches/vendored-deps.patch      |  94 ++++++
 srcpkgs/anki/template                         |  57 +++-
 6 files changed, 479 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/anki/patches/aqt_data-fhs.patch
 create mode 100644 srcpkgs/anki/patches/rust-nightly-fix.patch
 create mode 100644 srcpkgs/anki/patches/rustc-cross-compile.patch
 create mode 100644 srcpkgs/anki/patches/update-rust-nightly-version.patch
 create mode 100644 srcpkgs/anki/patches/vendored-deps.patch

diff --git a/srcpkgs/anki/patches/aqt_data-fhs.patch b/srcpkgs/anki/patches/aqt_data-fhs.patch
new file mode 100644
index 00000000000..ac0d29ec082
--- /dev/null
+++ b/srcpkgs/anki/patches/aqt_data-fhs.patch
@@ -0,0 +1,45 @@
+From a0a9ac1aeb8b8678f1102aed81010a901ad8d9e1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Johannes=20L=C3=B6thberg?= <johannes@kyriasis.com>
+Date: Sun, 29 Mar 2020 06:24:43 +0200
+Subject: [PATCH 1/4] Move aqt_data to sys.prefix/share
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+These files do _not_ belong right under sys.prefix.
+
+Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
+---
+ qt/aqt/utils.py | 2 +-
+ qt/setup.py     | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git qt/aqt/utils.py qt/aqt/utils.py
+index a0e12362..4d8c8c34 100644
+--- qt/aqt/utils.py
++++ qt/aqt/utils.py
+@@ -21,7 +21,7 @@ from aqt.theme import theme_manager
+ 
+ def aqt_data_folder() -> str:
+     # wheel install?
+-    dir = os.path.join(sys.prefix, "aqt_data")
++    dir = os.path.join(sys.prefix,"share", "aqt_data")
+     if not os.path.exists(dir) or not os.listdir(dir):
+         # running in place?
+         dir = os.path.join(os.path.dirname(__file__), "..", "aqt_data")
+diff --git qt/setup.py qt/setup.py
+index 38f4e2b7..bdda3baa 100644
+--- qt/setup.py
++++ qt/setup.py
+@@ -8,7 +8,7 @@ import setuptools
+ def package_files(directory):
+     entries = []
+     for (path, directories, filenames) in os.walk(directory):
+-        entries.append((path, [os.path.join(path, f) for f in filenames]))
++        entries.append((os.path.join("share", path), [os.path.join(path, f) for f in filenames]))
+     return entries
+ 
+ 
+-- 
+2.26.2
+
diff --git a/srcpkgs/anki/patches/rust-nightly-fix.patch b/srcpkgs/anki/patches/rust-nightly-fix.patch
new file mode 100644
index 00000000000..3d70aa36aad
--- /dev/null
+++ b/srcpkgs/anki/patches/rust-nightly-fix.patch
@@ -0,0 +1,274 @@
+From fb578a0c2dc391f37de7cb6969c40f34d0de845c Mon Sep 17 00:00:00 2001
+From: Damien Elmes <gpg@ankiweb.net>
+Date: Fri, 24 Apr 2020 13:39:14 +1000
+Subject: [PATCH] switch to owned strings in ParsedTemplate
+
+will make it easier to cache the parsed results in the future,
+and handle field renames & other transformations
+---
+ rslib/src/notetype/cardgen.rs   |  6 +-
+ rslib/src/notetype/templates.rs |  2 +-
+ rslib/src/template.rs           | 98 +++++++++++++++++----------------
+ 3 files changed, 56 insertions(+), 50 deletions(-)
+
+Backported by fossy to stable. notetype patch is not needed.
+
+diff --git rslib/src/template.rs rslib/src/template.rs
+index 4479899009..ed5fe7e916 100644
+--- rslib/src/template.rs
++++ rslib/src/template.rs
+@@ -147,26 +147,26 @@ fn legacy_tokens(mut data: &str) -> impl Iterator<Item = TemplateResult<Token>>
+ //----------------------------------------
+ 
+ #[derive(Debug, PartialEq)]
+-enum ParsedNode<'a> {
+-    Text(&'a str),
++enum ParsedNode {
++    Text(String),
+     Replacement {
+-        key: &'a str,
+-        filters: Vec<&'a str>,
++        key: String,
++        filters: Vec<String>,
+     },
+     Conditional {
+-        key: &'a str,
+-        children: Vec<ParsedNode<'a>>,
++        key: String,
++        children: Vec<ParsedNode>,
+     },
+     NegatedConditional {
+-        key: &'a str,
+-        children: Vec<ParsedNode<'a>>,
++        key: String,
++        children: Vec<ParsedNode>,
+     },
+ }
+ 
+ #[derive(Debug)]
+-pub struct ParsedTemplate<'a>(Vec<ParsedNode<'a>>);
++pub struct ParsedTemplate(Vec<ParsedNode>);
+ 
+-impl ParsedTemplate<'_> {
++impl ParsedTemplate {
+     /// Create a template from the provided text.
+     pub fn from_text(template: &str) -> TemplateResult<ParsedTemplate> {
+         let mut iter = tokens(template);
+@@ -177,26 +177,26 @@ impl ParsedTemplate<'_> {
+ fn parse_inner<'a, I: Iterator<Item = TemplateResult<Token<'a>>>>(
+     iter: &mut I,
+     open_tag: Option<&'a str>,
+-) -> TemplateResult<Vec<ParsedNode<'a>>> {
++) -> TemplateResult<Vec<ParsedNode>> {
+     let mut nodes = vec![];
+ 
+     while let Some(token) = iter.next() {
+         use Token::*;
+         nodes.push(match token? {
+-            Text(t) => ParsedNode::Text(t),
++            Text(t) => ParsedNode::Text(t.into()),
+             Replacement(t) => {
+                 let mut it = t.rsplit(':');
+                 ParsedNode::Replacement {
+-                    key: it.next().unwrap(),
+-                    filters: it.collect(),
++                    key: it.next().unwrap().into(),
++                    filters: it.map(Into::into).collect(),
+                 }
+             }
+             OpenConditional(t) => ParsedNode::Conditional {
+-                key: t,
++                key: t.into(),
+                 children: parse_inner(iter, Some(t))?,
+             },
+             OpenNegated(t) => ParsedNode::NegatedConditional {
+-                key: t,
++                key: t.into(),
+                 children: parse_inner(iter, Some(t))?,
+             },
+             CloseConditional(t) => {
+@@ -285,27 +285,27 @@ fn localized_template_error(i18n: &I18n, err: TemplateError) -> String {
+ // Checking if template is empty
+ //----------------------------------------
+ 
+-impl ParsedTemplate<'_> {
++impl ParsedTemplate {
+     /// true if provided fields are sufficient to render the template
+     pub fn renders_with_fields(&self, nonempty_fields: &HashSet<&str>) -> bool {
+         !template_is_empty(nonempty_fields, &self.0)
+     }
+ }
+ 
+-fn template_is_empty<'a>(nonempty_fields: &HashSet<&str>, nodes: &[ParsedNode<'a>]) -> bool {
++fn template_is_empty(nonempty_fields: &HashSet<&str>, nodes: &[ParsedNode]) -> bool {
+     use ParsedNode::*;
+     for node in nodes {
+         match node {
+             // ignore normal text
+             Text(_) => (),
+             Replacement { key, .. } => {
+-                if nonempty_fields.contains(*key) {
++                if nonempty_fields.contains(key.as_str()) {
+                     // a single replacement is enough
+                     return false;
+                 }
+             }
+             Conditional { key, children } => {
+-                if !nonempty_fields.contains(*key) {
++                if !nonempty_fields.contains(key.as_str()) {
+                     continue;
+                 }
+                 if !template_is_empty(nonempty_fields, children) {
+@@ -347,7 +347,7 @@ pub(crate) struct RenderContext<'a> {
+     pub card_ord: u16,
+ }
+ 
+-impl ParsedTemplate<'_> {
++impl ParsedTemplate {
+     /// Render the template with the provided fields.
+     ///
+     /// Replacements that use only standard filters will become part of
+@@ -373,10 +373,7 @@ fn render_into(
+             Text(text) => {
+                 append_str_to_nodes(rendered_nodes, text);
+             }
+-            Replacement {
+-                key: key @ "FrontSide",
+-                ..
+-            } => {
++            Replacement { key, .. } if key == "FrontSide" => {
+                 // defer FrontSide rendering to Python, as extra
+                 // filters may be required
+                 rendered_nodes.push(RenderedNode::Replacement {
+@@ -385,27 +382,36 @@ fn render_into(
+                     current_text: "".into(),
+                 });
+             }
+-            Replacement { key: "", filters } if !filters.is_empty() => {
++            Replacement { key, filters } if key == "" && !filters.is_empty() => {
+                 // if a filter is provided, we accept an empty field name to
+                 // mean 'pass an empty string to the filter, and it will add
+                 // its own text'
+                 rendered_nodes.push(RenderedNode::Replacement {
+                     field_name: "".to_string(),
+                     current_text: "".to_string(),
+-                    filters: filters.iter().map(|&f| f.to_string()).collect(),
++                    filters: filters.clone(),
+                 })
+             }
+             Replacement { key, filters } => {
+                 // apply built in filters if field exists
+-                let (text, remaining_filters) = match context.fields.get(key) {
+-                    Some(text) => apply_filters(text, filters, key, context),
++                let (text, remaining_filters) = match context.fields.get(key.as_str()) {
++                    Some(text) => apply_filters(
++                        text,
++                        filters
++                            .iter()
++                            .map(|s| s.as_str())
++                            .collect::<Vec<_>>()
++                            .as_slice(),
++                        key,
++                        context,
++                    ),
+                     None => {
+                         // unknown field encountered
+                         let filters_str = filters
+                             .iter()
+                             .rev()
+                             .cloned()
+-                            .chain(iter::once(""))
++                            .chain(iter::once("".into()))
+                             .collect::<Vec<_>>()
+                             .join(":");
+                         return Err(TemplateError::FieldNotFound {
+@@ -427,12 +433,12 @@ fn render_into(
+                 }
+             }
+             Conditional { key, children } => {
+-                if context.nonempty_fields.contains(key) {
++                if context.nonempty_fields.contains(key.as_str()) {
+                     render_into(rendered_nodes, children.as_ref(), context)?;
+                 }
+             }
+             NegatedConditional { key, children } => {
+-                if !context.nonempty_fields.contains(key) {
++                if !context.nonempty_fields.contains(key.as_str()) {
+                     render_into(rendered_nodes, children.as_ref(), context)?;
+                 }
+             }
+@@ -542,7 +548,7 @@ pub enum FieldRequirements {
+     None,
+ }
+ 
+-impl ParsedTemplate<'_> {
++impl ParsedTemplate {
+     /// Return fields required by template.
+     ///
+     /// This is not able to represent negated expressions or combinations of
+@@ -613,11 +619,11 @@
+             vec![
+-                Text("foo "),
++                Text("foo ".into()),
+                 Replacement {
+-                    key: "bar",
++                    key: "bar".into(),
+                     filters: vec![]
+                 },
+-                Text(" "),
++                Text(" ".into()),
+                 Conditional {
+-                    key: "baz",
+-                    children: vec![Text(" quux ")]
++                    key: "baz".into(),
++                    children: vec![Text(" quux ".into())]
+                 }
+             ]
+@@ -630,7 +636,7 @@ mod test {
+         assert_eq!(
+             tmpl.0,
+             vec![NegatedConditional {
+-                key: "baz",
++                key: "baz".into(),
+                 children: vec![]
+             }]
+         );
+@@ -643,7 +649,7 @@ mod test {
+         assert_eq!(
+             PT::from_text("{{ tag }}").unwrap().0,
+             vec![Replacement {
+-                key: "tag",
++                key: "tag".into(),
+                 filters: vec![]
+             }]
+         );
+@@ -651,7 +657,7 @@ mod test {
+         // stray closing characters (like in javascript) are ignored
+         assert_eq!(
+             PT::from_text("text }} more").unwrap().0,
+-            vec![Text("text }} more")]
++            vec![Text("text }} more".into())]
+         );
+ 
+         PT::from_text("{{").unwrap_err();
+@@ -737,15 +743,15 @@ mod test {
+         assert_eq!(
+             PT::from_text(input).unwrap().0,
+             vec![
+-                Text("\n"),
++                Text("\n".into()),
+                 Replacement {
+-                    key: "Front",
++                    key: "Front".into(),
+                     filters: vec![]
+                 },
+-                Text("\n"),
++                Text("\n".into()),
+                 Conditional {
+-                    key: "Back",
+-                    children: vec![Text("\n")]
++                    key: "Back".into(),
++                    children: vec![Text("\n".into())]
+                 }
+             ]
+         );
diff --git a/srcpkgs/anki/patches/rustc-cross-compile.patch b/srcpkgs/anki/patches/rustc-cross-compile.patch
new file mode 100644
index 00000000000..15239ea4cf1
--- /dev/null
+++ b/srcpkgs/anki/patches/rustc-cross-compile.patch
@@ -0,0 +1,11 @@
+--- rspy/Makefile	2020-05-23 12:02:29.758286838 +1000
++++ rspy/Makefile	2020-05-08 18:17:57.000000000 +1000
+@@ -69,7 +69,7 @@
+ .build/build: $(DEPS)
+ 	touch ../proto/backend.proto
+ 	${BUILD_VARIABLES} \
+-		maturin build -i "${PYTHON_FILE}" -o "$(OUTDIR)" $(BUILDFLAGS)
++		maturin build -i "${PYTHON_FILE}" -o "$(OUTDIR)" $(BUILDFLAGS) --target $(RUST_TARGET)
+    touch $@
+ 
+ check: .build/check
diff --git a/srcpkgs/anki/patches/update-rust-nightly-version.patch b/srcpkgs/anki/patches/update-rust-nightly-version.patch
new file mode 100644
index 00000000000..51e8afa7cf0
--- /dev/null
+++ b/srcpkgs/anki/patches/update-rust-nightly-version.patch
@@ -0,0 +1,5 @@
+--- rspy/rust-toolchain	2020-05-24 08:54:25.130010169 +1000
++++ rspy/rust-toolchain	2020-05-24 18:02:34.496636771 +1000
+@@ -1 +1 @@
+-nightly-2020-02-27
++nightly-2020-05-15
diff --git a/srcpkgs/anki/patches/vendored-deps.patch b/srcpkgs/anki/patches/vendored-deps.patch
new file mode 100644
index 00000000000..1d2bc90ffb1
--- /dev/null
+++ b/srcpkgs/anki/patches/vendored-deps.patch
@@ -0,0 +1,94 @@
+diff -u -r Makefile Makefile
+--- Makefile	2020-05-08 18:17:57.000000000 +1000
++++ Makefile	2020-05-19 18:40:54.345223164 +1000
+@@ -92,7 +92,7 @@
+ 	fi
+ 
+ .PHONY: develop
+-develop: pyenv buildhash prepare
++develop: buildhash prepare
+ 	@set -eu -o pipefail ${SHELLFLAGS}; \
+ 	. "${ACTIVATE_SCRIPT}"; \
+ 	for dir in $(DEVEL); do \
+diff -u -r pylib/Makefile pylib/Makefile
+--- pylib/Makefile	2020-05-08 18:17:57.000000000 +1000
++++ pylib/Makefile	2020-05-19 18:50:01.075182994 +1000
+@@ -52,7 +52,7 @@
+ 	python -m black anki/hooks.py
+ 	@touch $@
+ 
+-BUILD_STEPS := .build/vernum .build/run-deps .build/dev-deps .build/py-proto anki/buildinfo.py .build/hooks
++BUILD_STEPS := .build/vernum .build/py-proto anki/buildinfo.py .build/hooks
+ 
+ # Checking
+ ######################
+diff -u -r qt/Makefile qt/Makefile
+--- qt/Makefile	2020-05-08 18:17:57.000000000 +1000
++++ qt/Makefile	2020-05-19 18:50:17.520181786 +1000
+@@ -64,7 +64,7 @@
+ 	python -m black aqt/gui_hooks.py
+ 	@touch $@
+ 
+-BUILD_STEPS := .build/vernum .build/run-deps .build/dev-deps .build/js .build/ui aqt/buildinfo.py .build/hooks .build/i18n
++BUILD_STEPS := .build/vernum .build/js .build/ui aqt/buildinfo.py .build/hooks .build/i18n
+ 
+ # Checking
+ ######################
+--- Makefile	2020-05-08 18:17:57.000000000 +1000
++++ Makefile	2020-05-19 19:01:35.602131965 +1000
+@@ -122,7 +122,7 @@
+ 	@echo "Build complete."
+ 
+ .PHONY: build-rspy
+-build-rspy: pyenv buildhash
++build-rspy: buildhash
+ 	@set -eu -o pipefail ${SHELLFLAGS}; \
+ 	. "${ACTIVATE_SCRIPT}"; \
+ 	$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
+--- Makefile	2020-05-19 19:41:44.191955000 +1000
++++ Makefile	2020-05-19 19:42:21.423952264 +1000
+@@ -124,19 +124,16 @@
+ .PHONY: build-rspy
+ build-rspy: buildhash
+ 	@set -eu -o pipefail ${SHELLFLAGS}; \
+-	. "${ACTIVATE_SCRIPT}"; \
+ 	$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
+ 
+ .PHONY: build-pylib
+ build-pylib:
+ 	@set -eu -o pipefail ${SHELLFLAGS}; \
+-	. "${ACTIVATE_SCRIPT}"; \
+ 	$(SUBMAKE) -C pylib build
+ 
+ .PHONY: build-qt
+ build-qt:
+ 	@set -eu -o pipefail ${SHELLFLAGS}; \
+-	. "${ACTIVATE_SCRIPT}"; \
+ 	$(SUBMAKE) -C qt build
+ 
+ .PHONY: clean
+--- rspy/Makefile	2020-05-21 20:06:35.945720983 +1000
++++ rspy/Makefile	2020-05-21 20:07:54.295720504 +1000
+@@ -86,10 +86,10 @@
+ RUST_TOOLCHAIN := $(shell cat rust-toolchain)
+ 
+ .build/tools: requirements.txt rust-toolchain
+-	python -m pip install -r requirements.txt
+ 	rustup toolchain install $(RUST_TOOLCHAIN)
+ 	rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
+ 	rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)
++	rustup target add $(RUST_TARGET)
+ 	@touch $@
+ 
+ # we should not call clippy because it break things when running make check Mac OS
+--- pylib/Makefile	2020-05-22 08:46:14.988607539 +1000
++++ pylib/Makefile	2020-05-22 08:46:38.376605821 +1000
+@@ -41,7 +41,7 @@
+ 
+ PROTODEPS := $(wildcard ../proto/*.proto)
+ 
+-.build/py-proto: .build/dev-deps $(PROTODEPS)
++.build/py-proto: $(PROTODEPS)
+ 	protoc --proto_path=../proto --python_out=anki --mypy_out=anki $(PROTODEPS)
+ 	perl -i'' -pe 's/from fluent_pb2/from anki.fluent_pb2/' anki/backend_pb2.pyi
+ 	perl -i'' -pe 's/import fluent_pb2/import anki.fluent_pb2/' anki/backend_pb2.py
diff --git a/srcpkgs/anki/template b/srcpkgs/anki/template
index 680e008a9d4..ebc5fa6b333 100644
--- a/srcpkgs/anki/template
+++ b/srcpkgs/anki/template
@@ -1,23 +1,66 @@
 # Template file for 'anki'
 pkgname=anki
-version=2.1.15
-revision=2
-archs=noarch
+version=2.1.26
+revision=1
 build_style=gnu-makefile
 pycompile_dirs="/usr/share/anki/anki /usr/share/anki/aqt"
+# rustup: anki needs nightly ... :(
+hostmakedepends="git python3 rustup maturin which protobuf
+ mypy-protobuf-python python3-stringcase black python3-wheel
+ rsync nodejs python3-PyQt5-devel-tools gettext
+qt5-translations python3-pip strace"
 depends="python3-PyQt5-webengine python3-requests python3-SQLAlchemy
  python3-PyAudio python3-mpv python3-Markdown python3-send2trash
- python3-BeautifulSoup4 python3-decorator python3-jsonschema"
+ python3-BeautifulSoup4 python3-decorator python3-jsonschema
+ python3-protobuf"
 short_desc="Spaced repetition flashcard program"
 maintainer="Steve Prybylski <sa.prybylx@gmail.com>"
 license="AGPL-3.0-or-later"
 homepage="https://apps.ankiweb.net"
 changelog="https://apps.ankiweb.net/docs/changes.html"
-distfiles="https://apps.ankiweb.net/downloads/current/anki-${version}-source.tgz"
-checksum=5a53760164c77d619f55107a13099cffe620566a7f610b61b6c4b52487f3bb89
-
+distfiles="https://github.com/ankitects/anki/archive/${version}.tar.gz"
+checksum=f5a0c41f3eebe0e77de9d46f2a5cbbe20f7c3a4787f0f02e1d33f298428acbdf
 python_version=3
 
+# When a non-clean masterdir is used, rust is often left over from a
+# previous rust-enabled build. Unfortunatly, xbps-src dosen't seem
+# to clean out rust -.- So, use /usr/rustup, to avoid this issue.
+export PATH=/usr/rustup/bin:${PATH}
+export LD_LIBRARY_PATH=/usr/rustup/lib:${LD_LIBRARY_PATH}
+export CARGO_HOME="${wrksrc}/rustup"
+export RUSTUP_HOME="${wrksrc}/rustup"
+
+pre_configure() {
+	printf "1\\n" | rustup-init -y
+}
+
+pre_build() {
+	mkdir -p dist
+	make prepare
+}
+
+do_build() {
+	RUSTFLAGS="-C target-feature=-crt-static" make build
+}
+
+do_install() {
+	pushd pylib
+		 python3 setup.py install --prefix=/usr --root=${DESTDIR}
+	popd
+
+	pushd qt
+		 python3 setup.py install --prefix=/usr --root=${DESTDIR}
+	popd
+
+	# maturin generates a .whl, this is all we can do
+	PIP_CONFIG_FILE=/dev/null pip3 install --isolated --root=${DESTDIR} --prefix=/usr --ignore-installed --no-deps dist/ankirspy*.whl
+
+	# Copied from arch's PKGBUILD
+	install -Dm755 qt/runanki "${DESTDIR}/usr/bin/anki"
+	install -Dm644 qt/anki.desktop "${DESTDIR}/usr/share/applications/anki.desktop"
+	install -Dm644 qt/anki.png "${DESTDIR}/usr/share/pixmaps/anki.png"
+}
+
 post_install() {
 	vlicense LICENSE
 }

  parent reply	other threads:[~2020-05-30  1:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23  6:18 [PR PATCH] " fosslinux
2020-05-23  7:07 ` [PR PATCH] [Updated] " fosslinux
2020-05-24  5:37 ` fosslinux
2020-05-24  5:39 ` fosslinux
2020-05-28  7:38 ` [PR PATCH] [Updated] " fosslinux
2020-05-30  1:53 ` fosslinux [this message]
2020-06-01  9:58 ` fosslinux
2020-06-01  9:59 ` fosslinux
2020-06-01 10:05 ` [PR PATCH] [Updated] " fosslinux
2020-06-01 10:28 ` fosslinux
2020-06-01 12:05 ` stpx
2020-12-23  1:33 ` [PR PATCH] [Closed]: " fosslinux
2021-05-19 14:54 ` ericonr
2021-05-19 16:12 ` sgn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200530015304.IP3WqiKGhU8tOV0pclrBaNLd7esnPdpKrXCDbC3ZhxE@z \
    --to=fosslinux@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).