leycec / raiagent

Third-party Gentoo overlay. Ride the Lagrangian point between awesomeness and volatile compounds.
31 stars 14 forks source link

dev-python/Kivy - incomplete install #104

Closed scottfurry closed 1 year ago

scottfurry commented 1 year ago

Installed the packages dev-python/Kivy and dev-python/kivymd successfully. The dev-python/Kivy had the use flag examples. Statement from eix for kivy:

dev-python/Kivy [1]
     Installed versions:  2.1.0(02:00:45 PM 2022-08-02)(X buildozer cython examples gles2 highlight imaging opengl pango pytest rst sdl spell wayland -doc -gstreamer -pygame -vim-syntax PYTHON_TARGETS="python3_10 -python3_8 -python3_9")

While attempting to execute code from the /usr/share/kivy_examples, command line became littered with python exception messages. One message of note:

 --- Logging error ---
 Traceback (most recent call last):
   File "/usr/lib/python3.10/site-packages/kivy/__init__.py", line 369, in <module>
     shutil.copytree(join(kivy_data_dir, 'logo'), icon_dir)
   File "/usr/lib/python3.10/shutil.py", line 556, in copytree
     with os.scandir(src) as itr:
 FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.10/site-packages/kivy/data/logo'

The directory /usr/lib/python3.10/site-packages/kivy/data/ does not exist in filesystem. If I copy over the directory from a virtual environment install, problems go away. The data directory is used by kivy for various support files (graphics, fonts, et al).

The main effort was to execute the kivy demo sample kivy-examples/demo/kivycatalog/main.py, which highlights various features and capabilities of kivy widgets. With the above problem of missing data directory fixed, the demo program would continue to fail, albeit with a more trimmed down exception. Reported error:

[ERROR  ] [Clock       ] Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy
 Traceback (most recent call last):
   File "/usr/share/kivy-examples/demo/kivycatalog/main.py", line 26, in <module>
     from kivy.app import App
   File "/usr/lib/python3.10/site-packages/kivy/app.py", line 416, in <module>
     from kivy.base import runTouchApp, async_runTouchApp, stopTouchApp
   File "/usr/lib/python3.10/site-packages/kivy/base.py", line 28, in <module>
     from kivy.clock import Clock
   File "/usr/lib/python3.10/site-packages/kivy/clock.py", line 466, in <module>
     from kivy._clock import CyClockBase, ClockEvent, FreeClockEvent, \
 ModuleNotFoundError: No module named 'kivy._clock'

I suspect that a post-install step for python packages was not undertaken in the ebuild. This may be a step assumed to execute before but changes to gentoo eclass structure are now causing grief. But that's just a guess on my part.

leycec commented 1 year ago

Thanks so much for the detailed investigatory legwork, @scottfurry. This makes you our first dissatisfied Kivy customer, for which I'm surprisingly grateful. I wasn't quite sure whether anyone else was actually attempting to profit from our suite of Kivy ebuilds. Surprise twist: they are.

I must confess I never actually ran any of the examples. An upcoming Kivy app from my wife and I leverages a pure KivyMD workflow, which presumably replaces most (...probably all) of Kivy's bundled assets with Material Design-compliant equivalents. Incidentally, did I mention that KivyMD is phenomenal? Because it is.

Shockingly, the main KivyMD lead somehow actively develops from the hottest hot spot in the world: the occupied territories of eastern Ukraine. I perform daily ablutions for his safety. :scream:

kivy.data: Wherefore Art Thou?

Okay! It's back to the Gentoo slave mines for us, then. Your suspicions that...

...a post-install step for python packages was not undertaken in the ebuild. This may be a step assumed to execute before but changes to gentoo eclass structure are now causing grief.

...are almost certainly correct. We've switched to DISTUTILS_USE_PEP517 across most our Python ebuilds – including Kivy. That might now be biting us like Ontario's most terrifying snake, the Massasauga Rattler. </shudders>

Alternately, this might simply be an omission on our part. Kivy's non-trivial build system requires manually exporting a number of shell variables to Kivy's setup.py. We had this to say about that:

    # Export environment variables expected by this package's "setup.py"
    # (listed in the same order for maintainability). However, note that:
    # * These variables are almost entirely undocumented. It is what it is.
    # * These variables are listed undercase in "setup.py" but *MUST*
    #   nonetheless be declared as uppercase here. It is what it is.

oh, boy

leycec commented 1 year ago

Oh, boy. I can reluctantly confirm that enabling the examples USE flag produces a totally b0rked installation that fails to install either kivy.data or any of Kivy's Cythonized C extensions (including the kivy._clock C extension you noted above). This is almost certainly an upstream issue. Until I can get a better grip on this rip-roaring whitewater raft ride, please disable the examples USE flag.

And this is why I constantly shake my head and get crippling migraines.

scottfurry commented 1 year ago

Should I be grateful you actually posted a picture of snake and not a politician? Canadian politics aside.

I feel your pain.

I read the notes for [Installation] Enabling "USE_MESAGL=1" breaks everything referenced in the ebuild. Wow... ugh...

I had a painful time today getting anything kivy to run. First the ebuild, then virtualenv pip with "kivy[full]", and finally virtualenv again using "kivy[dev,full]". With the example programs installed, I could see what a normal output should look like during execution. It was then I discovered that my basic script had an error. I was calling app.run - missing parenthesis. \<facepalm>. I then backtracked the various install methods to see what would break. This produced messages posted above.

The missing directories shouldn't be too much problem to fix - one hopes.

As for python install under gentoo ...sigh... they just keep making things more complicated. You can see the code but then have to wrap your head around intent with no visuals of the Bash environment implications. And who bothers to write documentation anymore? \<sarcasm>

FreeBSD is looking more realistic by the minute.

The biggest pain is that python is not exactly resolute in terms of install methodology. There are at least half a dozen ways to install python packages?! Distribution and Packaging Maintainer's nightmare. To think this is by design from python devs. pip everything regardless of distribution installation. Then it's virtualenv pip everything creating duplicate structure. smh.

Basic gist is that Kivy examples could not be executed because the libraries do not get compiled. It works in a virtualenv, but not in an ebuild. I just don't have the requisite knowledge nor time to dig through gentoo interals to figure out. Report and cross my fingers.

I'll disable examples, reinstall, and report findings probably tomorrow.

I agree, kivy is cool. Now if we can just ease the software into the right place in the system without collateral damage. Or should I be up'ing my medication at this point?

leycec commented 1 year ago

Oh, I see. Kivy's setup.py is insane. For unknown reasons, Kivy reuses the same setup.py script to install either Kivy or the external Kivy-examples package. That's not the insane part. The insane part is that these two installation targets are mutually exclusive. You can either install Kivy or you can install Kivy-examples. Pick one.

Obviously, anyone installing Kivy wants Kivy to be installed. If they wanted a separate Kivy-examples package, they should have just packaged Kivy-examples properly as a separate project. Instead, we are here. I continue shaking my head and receiving excruciating migraines.

Let's just quietly kludge this away – or remove the examples USE flag entirely if our hacks fail. Don't fail us now, hacky sed one-liners! :sob:

scottfurry commented 1 year ago

From the install doc notes:

python -m pip install "kivy[base]" kivy_examples

So that means the setup.py is called twice. First, to install the kivy infrastructure then a second time to install the examples. oi vey

scottfurry commented 1 year ago

Odd suggestion - spin examples out to it's own ebuild. Sure, it's overhead but you can be confident that the base install will not become corrupted in the process. My $0.02 with no GST.

leycec commented 1 year ago

What!? NO GST!?!? Call the CRA, folks. Oh, wait... you can't actually call the CRA. No one can. The CRA don't take calls, because why would taxpayer-funded agencies communicate with taxpayers? The CRA calls you. Actually... I'm pretty sure they don't even do that, because the human element was obsoleted away long ago. Now it's all cutting-edge COBOL "automation" and Phoenix Pay "solutions."

This is why I lament at night.

...Back to the Front

I discovered something! Yes, it's true. Kivy's setup.py supports a hidden undocumented KIVY_SPLIT_EXAMPLES option. If we enable that and stop enabling the hidden undocumented KIVY_BUILD_EXAMPLES option that destroys Manhattan, we may just be able to stop the alien invasion in time. Probably not, of course. But this is mankind's last hope.

Fulfil your destiny, KIVY_SPLIT_EXAMPLES! Do something for once.

scottfurry commented 1 year ago

Fulfil your destiny, KIVY_SPLIT_EXAMPLES! Do something for once.

Help me, KIVY_SPLIT_EXAMPLES. You're my only hope...

scottfurry commented 1 year ago

FWIW, I little trick I picked up when I was doing package maintaining for different OS's was to go look at what other distributions do installing stuff. The Repology site shows kivy installation. By clicking on the version value, you can click through to a page, for the most part, to distributions packaging information.

For example, Slack page for kivy has links to the SlackBuild file define how to install. The text file is right there to examine.

Debian(Unstable) is not at the latest release but clicking on the version 1.11.0 takes you to the source details. You can see that Debian shows two binary packages - 1) core and 2) examples. A link at the bottom takes you to Debian's git repository. You can browse the package debian directory for the install instructions.

Caveat Emptor YMMV

leycec commented 1 year ago

Repology. That is such packaging h0tness. I now stand on the shoulders of giants. I'm acrophobic, so the vertiginous fear I feel while standing so high up doesn't feel great. I carefully climb down. Now with grey hair and a wrinkly chin, I vow never to do that again. :older_adult:

By which I meant to say... resolved by f4e7558. If you get a chance in the morning, would you refreshing the repo and trying again?

What @leycec Did, If Anyone Cares (They Don't, Which Is Sad)

Unsurprisingly, KIVY_SPLIT_EXAMPLES behaves badly by installing examples to the non-standard /usr/share/kivy-examples/ directory. Who would ever look there for an example? I am confident the answer is: "No sane Canadian, that is who." I shrug shoulders non-committally and then just rip everything out in favour of a trivial one-liner:

use examples && dodoc -r examples

Friends always let friends one-liner and commit. Thanks again for the tremendous assistance on both this and prior issues, @scottfurry. You remain the Hero I don't deserve but nonetheless keep getting.

scottfurry commented 1 year ago

We're all in this together. Keep your stick on the ice. Red_Green_HandyHandsome

scottfurry commented 1 year ago

It is unfortunate that adherence to LFS (Linux File System) is scatter shot. And distributions having their own conventions and expectations just adds unneeded complications. Package Maintainers do their best to enforce such conventions but this action is dependent on a cohesive distribution standard/philosophy. My impression of Gentoo is the matter is analogous to the line from Pirates of the Caribbean: "...more what you'd call "guidelines" than actual rules."

I can confirm the fixes implemented work. I can execute the various demo and examples produced by kivy. Thanks for the hard work. Your efforts are much appreciated.

leycec commented 1 year ago

Oh, you're most welcome. It's a genuine joy to hammer out issues like this with a fellow gentleman of culture. And...

My impression of Gentoo is the matter is analogous to the line from Pirates of the Caribbean: "...more what you'd call "guidelines" than actual rules."

This is the Gentoo way. Gentoo attracts the well-meaning anti-authoritarian types like myself, who then inevitably rebel against everything – including Gentoo guidelines. We're the Green Party of Canada gone Linux distro: defeated from within by self-destructive bickering over ideological purity and the disastrous cult of personality, we rise from the ashes of our own pettiness to compute another day.

Unrelatedly...

Would You Like to Know More About @beartype?

@beartype is this Pythonic thing I do with actively maintained ebuilds in raiagent. If you have any lingering interest in type hints, I'd be delighted to hear your thoughts.

Have a slow and easy slide into September. You rock, @scottfurry. :guitar: :notes:

scottfurry commented 1 year ago

We're the Green Party of Canada gone Linux distro: defeated from within by self-destructive bickering over ideological purity and the disastrous cult of personality, we rise from the ashes of our own pettiness to compute another day.

I'm partial to the Lobster Party of Canada, myself personally. They got free air time during a federal election decades ago. Guy siting behind a desk with his feet up and a 2-4 in front of him decreeing that Canada's ills could be solved by having more kids. More kids equals more taxpayers. More taxpayers means more money for government programs. Made a bit of twisted sense at the time.

Will look into provided links. Thanks for tagging along.