flacjacket / pywlroots

Python binding to the wlroots library using cffi
University of Illinois/NCSA Open Source License
51 stars 12 forks source link

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

Closed SortedShuffle closed 5 months ago

SortedShuffle commented 5 months ago

Hello, thank you for making such a great project open source! I have an issue when installing pywlroots on OpenSuse. I've succsessfully installed the py packages cffi, cairocffi and libraries libwlroots, libwlroots-devel, libxkbcommon and libxkbcommon-devel. I've installed the package inside a virtual environment and get the following error:

linux@localhost:~/git/qtile> ./venv/bin/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.

heuer commented 5 months ago

I guess the libxkbcommon-devel package is missing. What's the result of

zypper search -i libxkbcommon

In addition, you're using the virtual environment not correctly. If you created the virtual environment in .venv you'll have to activate it:

source .venv/bin/activate

After the activation, you can use pip without the .venv/bin path:

pip install pywlroots

Complete, minimal example how to create a venv and install pywlroots:

mkdir test-pywlr
cd test-pywlr
python -m venv .venv
source .venv/bin/activate
pip install pywlroots
SortedShuffle commented 5 months ago

Thank you for helping me out. zypper search -i libxkbcommon returns:

linux@localhost:~/git/qtile> sudo zypper search -i libxkbcommon
[sudo] password for root:
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

By activating and using the environment correctly nothing changes. The error persists.

heuer commented 5 months ago

Which SUSE version do you use?

SortedShuffle commented 5 months ago

I am using opensuse Tumbleweed.

linux@localhost:~> cat /etc/os-release
NAME="openSUSE Tumbleweed"
#VERSION="20240329"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20240329"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
#CPE 2.3 format, boo#1217921
CPE_NAME="cpe:2.3:0:opensuse: tumbleweed:20240329:*:*:*:*:*:*:*
#CPE 2.2 format
#CPE_NAME="cpe:/o:opensuse: tumbleweed:20240329"
BUG_REPORT_URL="https://bugzilla.opensuse.org"
SUPPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
LOGO="distributor-logo-Tumbleweed"
heuer commented 5 months ago

opensuse Tumbleweed.

Thanks. I can confirm the issue, I just installed Tumbleweed in a VM and I get the same error.

Unfortunately, I'm not familiar with OpenSUSE Tumbleweed, so I can't really help you.

I think the python-xkbcommon project is the right contact for the problem, because the installation (without Qtile and without pywlroots and without pywayland) of

pip install xkbcommon

fails.

Does Tumbleweed perhaps have a package like python3-xkbcommon that you can install globally with zypper so that the lib no longer needs to be installed with pip?

Sorry I can't help, but I would have to spend too much time getting to grips with OpenSUSE.

SortedShuffle commented 5 months ago

Super! Thank you for your time and help! I will try asking python-xkbcommon. Have a great Sunday.

heuer commented 5 months ago

No problem.

Please close the issue here, this seems to be an OpenSuse issue that does not directly affect pywlroots, if I understood https://github.com/sde1000/python-xkbcommon/issues/18 correctly.

SortedShuffle commented 5 months ago

Linking /usr/include/libxkbcommon/xkbcommon to /usr/include/xkbcommon solved the issue. Have a great day!