sde1000 / python-xkbcommon

Python bindings for libxkbcommon using cffi
MIT License
19 stars 5 forks source link

fatal error: xkbcommon/xkbcommon.h: No such file or directory. #18

Closed SortedShuffle closed 7 months ago

SortedShuffle commented 7 months ago

I have an issue when installing xkbcommon on OpenSuse Tumbleweed. I've succsessfully installed the libraries libxkbcommon and libxkbcommon-devel.

zypper search -i libxkbcommon returns:

linux@localhost:~/git/qtile> sudo zypper search -i libxkbcommon
Loading repository data...
Reading installed packages...

S  | Name                               | Summary                                             | Type
---+------------------------------------+-----------------------------------------------------+--------
i  | libxkbcommon-devel                 | Development files for the libxkbcommon library      | package
i+ | libxkbcommon-tools                 | Utilities from xkbcommon                            | package
i  | libxkbcommon-tools-bash-completion | Bash completion for libxkbcommon-tools              | package
i  | libxkbcommon-x11-0                 | Library for handling xkb descriptions using XKB-X11 | package
i  | libxkbcommon0                      | Library for handling xkb descriptions               | package

I've installed the package inside a virtual environment and get the following error:

(venv) linux@localhost:~/git/qtile> pip install xkbcommon
Collecting xkbcommon
  Using cached xkbcommon-0.8.tar.gz (28 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.5.0 in ./venv/lib64/python3.11/site-packages (from xkbcommon) (1.16.0)
Requirement already satisfied: pycparser in ./venv/lib64/python3.11/site-packages (from cffi>=1.5.0->xkbcommon) (2.22)
Building wheels for collected packages: xkbcommon
  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
  ╰─> [21 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/xkbcommon
      copying xkbcommon/__init__.py -> build/lib.linux-x86_64-cpython-311/xkbcommon
      copying xkbcommon/ffi_build.py -> build/lib.linux-x86_64-cpython-311/xkbcommon
      copying xkbcommon/xkb.py -> build/lib.linux-x86_64-cpython-311/xkbcommon
      running build_ext
      generating cffi module 'build/temp.linux-x86_64-cpython-311/xkbcommon._ffi.c'
      creating build/temp.linux-x86_64-cpython-311
      building 'xkbcommon._ffi' extension
      creating build/temp.linux-x86_64-cpython-311/build
      creating build/temp.linux-x86_64-cpython-311/build/temp.linux-x86_64-cpython-311
      gcc -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -I/home/linux/git/qtile/venv/include -I/usr/include/python3.11 -c build/temp.linux-x86_64-cpython-311/xkbcommon._ffi.c -o build/temp.linux-x86_64-cpython-311/build/temp.linux-x86_64-cpython-311/xkbcommon._ffi.o
      build/temp.linux-x86_64-cpython-311/xkbcommon._ffi.c:571:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
        571 | #include <xkbcommon/xkbcommon.h>
            |          ^~~~~~~~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/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
Failed to build xkbcommon
ERROR: Could not build wheels for xkbcommon, which is required to install pyproject.toml-based projects

I suppose it its a linking problem but I am unable to find the correct solution. Thank you for your help.

sde1000 commented 7 months ago

Hmm. I'm not an OpenSuse user so I don't know the details of their tools.

It looks like the build process can't find xkbcommon.h, which I would expect to be in the libxkbcommon-devel package. Can you list the files in that package?

SortedShuffle commented 7 months ago

running rpm -ql libxkbcommon-devel i obtain:

linux@localhost:~>rpm -ql libxkbcommon-devel
/usr/include/libxkbcommon
/usr/include/libxkbcommon/xkbcommon
/usr/include/libxkbcommon/xkbcommon/xkbcommon-compat.h
/usr/include/libxkbcommon/xkbcommon/xkbcommon-compose.h
/usr/include/libxkbcommon/xkbcommon/xkbcommon-keysyms.h
/usr/include/libxkbcommon/xkbcommon/xkbcommon-names.h
/usr/include/libxkbcommon/xkbcommon/xkbcommon.h
/usr/include/libxkbcommon/xkbcommon/xkbregistry.h
/usr/lib64/libxkbcommon.so
/usr/lib64/pkgconfig/xkbcommon.pc
/usr/share/doc/packages/xkbcommon-devel
/usr/share/doc/packages/xkbcommon-devel/NEWS.md

The header file looks to be there...

sde1000 commented 7 months ago

That's odd!

On all the other systems I've seen, it's /usr/include/xkbcommon/xkbcommon.h.

Does OpenSuse have a different convention, or is this just a bug in the libxkbcommon-devel package?

It looks like other projects are running into this issue too, eg. https://github.com/espanso/espanso/issues/995

SortedShuffle commented 7 months ago

I am not expert enough to answer about opensuse conventions but linking the contents of /usr/include/libxkbcommon/ to /usr/include/xkbcommon solved the issue. Thank you for your help and have a great day.

jengelh commented 2 months ago

Does OpenSuse have a different convention, or is this just a bug in the libxkbcommon-devel package?

libxkbcommon provides a .pc file, which in itself is a sign it ought to be used (much like traditioanl /usr/bin/something-config scripts). python-xkbcommon fails to do that, so that's a bug/shortcoming in python-xkbcommon.