RedBearAK / toshy

Keymapper config to make Linux work like a 'Tosh!
https://toshy.app
GNU General Public License v3.0
242 stars 15 forks source link

Failed building wheel for xkbcommon #305

Closed ssaidnabiev closed 1 week ago

ssaidnabiev commented 1 week ago

Linux distro name: Ubuntu 20.04 Desktop environment(s): LXDE DE version(s): last

Keyboard type (Apple):


Problem observed:

Building wheel for xkbcommon (pyproject.toml) ... error ERROR: Failed building wheel for xkbcommon ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (xkbcommon) Error installing/upgrading Python packages. Installer exiting.

bd252a46aee637968e225477263
  Stored in directory: /home/saidazim/.cache/pip/wheels/b0/b5/51/317e6588f7bda212431c770cc26c930e88673899b6f372b254
  Building wheel for xkbcommon (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for xkbcommon (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/xkbcommon
      copying xkbcommon/__init__.py -> build/lib.linux-x86_64-cpython-38/xkbcommon
      copying xkbcommon/ffi_build.py -> build/lib.linux-x86_64-cpython-38/xkbcommon
      copying xkbcommon/xkb.py -> build/lib.linux-x86_64-cpython-38/xkbcommon
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      generating cffi module 'build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c'
      creating build/temp.linux-x86_64-cpython-38
      building 'xkbcommon._ffi' extension
      creating build/temp.linux-x86_64-cpython-38/build
      creating build/temp.linux-x86_64-cpython-38/build/temp.linux-x86_64-cpython-38
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/saidazim/.config/toshy/.venv/include -I/usr/include/python3.8 -c build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c -o build/temp.linux-x86_64-cpython-38/build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.o
      build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c: In function ‘_cffi_const_XKB_CONTEXT_NO_SECURE_GETENV’:
      build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c:1017:12: error: ‘XKB_CONTEXT_NO_SECURE_GETENV’ undeclared (first use in this function); did you mean ‘_cffi_const_XKB_CONTEXT_NO_SECURE_GETENV’?
       1017 |   int n = (XKB_CONTEXT_NO_SECURE_GETENV) <= 0;
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |            _cffi_const_XKB_CONTEXT_NO_SECURE_GETENV
      build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c:1017:12: note: each undeclared identifier is reported only once for each function it appears in
      build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c: In function ‘_cffi_d_xkb_keymap_key_get_mods_for_level’:
      build/temp.linux-x86_64-cpython-38/xkbcommon._ffi.c:2760:10: warning: implicit declaration of function ‘xkb_keymap_key_get_mods_for_level’; did you mean ‘xkb_keymap_key_get_syms_by_level’? [-Wimplicit-function-declaration]
       2760 |   return xkb_keymap_key_get_mods_for_level(x0, x1, x2, x3, x4, x5);
            |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |          xkb_keymap_key_get_syms_by_level
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for xkbcommon
  Building wheel for inotify-simple (setup.py) ... done
  Created wheel for inotify-simple: filename=inotify_simple-1.3.5-py3-none-any.whl size=7685 sha256=7a6779c517b0f779b07cb3374ef224e2eb9799d5d0f7eb6a4d6231bba6695a5e
  Stored in directory: /home/saidazim/.cache/pip/wheels/85/b2/be/354e28439e9b15a9a77924041be045e499f11bb03493529246
  Building wheel for evdev (pyproject.toml) ... done
  Created wheel for evdev: filename=evdev-1.7.1-cp38-cp38-linux_x86_64.whl size=108598 sha256=3541e416d81cde0883ca98ebcc6184e64940b3049d38a718e1fc4038bc982859
  Stored in directory: /home/saidazim/.cache/pip/wheels/40/a7/e8/d118cb622045826cc85b320ab9f6ebe89d9b88f2e8150be72d
Successfully built dbus-python systemd-python pygobject inotify-simple evdev
Failed to build xkbcommon
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (xkbcommon)
Error installing/upgrading Python packages. Installer exiting.
RedBearAK commented 1 week ago

@ssaidnabiev

I guess KDE Neon is not an adequate test bed for Ubuntu 20.04 (they recently rebased onto 22.04, I think). But I hadn't had much trouble with xkbcommon testing all the way back to CentOS 7, which is much older than Ubuntu 20.04.

You can remove xkbcommon, since it isn't necessary yet.

Find this in the setup_toshy.py file, which can be opened with any plain text editor or code editor (not a word processor like LibreOffice Writer):

pip_pkgs   = [

    # Pinned pygobject to 3.44.1 (or earlier) to get through install on RHEL 8.x and clones
    "lockfile", "dbus-python", "systemd-python", "pygobject<=3.44.1", "tk",
    "sv_ttk", "watchdog", "psutil", "xkbcommon",

Make the last line of it look like this:

pip_pkgs   = [

    # Pinned pygobject to 3.44.1 (or earlier) to get through install on RHEL 8.x and clones
    "lockfile", "dbus-python", "systemd-python", "pygobject<=3.44.1", "tk",
    "sv_ttk", "watchdog", "psutil", #  "xkbcommon",

This will bypass the attempt to install xkbcommon. That was the only new thing that I can think of, so it should be fine after that.

I want to try to replicate your environment when I have some time to test. You installed regular Ubuntu 20.04 and then LXDE afterward? You're not on Lubuntu 20.04? And I need to know if you did a "minimal" install. There are often packages missing in the "minimal" install.

RedBearAK commented 1 week ago

@ssaidnabiev

I think I figured out the problem, which is that the libxkbcommon-dev package on Ubuntu 20.04 is too old to be compatible with the latest xkbcommon pip package. I pinned xkbcommon to an earlier version (<0.5) and was able to get through the installer. This is weird, because I didn't even need to pin that package version for CentOS 7, which is ancient.

Ubuntu 20.04 also still uses Python 3.8, which is kind of shocking to me. That's the bare minimum Python version needed to run the keymapper. But everything seems to work, including the beta Python script that uses xkbcommon to grab the keyboard layout list. It's not a necessary, or even useful, part of the program yet, which is why you can remove it.

I'll have to put in a "quirks" handler for Ubuntu 20.04, added to the list of quirks handlers for other distros, and supporting anything earlier like Ubuntu 18.04 LTS might be a bit difficult without just leaving xkbcommon out entirely.

Thanks for the report, sorry about the lack of testing on that specific older version. Ubuntu 20.04 is end-of-life for regular users but I know it's still supported for a few more years on extended contracts. I'd recommend at least upgrading to 22.04 LTS if you have a chance.

RedBearAK commented 1 week ago

Note to self:

Using any xkbcommon version less than 1.5 also seems to work. Last release before 1.5 was 1.0.1, so that's what gets installed.

pip_pkgs   = [

    # Pinned pygobject to 3.44.1 (or earlier) to get through install on RHEL 8.x and clones
    "lockfile", "dbus-python", "systemd-python", "pygobject<=3.44.1", "tk",
    "sv_ttk", "watchdog", "psutil", "xkbcommon<1.5",

This seems contrary to the version compatibility note on PyPi.org for versions 0.5 and later, but it works.

RedBearAK commented 1 week ago

@ssaidnabiev

I think you just coincidentally were the first one to report this, and it has nothing to do with Ubuntu 20.04. I've now encountered this problem with xkbcommon on multiple distros that were previously working fine.

I'm guessing it has to do with the new release(s) of xkbcommon that dropped, quite literally, yesterday, on the 5th.

https://pypi.org/project/xkbcommon/#history

Looks like the sensible thing for the moment is to pin xkbcommon for every distro, just like I did in the previous comment.

I'll update things when I find out more about what's going on.

RedBearAK commented 1 week ago

Asked on the python-xkbcommon GitHub repo for any info they can give regarding what is causing this error. Whether it's a bug or I'm doing something wrong. We'll see what they say.

https://github.com/sde1000/python-xkbcommon/issues/23

Meanwhile, I'm pinning to v1.0.1 for all distros for now.

RedBearAK commented 1 week ago

On advice from the owner of the python-xkbcommon repo, I'll be changing the version pinning to xkbcommon<1.1 so that any updates of the 1.0 series will be allowed to install, but nothing 1.1 or later that might have breaking API changes.

ssaidnabiev commented 1 week ago

@RedBearAK adding "<1.5" solved the problem with xkbcommon toshy has been installed now, no reboot was required, tray icon came up on the app indicator, tried app switching, copying and pasting, works fine you can close this issue with your final comments or leave it open until you come up with a perfect universal solution. thanks for responsiveness and support

RedBearAK commented 1 week ago

That's good news. Open another issue if you have any specific problems.

I'll keep this open until I do a bit more testing and merge all the fixes for other things that came up while I was dealing with the xkbcommon issue. Should be done shortly.

RedBearAK commented 1 week ago

Solution merged into main branch. Closing this as resolved.