Project

General

Profile

Freedom issue #1426

[anki] depend on qt5-webengine

Elon_Satoshi - over 3 years ago - . Updated about 2 months ago.

Status:
in progress
Priority:
freedom issue
Assignee:
% Done:

0%


Description

$ sudo pacman -S anki
resolving dependencies...
warning: cannot resolve "qt5-webengine", a dependency of "anki" 
:: The following package cannot be upgraded due to unresolvable dependencies:
      anki
<pre>

I am currently installing it with --assume-installed qt5-webengine to see if it runs. If not, maybe we could compile it to run without qt5-webengine, and then remove the dependency.

Files

collection.apkg (651 KB) collection.apkg rfb, 2020-07-16 07:36 AM

Related issues

Related to Packages - Freedom issue #1167: [chromium][qt5-webengine][electron] QTWebgine/Electron embeds "entire Chromium platform"confirmed

Actions
Related to Packages - Packaging request #1830: Let's revert Anki to version 2.0.*fixed

Actions

History

#1

Updated by Elon_Satoshi over 3 years ago

Anki won't run without the qt5-webengine dependency

Traceback (most recent call last):
  File "/usr/bin/anki", line 6, in <module>
    import aqt
  File "/usr/share/anki/aqt/__init__.py", line 14, in <module>
    from aqt.qt import *
  File "/usr/share/anki/aqt/qt.py", line 17, in <module>
    from PyQt5.QtWebEngineWidgets import QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

I think it needs to be rebranded for Parabola. Maybe somebody could show me how to remove qt5-webengine from a python project.

#2

Updated by Elon_Satoshi about 3 years ago

Would it be possible to use qtwebkit instead of qtwebengine in Anki? How would I do that?

#3

Updated by isacdaavid about 3 years ago

  • Related to Freedom issue #1167: [chromium][qt5-webengine][electron] QTWebgine/Electron embeds "entire Chromium platform" added
#4

Updated by isacdaavid about 3 years ago

  • Assignee set to isacdaavid
  • Subject changed from [anki] depends on qt5-webengine to [anki][kalgebra][libkgapi][telepathy-kde-text-ui] depends on qt5-webengine

anki is just one of a handful of new packages that fail to install (let alone run) because of their dependency on qt5-webengine. since the blacklist has been called into question for its inclusion of qt5-webengine, I would rather go to the root of the problem (#1167) and find out whether I can solve it all there, before attempting to change affected packages like anki. so stay tuned.

#5

Updated by isacdaavid about 3 years ago

  • Priority changed from bug to freedom issue
  • Subject changed from [anki][kalgebra][libkgapi][telepathy-kde-text-ui] depends on qt5-webengine to [anki][kalgebra][libkgapi][telepathy-kde-text-ui][luminancehdr][pgadmin4][psi-plus-plugins] depend on qt5-webengine
#6

Updated by bill-auger over 1 year ago

  • Subject changed from [anki][kalgebra][libkgapi][telepathy-kde-text-ui][luminancehdr][pgadmin4][psi-plus-plugins] depend on qt5-webengine to [anki] depend on qt5-webengine
#7

Updated by bill-auger 12 months ago

#8

Updated by theova 9 months ago

Here is the discussion in Ankis Support page: [1]
There are already forks of anki without qt-webengine.

The more promising fork seems CCBC [2]. The problem is that it needs
qt4, which is no longer in the repositories... So I am not able to run it [3].

Meanwhile, Parabola has some alternatives [4].

[1]: https://anki.tenderapp.com/discussions/ankidesktop/37764-webkit
[2]: https://github.com/lovac42/CCBC
[3]: https://github.com/lovac42/CCBC/issues/14
[4]: https://wiki.parabola.nu/List_of_Applications/Other#Flashcards

#9

Updated by nona 6 months ago

For completeness, I am adding this: https://labs.parabola.nu/boards/18/topics/267?r=439

#10

Updated by rfb 4 months ago

Just discovered this issue about Anki while moving to Parabola. It’s a shame because Anki is a great piece of software. My post is not very useful but I just wanted to add another voice to show that Anki is quite used out there.

I don’t know anything about Qt, just some Ruby (which could help to understand Python) so I’m not sure to be able to help. If there’s anything I can do to make Anki come back to Parabola, I’d be glad to do it.

Thanks for your work.

#11

Updated by bill-auger 4 months ago

the ccbc fork is probably the best way forward on this - the PKGBIULD that nona made seems to be working as expected - the licensing needs more checking

#12

Updated by bill-auger 4 months ago

if ccbc does not work out, eli suggested that mnemosyne is a
suitable replacement - its data files are not compatible with
anki; but mnemosyne can import anki data files - though it
currently uses webengine also, the upstream may be more
receptive to patches to change that

#13

Updated by nona 4 months ago

bill-auger wrote:

eli suggested

who's eli?

bill-auger wrote:

that mnemosyne is a suitable replacement

I'll try to get in touch.

#14

Updated by bill-auger 4 months ago

  • Assignee changed from isacdaavid to bill-auger
  • Tracker changed from Bug to Freedom issue

eli is 'eschwartz', one of the community moderators of the forum and bug tracker

i mentioned mnemosyne, for in case that ccbc does not work out - i have packaged it, and it seems to work perfectly - i was going to publish it to pcr-testing now, so that others who are more familiar with it can try it out

my main concern with ccbc is the massive amount of treatment the PKGBUILD applies - depending on how often new versions are released, it may need reworking for each release - - so it could be troublesome to maintain, especially if the upstream maintainer is not responsive - if you want to maintain the package, thats great, you would need to give a contact email address though

were all of those changes necessary in order to support arch (without QT4)? - maybe these could be offered upstream, at least to establish a rapport - QT4 is not an easy path into the future

#15

Updated by bill-auger 4 months ago

ok the package is in the pcr-testing repos now, if people want to test it - it is named 'anki-ccbc'

note to self (if we keep it):
  • move this to libre
  • add it as the anki replacement in the blacklist
#16

Updated by bill-auger 4 months ago

  • Status changed from open to in progress
#17

Updated by nona 4 months ago

bill-auger wrote:

my main concern with ccbc is the massive amount of treatment the PKGBUILD applies - depending on how often new versions are released, it may need reworking for each release - - so it could be troublesome to maintain, especially if the upstream maintainer is not responsive

Yes, I know :S , but since this is a no-strings-attached system, I can just elegantly decline to continue at some point. May be, someone else will pick it up by then.

were all of those changes necessary in order to support arch (without QT4)? - maybe these could be offered upstream, at least to establish a rapport

Every change that I made was necessary at some point. The more I used CCBC, the more I had to tweak it. Right now, I can still find some bugs, but most of them are to transition from Qt4 to Qt5.

I already tried to send my modifications by mail to both pyqt4topyqt5 and lovac42, but I do not have nor want a github account (call it idiosyncrasy, if you want--I just don't want anything to do with M$).

i mentioned mnemosyne, for in case that ccbc does not work out

Regarding mnemosyne, it's hosted on github as well, and their mailing list is based on g◉◉gle (another idiosyncrasy of mine). They seem to have a full team of people working on the project, and they even have a suggestions section. I just sent one to start using QtWebKit instead of QtWebEngine. I sincerely do not think that they are going to listen to it, and I would be very glad to be proven wrong. I could also see that the project has some other programming languages (research students?) like Java, which indicates to me that the base code must be a big spaghetti (note that this comment is completely uninformed, and I may take some fire for that. I really do not mean to insult them, it's just to express my own unwillingness to explore it).

- if you want to maintain the package, thats great, you would need to give a contact email address though

As I said, I will look into the packaging documentation (this week or the next, and I will let you know).

Thanks!

#18

Updated by eschwartz 4 months ago

To be clear, I don't expect you to be particularly successful getting most people to care about one browser engine over another.

But browser engines in general seem to be ludicrous overkill for what most people use them for, and it's incredibly wasteful. Instead, my suggestion was that such programs should be ported over to use QTextBrowser, which supports HTML 4 for rich text but isn't actually a browser, doesn't require as much resources as a browser, can be done with just the QtWidgets module and thus has a much lighter installation footprint (resulting in smaller installers for Windows/macOS in addition to fewer package dependencies on Linux), etc.

This is good advice for any program, but Anki is aggressively uninterested in the opinions of people exercising their Free Software right to build the source code themselves. Mnemosyne seems a lot more open to ideas...

#19

Updated by bill-auger 4 months ago

just yesterday, i watched a talk of kevlin henney mocking that practice as "grabbing for a banana and pulling in a gorilla with it"

#20

Updated by theova 4 months ago

bill-auger wrote:

ok the package is in the pcr-testing repos now, if people want to test it - it is named 'anki-ccbc'

I experienced the following:
  • Missing file during nstallation:
    sudo pacman -U tmp/anki-ccbc-0.1.0-1-any.pkg.tar.xz 
    ....
    :: Processing package changes...
    xdg-mime: file '/usr/share/mime/packages/anki.xml' does not exist
    error: command failed to execute correctly
    ....
    
  • If I click "Add" (left to "Decks") I get
    An error occurred. Please use Tools > Check Database to see if that fixes the problem. 
    If problems persist, you are SOL.
    Anki 2.1.16_ccbc (dev) Python 3.8.3 Qt 5.15.0 PyQt 5.15.0
    Platform: Linux
    Flags: frz=False ao=False sv=1
    
    Caught exception:
    Traceback (most recent call last):
      File "/usr/share/anki-ccbc/aqt/webview.py", line 212, in _linkHandler
        self.linkHandler(url.toString())
      File "/usr/share/anki-ccbc/aqt/toolbar.py", line 73, in _linkHandler
        self.link_handlers[link]()
      File "/usr/share/anki-ccbc/aqt/toolbar.py", line 87, in _addLinkHandler
        self.mw.onAddCard()
      File "/usr/share/anki-ccbc/aqt/main.py", line 781, in onAddCard
        instance = aqt.dialogs.open(name, self)
      File "/usr/share/anki-ccbc/aqt/__init__.py", line 72, in open
        instance = creator(*args)
      File "/usr/share/anki-ccbc/aqt/addcards.py", line 38, in __init__
        self.setupChoosers()
      File "/usr/share/anki-ccbc/aqt/addcards.py", line 60, in setupChoosers
        self.modelChooser = aqt.modelchooser.ModelChooser(
      File "/usr/share/anki-ccbc/aqt/modelchooser.py", line 23, in __init__
        self.setMargin(0)
    AttributeError: 'ModelChooser' object has no attribute 'setMargin'
    

    I am not able to add any cards and the program is not usable at all for me...
#21

Updated by nona 4 months ago

I am busy at the moment, trying to get my linux kernel to work with my graphics card. This may take a little longer than I expected. Sorry.

#22

Updated by bill-auger 3 months ago

again, i could not test this fully because i do not have any
"cards"; and i can not assume anything about their format -
if those cards are made of python, maybe some of them need
the same qt4->qt5 treatment - if they are just data, then
that python bug is probably easily fixed

could someone attach a set of cards or direct me to where i
could find a variety of them?

#23

Updated by bill-auger 3 months ago

  • Description updated (diff)
#24

Updated by nona 3 months ago

I am not able to add any cards and the program is not usable at all for me...

I frankly never create cards, I just use what is available. The way I have been working about this is that when I get an error, I look into the documentation of Qt5 and Qt4 to see what are the equivalencies or what needs to be changed.

In the case of the mentioned error, the function is obsolete, so the solution would be to "Use setContentsMargins() and getContentsMargins() instead.", as suggested by the documentation.

Therefore, looking for =.setMargin= in the source code,

find . -name '*.py' -type f -exec grep --color -nH --null -e '\.setMargin(0)' \{\} +

I found:
./aqt/modelchooser.py:023:        self.setMargin(0)
./aqt/deckchooser.py:023:        self.setMargin(0)

(line 23 must be a hell of a coincidence or an initial kill-yank)
Thus, I modified the following line in my PKGBUILD:
    's%QDesktopServices.\(Documents\|Home\)\(Location\)%QStandardPaths.\1\2%g;'

so that it has one more line after that:
    's%QDesktopServices.\(Documents\|Home\)\(Location\)%QStandardPaths.\1\2%g;'
    's%self.setMargin(0)%self.setContentsMargins(0)%;'

That line basically replaces =self.setMargin= with =self.setContentsMargins=

which now creates a new error:

Caught exception:
Traceback (most recent call last):
  File "/usr/share/anki/aqt/webview.py", line 214, in _linkHandler
    self.linkHandler(url.toString())
  File "/usr/share/anki/aqt/toolbar.py", line 74, in _linkHandler
    self.link_handlers[link]()
  File "/usr/share/anki/aqt/toolbar.py", line 88, in _addLinkHandler
    self.mw.onAddCard()
  File "/usr/share/anki/aqt/main.py", line 789, in onAddCard
    instance = aqt.dialogs.open(name, self)
  File "/usr/share/anki/aqt/__init__.py", line 72, in open
    instance = creator(*args)
  File "/usr/share/anki/aqt/addcards.py", line 38, in __init__
    self.setupChoosers()
  File "/usr/share/anki/aqt/addcards.py", line 65, in setupChoosers
    self.modelChooser = aqt.modelchooser.ModelChooser(
  File "/usr/share/anki/aqt/modelchooser.py", line 23, in __init__
    self.setContentsMargins(0)
TypeError: arguments did not match any overloaded call:
  setContentsMargins(self, int, int, int, int): not enough arguments
  setContentsMargins(self, QMargins): argument 1 has unexpected type 'int'

This error happens, evidently due to the type of data provided to the function and it was an overlook on my side, but I don't have much time now, and needs to be fixed in a similar way. It is that simple, but time-consuming, to fix the whole thing. I don't even know what the 'Add' button is supposed to do, and I guess that it is meant to create a deck or a card. If it is supposed to get a deck from an =.apkg= file, just use 'File' > 'Import'. However, I can hardly believe that the developers would have both options in such a repetitive way.

If nobody fixes that bug, I will do it as soon as possible. I don't know what is more useful: to read the packaging documentation and prepare for it, or to actually fix the bug. I already pushed the change that I made to my repo

#25

Updated by nona 3 months ago

bill-auger wrote:

again, i could not test this fully because i do not have any
"cards"; and i can not assume anything about their format -
if those cards are made of python, maybe some of them need
the same qt4->qt5 treatment - if they are just data, then
that python bug is probably easily fixed

could someone attach a set of cards or direct me to where i
could find a variety of them?

Sure, you can find many on the AnkiWeb (which I really think is great). The ones I have are really too big to share here.

#26

Updated by bill-auger 3 months ago

theova wrote:

xdg-mime: file '/usr/share/mime/packages/anki.xml' does not exist

that is fixed in abslibre/pcr-testing:

https://git.parabola.nu/abslibre.git/tree/pcr-testing/anki-ccbc?id=d8d414c66f4dd069a31eb1aa34443a7fb59215c7

#27

Updated by bill-auger 3 months ago

for the sake of considering more alternatives, is there any reason why 'parley' is not a suitable replacement for 'anki' ? - 'parley' is already in [libre], patched to use 'qt5-webkit'

"Program to help you memorize things. It uses the spaced repetition learning method, also known as flash cards"

maybe parley is not general-purpose though - the package description is:

"Vocabulary Trainer, without qt5-webengine"
#28

Updated by rfb 3 months ago

bill-auger wrote:

for the sake of considering more alternatives, is there any reason why 'parley' is not a suitable replacement for 'anki' ? - 'parley' is already in [libre], patched to use 'qt5-webkit'

"Program to help you memorize things. It uses the spaced repetition learning method, also known as flash cards"

maybe parley is not general-purpose though - the package description is:

"Vocabulary Trainer, without qt5-webengine"

I haven’t tested parley yet. The main hurdle is that it is a KDE software. Of course, if one’s running KDE, no problem. But, for other people trying to be GNOME or KDE-free on a minimal system, this is an inconvenience. I run XFCE and I checked on Pacman the parley installation: for this tiny little program, I need to install 214MB of KDE dependencies…

Anki and other Anki-based software have the advantage of being DE-independent.

As for Anki decks, I join my English and Japanese collection I made myself so you can test. It’s minimal in the way that it’s just plain text, there is no media attached to the cards so it’s quite light. It might not represent the performance you would get with a more bloated set of cards.
Also, it comes from Anki 2.0, so from what I understood, the version that still had the qt-webkit. Though, it shouldn’t have any consequences on the deck itself.

#29

Updated by eschwartz 3 months ago

theova wrote:

bill-auger wrote:

ok the package is in the pcr-testing repos now, if people want to test it - it is named 'anki-ccbc'

I experienced the following:
  • Missing file during nstallation:
    xdg-mime: file '/usr/share/mime/packages/anki.xml' does not exist 
    

Um okay, this is wrong. https://git.parabola.nu/abslibre.git/commit/pcr-testing/anki-ccbc?id=d8d414c66f4dd069a31eb1aa34443a7fb59215c7

The anki-ccbc.install scriptlet should not exist. Please don't use xdg-mime install, instead mv the file during package() as upstream should NOT install /usr/share/anki-ccbc/anki.xml in this location -- it's supposed to be installed to /usr/share/mime/packages/

Pacman hooks will handle its processing at install time.

xdg-mime default is not necessary as it's the user's job to select default applications, but there's only one installed handler for application/x-anki anyway I'd assume.

#30

Updated by bill-auger 3 months ago

thats i wondered about that - so 'desktop-file-utils' handles
that by magic

i tried to package mnemosyne today, to get an idea of how
strongly it would resist being the absence of webengine - then i
realized that it had 6 python dependencies which would need to
be packaged to support it

#31

Updated by nona 3 months ago

bill-auger wrote:

for the sake of considering more alternatives, is there any reason why 'parley' is not a suitable replacement for 'anki' ? - 'parley' is already in [libre], patched to use 'qt5-webkit'

I did an initial trial, and it works well for me. It does what it is meant to do. There are features from CCBC that I missed (may be it's the lesson that I chose?). For instance, with CCBC, you have levels of difficulty when you answer. Most importantly, it would be great to transfer the .apkg into a suitable Parley format, because there are so many cards already available in CCBC... I also liked and disliked that it has an embedded lesson downloader. For one, it is nice that you don't need to open your browser and look for the lessons on another website. However, as a Tor user, I would prefer to actually be able to do precisely that (to prevent DNS leaks and all that; may be it would be nice to have a SOCKS5 proxy option; may be that is too much to ask from a program like this). I did find something like that, I think. Another thing that I missed is the high level of keyboard shortcuts for CCBC. What has been mentioned already about the bloat, is something to consider too. My system is like a loaded truck anyways, but I really understand those users.

#32

Updated by nona 3 months ago

nona wrote:

That line basically replaces =self.setMargin= with =self.setContentsMargins=

which now creates a new error:
[...]

This error happens, evidently due to the type of data provided to the function and it was an overlook on my side...

If we go to the C++ and Python documentation of Qt, we'll find that =setContentsMargins= needs 4 =int= or a =QMargins=. The original code had =0=. Thus, I just replaced that with 4 =0=. I already pushed the change to my repo

I will next fix the bug for the Browse button.

#33

Updated by theova about 2 months ago

As for know, Anki-CCBC is not usable for me.

I think the work of nona goes into the right direction. However, in my opinion it would be better to fork CCBC instead of patching it in the PKGBUILD.
I'm not sure about the amount of work to port a qt4 programm to qt5 - is it doable? If so, I would like to help working on this issue.

#34

Updated by bill-auger about 2 months ago

has anyone tried the Mnemosyne program that eli suggested? - it would
probably be less work to maintain

#35

Updated by theova about 2 months ago

I tried. However, Mnemosyne depends on qt-webengine too. I have not looked into it.
bill-auger, you started to build it without webengine?

#36

Updated by eschwartz about 2 months ago

I was told that mnemosyne has a python core with multiple frontends, including both a qt webengine frontend and a webpage frontend that you open in your preferred browser (e.g. Iceweasel).

The webpage frontend would be usable as-is and it's reasonable to think that one could author an additional frontend using a choice of technologies. Perhaps fork the webengine frontend into a webkit frontend. Or make one that uses no browser technology at all, and offer that one to upstream.

#37

Updated by nona about 2 months ago

theova wrote:

As for know, Anki-CCBC is not usable for me.

I think the work of nona goes into the right direction. However, in my opinion it would be better to fork CCBC instead of patching it in the PKGBUILD.
I'm not sure about the amount of work to port a qt4 programm to qt5 - is it doable? If so, I would like to help working on this issue.

Yes, indeed. Everything that you said +1. Go forth! Note that my repo is not the same as what exists in Parabola. I would advise you to look into both.

#38

Updated by bill-auger about 2 months ago

if memosyne is already configurable, to use xdg-open, that LGTM -
it is the main reason why that mechanism exists - its a shame
that devs do not simply use the system tools, rather than doing
the extra work of integrating a library to duplicate
functionality, which is a reasonable assumption that every GUI
system has

#39

Updated by bill-auger about 2 months ago

nona wrote:

theova wrote:

As for know, Anki-CCBC is not usable for me.

it would be better to fork CCBC instead of patching it in the PKGBUILD.
I'm not sure about the amount of work to port a qt4 programm to qt5 - is it doable? If so, I would like to help working on this issue.

Yes, indeed. Everything that you said +1. Go forth!

o/c patching is not ideal; but forking, only for the purpose of
maintaining a patch-set, is pointless - it is exactly the same
amount of work

it is almost always best to work with the upstream to improve
the original - forking should be a last resort, when the
upstream is not interested, or not responsive

in this case, IIRC the main reason why CCBC was forked is not in
order to remove webengine support, but because anki migrated to
QT5, and was not interested in supporting QT4 - the work nnoa
did was to patch CCBC, so that it use QT5 again; which is very
convoluted

the CCBC fork would have been pointless, if not for QT4
support; and un-doing those changes removes all of the benefit
that the CCBC provides: compatibility with older data-sets IIRC

after doing so, there would likely be nothing remaining of the
CCBC changes - without looking at the code, i assume that the
same could be accomplished by resetting the CCBC git repo, back
to the point where it was forked from anki, then converting it
to support QT5 - but that is exactly what the anki upstream did
- the result would be an older, un-maintained version of anki,
which supports QT5

if someone were going to maintain a patch-set, which primary
goal is only to remove webengine support, or if a fork was
necessary, then it would surely be more sensible, and less work,
to patch webengine support out of the upstream anki, and forget
about CCBC altogether

presumably, that would be the best way to minimize the patches
that parabola carries, and reduce the over-all maintenance
workload; because the upstream anki would be doing most of the
maintenance

as a side note, it is also worth mentioning, that there is a bug
in the 'pyqt4topyqt5' tool that is used to convert CCBC to QT5 -
that itself is not a problem because i fixed it, and opened a
merge request on the upstream github in july; but it got no
attention - it appears that nothing interesting has happened to
the repo in over 3 years; so it is likely that 'pyqt4topyqt5'
will cease to function eventually, eg: whenever QT6; and the
current patching trick will no longer be viable

i am not familiar with these programs from a user-perspective;
but from the perspective of a maintainer, memosene would seem to
be the best option; as it may require no maintenance at all

Also available in: Atom PDF