Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anki: 2.1.15 -> 2.1.60 #221229

Merged
merged 3 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,849 changes: 4,849 additions & 0 deletions pkgs/games/anki/Cargo.lock

Large diffs are not rendered by default.

378 changes: 222 additions & 156 deletions pkgs/games/anki/default.nix

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions pkgs/games/anki/no-version-check.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 53740ca75d167fab5c403a462e21ecd717b1dafa Mon Sep 17 00:00:00 2001
From: Euan Kemp <[email protected]>
Date: Fri, 17 Mar 2023 22:38:04 +0900
Subject: [PATCH 1/2] Don't download nodejs if NODE_BINARY is set

Some build environments, such as nixpkgs, restrict network access and
thus would prefer to not download anything at all. Setting PROTOC_BINARY
and friends makes the build system not download stuff, and the same
should be true for nodejs
---
build/ninja_gen/src/node.rs | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/build/ninja_gen/src/node.rs b/build/ninja_gen/src/node.rs
index df05e149d..d08c7011e 100644
--- a/build/ninja_gen/src/node.rs
+++ b/build/ninja_gen/src/node.rs
@@ -105,16 +105,6 @@ pub fn setup_node(
binary_exports: &[&'static str],
mut data_exports: HashMap<&str, Vec<Cow<str>>>,
) -> Result<()> {
- download_and_extract(
- build,
- "node",
- archive,
- hashmap! {
- "bin" => vec![if cfg!(windows) { "node.exe" } else { "bin/node" }],
- "npm" => vec![if cfg!(windows) { "npm.cmd " } else { "bin/npm" }]
- },
- )?;
-
let node_binary = match std::env::var("NODE_BINARY") {
Ok(path) => {
assert!(
@@ -124,6 +114,15 @@ pub fn setup_node(
path.into()
}
Err(_) => {
+ download_and_extract(
+ build,
+ "node",
+ archive,
+ hashmap! {
+ "bin" => vec![if cfg!(windows) { "node.exe" } else { "bin/node" }],
+ "npm" => vec![if cfg!(windows) { "npm.cmd " } else { "bin/npm" }]
+ },
+ )?;
inputs![":extract:node:bin"]
}
};
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 16af7d4cabcf10797bd110c905a9d7694bde0fb4 Mon Sep 17 00:00:00 2001
From: Euan Kemp <[email protected]>
Date: Fri, 17 Mar 2023 23:07:05 +0900
Subject: [PATCH 2/2] Allow setting YARN_BINARY for the build system

---
build/ninja_gen/src/node.rs | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/build/ninja_gen/src/node.rs b/build/ninja_gen/src/node.rs
index d08c7011e..c1e2ce1b3 100644
--- a/build/ninja_gen/src/node.rs
+++ b/build/ninja_gen/src/node.rs
@@ -129,7 +129,18 @@ pub fn setup_node(
let node_binary = build.expand_inputs(node_binary);
build.variable("node_binary", &node_binary[0]);

- build.add("yarn", YarnSetup {})?;
+ match std::env::var("YARN_BINARY") {
+ Ok(path) => {
+ assert!(
+ Utf8Path::new(&path).is_absolute(),
+ "YARN_BINARY must be absolute"
+ );
+ build.add_resolved_files_to_group("yarn:bin", &vec![path]);
+ },
+ Err(_) => {
+ build.add("yarn", YarnSetup {})?;
+ },
+ };

for binary in binary_exports {
data_exports.insert(
--
2.39.2

31 changes: 31 additions & 0 deletions pkgs/games/anki/patches/0003-Skip-formatting-python-code.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From ed5090b237bca768dbf7dfc3b4414b955879f15e Mon Sep 17 00:00:00 2001
From: Euan Kemp <[email protected]>
Date: Fri, 7 Apr 2023 20:22:34 +0900
Subject: [PATCH 3/3] Skip formatting python code

---
pylib/tools/hookslib.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pylib/tools/hookslib.py b/pylib/tools/hookslib.py
index 6361c633e..95ecb64a2 100644
--- a/pylib/tools/hookslib.py
+++ b/pylib/tools/hookslib.py
@@ -82,7 +82,7 @@ class Hook:
code = f"""\
class {self.classname()}:
{classdoc}{self.list_code()}
-
+
def append(self, callback: {self.callable()}) -> None:
'''{appenddoc}'''
self._hooks.append(callback)
@@ -208,4 +208,4 @@ def write_file(path: str, hooks: list[Hook], prefix: str, suffix: str):
os.environ["USERPROFILE"] = os.environ["HOME"]
with open(path, "wb") as file:
file.write(code.encode("utf8"))
- subprocess.run([sys.executable, "-m", "black", "-q", path], check=True)
+ # subprocess.run([sys.executable, "-m", "black", "-q", path], check=True)
--
2.39.2

17 changes: 17 additions & 0 deletions pkgs/games/anki/patches/gl-fixup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py
index 352848cfd..3fd5d0769 100644
--- a/qt/aqt/__init__.py
+++ b/qt/aqt/__init__.py
@@ -402,12 +402,6 @@ def parseArgs(argv: list[str]) -> tuple[argparse.Namespace, list[str]]:
def setupGL(pm: aqt.profiles.ProfileManager) -> None:
driver = pm.video_driver()

- # work around pyqt loading wrong GL library
- if is_lin:
- import ctypes
-
- ctypes.CDLL("libGL.so.1", ctypes.RTLD_GLOBAL)
-
# catch opengl errors
def msgHandler(category: Any, ctx: Any, msg: Any) -> None:
if category == QtMsgType.QtDebugMsg:
13 changes: 13 additions & 0 deletions pkgs/games/anki/patches/no-update-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/qt/aqt/main.py b/qt/aqt/main.py
index 0f2764f66..c42a88402 100644
--- a/qt/aqt/main.py
+++ b/qt/aqt/main.py
@@ -1395,6 +1395,8 @@ title="{}" {}>{}</button>""".format(
##########################################################################

def setupAutoUpdate(self) -> None:
+ # nixpkgs patch; updates are managed by nix
+ return
import aqt.update

self.autoUpdate = aqt.update.LatestVersionFinder(self)
19 changes: 10 additions & 9 deletions pkgs/servers/ankisyncd/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ lib
, fetchFromGitHub
, python3
, anki
}:

python3.pkgs.buildPythonApplication rec {
Expand All @@ -11,7 +10,8 @@ python3.pkgs.buildPythonApplication rec {
owner = "ankicommunity";
repo = "anki-sync-server";
rev = version;
sha256 = "196xhd6vzp1ncr3ahz0bv0gp1ap2s37j8v48dwmvaywzayakqdab";
hash = "sha256-RXrdJGJ+HMSpDGQBuVPPqsh3+uwAgE6f7ZJ0yFRMI8I=";
fetchSubmodules = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

anki-sync-server 2.4.0 still requires anki from pypi, so it's not going to be a straightforward change (and the update isn't as simple as bumping the version number)

The current discussion seems to favor just getting rid of this flavor of ankisyncd in favor of the rust one (being discussed in #224366 ) so I'd say to just not touch ankisyncd here more than we have to for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, as discussed in #224366 and previously in this pr, I don't think it's worth updating it (nor is it easy to do so).
I'm just trying to leave it functioning at all since this PR would otherwise break it, and then we can deal with it separately

};
format = "other";

Expand All @@ -21,14 +21,15 @@ python3.pkgs.buildPythonApplication rec {
mkdir -p $out/${python3.sitePackages}

cp -r ankisyncd utils ankisyncd.conf $out/${python3.sitePackages}
cp -r anki-bundled/anki $out/${python3.sitePackages}
mkdir $out/share
cp ankisyncctl.py $out/share/

runHook postInstall
'';

fixupPhase = ''
PYTHONPATH="$PYTHONPATH:$out/${python3.sitePackages}:${anki}"
PYTHONPATH="$PYTHONPATH:$out/${python3.sitePackages}"

makeWrapper "${python3.interpreter}" "$out/bin/ankisyncd" \
--set PYTHONPATH $PYTHONPATH \
Expand All @@ -46,14 +47,14 @@ python3.pkgs.buildPythonApplication rec {

buildInputs = [ ];

propagatedBuildInputs = [ anki ];
propagatedBuildInputs = with python3.pkgs; [
decorator
requests
];

checkPhase = ''
# Exclude tests that require sqlite's sqldiff command, since
# it isn't yet packaged for NixOS, although 2 PRs exist:
# - https://github.com/NixOS/nixpkgs/pull/69112
# - https://github.com/NixOS/nixpkgs/pull/75784
# Once this is merged, these tests can be run as well.
# skip these tests, our files are too young:
# tests/test_web_media.py::SyncAppFunctionalMediaTest::test_sync_mediaChanges ValueError: ZIP does not support timestamps before 1980
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://nixos.org/manual/nixpkgs/unstable/#python-setup.py-bdist_wheel-cannot-create-.whl

You can set SOURCE_DATE_EPOCH = 315532800; to workaround.

Copy link
Member Author

@euank euank Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just setting that wasn't enough, the test still has the same error.

I'm pretty inclined to not spend any more time on this since I'm hoping to delete that package pretty soon anyway (in favor of the rust sync server)

pytest --ignore tests/test_web_media.py tests/
'';

Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35572,7 +35572,7 @@ with pkgs;

angband = callPackage ../games/angband { };

anki = python39Packages.callPackage ../games/anki {
anki = callPackage ../games/anki {
inherit (darwin.apple_sdk.frameworks) CoreAudio;
};
anki-bin = callPackage ../games/anki/bin.nix { buildFHSUserEnv = buildFHSUserEnvBubblewrap; };
Expand Down