flathub / net.ankiweb.Anki

https://flathub.org/apps/details/net.ankiweb.Anki
20 stars 13 forks source link

New cleanup #10

Closed jurf closed 5 years ago

jurf commented 5 years ago

This time in the suggested way.

Obsoletes #8.

Note that pyqt5 can be built with only selecting some modules, but I haven’t yet been able to figure which Anki needs (it didn’t want to run in my testing). @bochecha, ping. :slightly_smiling_face:

jurf commented 5 years ago

bot, build

bochecha commented 5 years ago

Hi @jurf, I'm trying this, it fails: the json points to anki.svg, but the file is named net.ankiweb.Anki.svg.

And then you have the rename-icon which is unneeded (and fails the build) as the icon is already properly named.

At the end of the build, there's this:

xdg-mime install anki.xml --novendor
make: xdg-mime: Command not found
make: [Makefile:19: install] Error 127 (ignored)
xdg-mime default anki.desktop application/x-anki
make: xdg-mime: Command not found
make: [Makefile:20: install] Error 127 (ignored)
xdg-mime default anki.desktop application/x-apkg
make: xdg-mime: Command not found
make: [Makefile:21: install] Error 127 (ignored)
jurf commented 5 years ago

@bochecha ah shoot, beginner mistake, but was too lazy to wait half an hour for it to build again at this hour. Lemme fix it quickly.

BTW the rename icon is there so that we don’t have to sed the desktop file. The less sed, the better. :D

jurf commented 5 years ago

OK, should be fixed, though I’m compiling now to be sure. Edit: yeah, now it builds.

BTW, these are the modules that are built when the whole of PyQt is built:

QtCore, QtGui, QtHelp, QtMultimedia,
QtMultimediaWidgets, QtNetwork, QtOpenGL, QtPrintSupport, QtQml, QtQuick,
QtSql, QtSvg, QtTest, QtWidgets, QtXml, QtXmlPatterns, QtDesigner, QtDBus,
_QOpenGLFunctions_2_0, _QOpenGLFunctions_2_1, _QOpenGLFunctions_4_1_Core,
QtSensors, QtSerialPort, QtX11Extras, QtBluetooth, QtPositioning,
QtQuickWidgets, QtWebSockets, QtWebChannel, QtWebEngineWidgets, QtLocation,
QtNfc, QtWebEngineCore, QtWebEngine.
bochecha commented 5 years ago

You need to use --no-deps for all the pip installs.

As it is, you get things like this:

========================================================================
Building module python3-requests in /home/mathieu/.cache/flatpak-builder/build/python3-requests-1
========================================================================
Running: pip3 install --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} requests
Ignoring indexes: https://pypi.python.org/simple
Collecting requests
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Collecting idna<2.8,>=2.5 (from requests)
Collecting urllib3<1.24,>=1.21.1 (from requests)
Collecting certifi>=2017.4.17 (from requests)
Installing collected packages: chardet, idna, urllib3, certifi, requests
  Running setup.py install for chardet ... done
  Running setup.py install for idna ... done
  Running setup.py install for urllib3 ... done
  Running setup.py install for certifi ... done
  Running setup.py install for requests ... done
Successfully installed certifi-2018.8.24 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23

That means when you install the requests module, pip goes to PyPI and downloads the dependencies.

That's going to fail in Flathub, where builds can't access the network.

jurf commented 5 years ago

@bochecha pretty sure that should work, I used this for that as always: https://github.com/flatpak/flatpak-builder-tools/tree/master/pip

There’s basically no difference to the updated version and the old versions (except for the newer packages), and those worked without issue.

jurf commented 5 years ago

bot, build

bochecha commented 5 years ago

As for PyQt modules, you need these:

            "  --enable=QtCore \\",
            "  --enable=QtGui \\",
            "  --enable=QtNetwork \\",
            "  --enable=QtPrintSupport \\",
            "  --enable=QtWebChannel \\",
            "  --enable=QtWebEngineCore \\",
            "  --enable=QtWebEngineWidgets \\",
            "  --enable=QtWidgets \\",

And then the app works. :slightly_smiling_face:

jurf commented 5 years ago

@bochecha thanks so much! I couldn’t figure that out for the life of me.

Regarding the xdg-mime errors, I’m not sure why they fail and why the mime file is installed by hand afterwards, I’ll have to look into that, but it doesn’t fail the build and it went through the initial review so I guess it’s OK… Edit: figured it out, xdg-mime doesn’t do anything other than install the mime file and set Anki as the default for the rules supplied in it, it’s easier to just install it by hand.

bochecha commented 5 years ago

Regarding pip downliading the dependencies, I was wrong.

Turns out the module for requests bundles has not only the source tarball for requests, but also the tarballs for its dependencies.

That's pretty awful, but I guess that's how that pip generator works. :disappointed:

jurf commented 5 years ago

bot, build

dsd commented 5 years ago

pyqt5 depends on sip and won't build without it mpv depends on ffmpeg and won't build without it

That's why they are currently nested modules (also the mpv flatpak manifest is set up like this - https://github.com/flathub/io.github.GnomeMpv/blob/master/io.github.GnomeMpv.json). So I think they must stay nested, in order to represent the build dependencies. Please let me know if I'm missing something.

jurf commented 5 years ago

@bochecha nice, build times went down 22→14 minutes after that PyQt5 change. Thanks again!

@dsd manifests are processed in order, so that each module has access to whatever the previous module installed. E.g., if Anki actually compiled anything, it would fail with the manifest currently in master, because since it is at the start, none of the dependencies are there yet, and it has nothing to compile against. They all install into the same root (/app).

Nested modules are an option, yes, but I don’t like using them, because they break the order, e.g. FFmpeg gets built before MPV, even though it’s after it.

Nested modules also aren’t very popular in my experience (i.e. quite rare) on Flathub. If you sometimes wonder what’s the ‘correct’ way to do things, take a look at manifests done by (and maintained) the Flathub maintainers, e.g. TingPing, barthalion, etc.

jurf commented 5 years ago

But, in the end, it’s a matter of personal preference.

jurf commented 5 years ago

Also, please don’t take this as a critique of your work; I’m quite a detailist and I use Anki a lot, so I wanted to toughen up the manifest while I still have time for it, so that when I need it to work, it’ll work. The stylistic changes are just there because they made my job considerably easier when understanding the manifest and when I wanted to make the actual functional – i.e. important – changes.

jurf commented 5 years ago

Ping?

jurf commented 5 years ago

Hey what’s going on, why is it failing on ARM all of a sudden?