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

build binary for desktop Linux, with kivy GUI included #6835

Closed
joshbowyer opened this issue Dec 9, 2020 · 19 comments
Closed

build binary for desktop Linux, with kivy GUI included #6835

joshbowyer opened this issue Dec 9, 2020 · 19 comments

Comments

@joshbowyer
Copy link

Is it possible to build Electrum desktop with the mobile (Android) UI, or to at least make it look better? Currently Linux phones (Pinephone/Librem5) are starting to become an actual thing, and there are no crypto wallets for that screen size. These run Debian on arm64.

@SomberNight
Copy link
Member

The Android app uses the kivy GUI.

You can use the kivy GUI on desktop Linux:
https://github.com/spesmilo/electrum/tree/e3ea0f6241088c3c7fd3b2b72ae6643a0f4c9de7/contrib/android#kivy-can-be-run-directly-on-linux-desktop-how
Is this what you mean?

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020 via email

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

I apologize for the stupid question, but when I run the command in that section, it returns:

python3 -m kivy.atlas ../../electrum/gui/kivy/theming/light 1024 ../../electrum/gui/kivy/theming/light/*.png
/usr/bin/python3: Error while finding module specification for 'kivy.atlas' (ModuleNotFoundError: No module named 'kivy')
make: *** [Makefile:9: theming] Error 1```

I'm also not quite sure how to best build this for arm64, Id think an appimage would be best but how do I build that for arm64 AND include the Kivy UI?

@SomberNight
Copy link
Member

ModuleNotFoundError: No module named 'kivy'

you need to install kivy first, e.g.

python3 -m pip install kivy

I'm also not quite sure how to best build this for arm64, Id think an appimage would be best but how do I build that for arm64 AND include the Kivy UI?

right, building it would need some work...

  1. see this for building appimage for arm: AppImage for ARM Linux #5159
  2. as for bundling the kivy GUI in the binary, we would just need to include kivy and its dependencies, and our GUI files - currently the kivy GUI is intentionally not bundled in any of the binaries except for the Android apk (not listed in e.g. setup.py/packages)

(1) is probably much more involved than (2)

@SomberNight
Copy link
Member

see this for building appimage for arm: #5159

actually, a significant chunk of troubles listed there are about building Qt, which is used for the main desktop GUI, so you would not need that

anyway, if you figure out how to build an appimage for ARM on an amd64 host, we would be very interested in that.

@SomberNight SomberNight changed the title Mobile UI? build binary for desktop Linux, with kivy GUI included Dec 9, 2020
@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

I wonder if Flatpak might be a good alternative to AppImage? Also, whoever maintains the Debian package may wish to add Kivy as either a built-in module, or a separate package. For now I will look into AppImage, but as I try running it with just python pip, I run into an issue. Here is what I did:

git clone git://github.com/spesmilo/electrum.git
cd electrum
git submodule update --init
python3 -m pip install --user -e .
python3 -m pip install kivy
cd contrib/android/; make theming
electrum -g kivy

(I added ~/.local/bin to my PATH)

It error out however, with the following: Error: Failed to load libsecp256k1.

Should this be installed as a pip module? Or apt?

edit: Installed with pip and still get the same error

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

Ah, found the solution here: #5606 (comment)

but now im getting this:

NotADirectoryError: [Errno 20] Not a directory: '/home/josh/git/electrum/electrum/electrum/gui/kivy/data/style.kv'

Whereas the path should be '/home/josh/git/electrum/electrum/gui/kivy/data/style.kv' (its adding an extra electrum child that doenst exist)

(Also its good to know that it still expects all its data to be in its git directory...)

@SomberNight
Copy link
Member

NotADirectoryError: [Errno 20] Not a directory: '/home/josh/git/electrum/electrum/electrum/gui/kivy/data/style.kv'

What command are you running when getting this?

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

electrum -g kivy

If I just run electrum it starts fine, so something in Kivy is having an issue

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

Sorry here is the full trace btw:

[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/home/josh/.local/lib/python3.7/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[INFO   ] [Factory     ] 184 symbols loaded
E | daemon.Daemon | GUI raised exception: NotADirectoryError(20, 'Not a directory'). shutting down.
E | __main__ | daemon.run_gui errored
Traceback (most recent call last):
  File "/home/josh/git/electrum/electrum/electrum", line 401, in handle_cmd
    d.run_gui(config, plugins)
  File "/home/josh/git/electrum/electrum/daemon.py", line 573, in run_gui
    self.gui_object.main()
  File "/home/josh/git/electrum/electrum/gui/kivy/__init__.py", line 64, in main
    from .main_window import ElectrumWindow
  File "/home/josh/git/electrum/electrum/gui/kivy/main_window.py", line 27, in <module>
    from kivy.app import App
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/app.py", line 319, in <module>
    from kivy.base import runTouchApp, stopTouchApp
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/base.py", line 28, in <module>
    from kivy.lang import Builder
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/lang/__init__.py", line 862, in <module>
    from kivy.lang.builder import (Observable, Builder, BuilderBase,
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/lang/builder.py", line 931, in <module>
    Builder.load_file(join(kivy_data_dir, 'style.kv'), rulesonly=True)
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/lang/builder.py", line 288, in load_file
    with open(filename, 'r') as fd:
NotADirectoryError: [Errno 20] Not a directory: '/home/josh/git/electrum/electrum/electrum/gui/kivy/data/style.kv'```

@joshbowyer
Copy link
Author

Alright I hunted the issue down, and in run_electrum it was concatenating KIVY_DATA_DIR and '/electrum/gui/kivy/data' so I removed the extra '/electrum' and now it doesnt complain about that, but it does throw more errors now. (fyi I have been trying this on my regular x64 laptop, not arm)

Here is the error: https://privatebin.net/?f57e36c064d2a06c#9mdTT2pVGszN9Qy55TKxSkPy5KkfWKJraJq5FchsEnUG

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

Ok once this is all solved I will post the complete instructions to build this on Debian, I have figured out everything except one last error:

E | __main__ | daemon.run_gui errored
Traceback (most recent call last):
  File "/home/josh/git/electrum/electrum/electrum", line 401, in handle_cmd
    d.run_gui(config, plugins)
  File "/home/josh/git/electrum/electrum/daemon.py", line 573, in run_gui
    self.gui_object.main()
  File "/home/josh/git/electrum/electrum/gui/kivy/__init__.py", line 64, in main
    from .main_window import ElectrumWindow
  File "/home/josh/git/electrum/electrum/gui/kivy/main_window.py", line 75, in <module>
    'electrum/gui/kivy/data/fonts/Roboto-Bold.ttf')
  File "/home/josh/.local/lib/python3.7/site-packages/kivy/core/text/__init__.py", line 315, in register
    raise IOError('File {0} not found'.format(font_type))
OSError: File electrum/gui/kivy/data/fonts/Roboto.ttf not found

Yet I can confirm that the file is indeed right in that path.

@joshbowyer
Copy link
Author

Sorry for blowing up your inbox lol, I added a debug statement to /home/josh/git/electrum/electrum/gui/kivy/main_window.py right before it tries to import those fonts, to show the cwd, and it is /home/josh. It looks like its relative to the directory it is launched from as opposed to being concatenated with KIVY_DATA_DIR, since if I cd to the electrum directory and launch it, it works just fine.

@joshbowyer
Copy link
Author

joshbowyer commented Dec 9, 2020

I wont mess with that issue since its easy enough to overcome in a .desktop file. I will post the entire command list I had to run in order to make this work on Debian. My last question is, can I specify the window resolution for this? It does NOT resize well at all, changing the window size jacks everything up, and it seems the actual viewport is fixed to a specific resolution (that is what I would like to statically override if possible).

Here is the method to install Electrum + Kivy on Debian:

cd electrum
git submodule update --init
sudo apt install libsecp256k1-dev xsel
python3 -m pip install pygame
python3 -m pip install kivy
python3 -m pip install --user -e .
cd contrib/android/; make theming
sed -i '/KIVY_DATA_DIR/ s/\/electrum//' electrum/electrum
cd ../../
electrum -g kivy

@SomberNight
Copy link
Member

My last question is, can I specify the window resolution for this?

https://kivy.org/doc/stable/guide/config.html

For me, it's at ~/.kivy/config.ini.
See the [graphics] section.

@SomberNight
Copy link
Member

SomberNight commented Dec 10, 2020

Alright I hunted the issue down, and in run_electrum it was concatenating KIVY_DATA_DIR and '/electrum/gui/kivy/data' so I removed the extra '/electrum' and now it doesnt complain about that,

OSError: File electrum/gui/kivy/data/fonts/Roboto.ttf not found

Hmm thanks for finding these issues. They haven't been reported before as I guess the handful of people who run the kivy GUI on Linux desktop all run ./run_electrum directly from the git clone. I will see if they can be easily fixed.

SomberNight added a commit to SomberNight/electrum that referenced this issue Dec 10, 2020
When running kivy on Linux desktop,
running from git clone, `./run_electrum -g kivy` worked,
but `pip install -e .; electrum -g kivy` did not.
This was due to the relative paths using cwd as base.

see spesmilo#6835
@joshbowyer
Copy link
Author

Oh there is one more thing needed; Kivy isn't compiled with Wayland support but more devices are using it now (Pinephone/Pinebook/Librem5/etc). When building the image, Wayland should be enabled by installing Kivy from source (and not via pip) so that setup.py can be edited and c_options['use_wayland'] = False and c_options['use_sdl2'] = False can be set to true before compiling. Currently Electrum+Kivy installed as earlier in this thread works on my amd64 machine, but not on my arm64 device as it errors on the display (due to lack of Wayland)

@joshbowyer
Copy link
Author

Actually Im not sure about that last part, I tried making it run under Xwayland and its just a blank gray screen, but Ive been fighthing with kivy all day (i dont really know how to package things for debian properly...) so I havent been able to test with a Wayland-enabled kivy

@SomberNight
Copy link
Member

The kivy GUI was removed in favour of the qml GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants