Giter Site home page Giter Site logo

python-xkbcommon's People

Contributors

flacjacket avatar mbey-mw avatar sde1000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-xkbcommon's Issues

Tags/ releases missing in repository

Hi! I'm currently trying to package python-xkbcommon for Arch Linux.

Unfortunately this project is missing the tags that led to the sdist tarballs on pypi.org: https://pypi.org/project/xkbcommon/#history

Can you please tag the versions? This ensures transparency during bug reports and when building from source. Especially for downstream distributions this is very important to guard against supply chain attacks and to be able to run tests (currently I can not switch to an auto-generated github release tarball, which includes the tests, as there are none).

Thanks!

error at installation

Hello,
the installation of python-xkbcommon rebately fails i am using fedora 36. I attached an file with the error message.

error.txt

Tests missing in sdist tarballs on pypi.org

Hi! When trying to package version 0.3 of this project for Arch Linux I tried to run tests for it.
Unfortunately the tests are not contained in the sdist tarball and as there are no release tarballs on github either, I am unable to run tests.

It would be really awesome if you could add them (additionally to tagging the respective versions #9 ).

LICENSE missing in sdist tarball on pypi.org

Hi! The LICENSE file is missing in the sdist tarballs on pypi.org.

For Arch Linux (and other Linux distributions) it is a requirement to package the LICENSE file (especially when it is MIT) alongside the built files.

It would be really great if you could add it to the sdist tarballs (and also tag the versions in this repository #9).
Thanks! :)

setting up keyboard state from X11

How can I use this library to set up the keyboard state under X11. The X11 interface methods do not appear to be implemented.

The regular documentation for libxkbcommon says:

#include <xkbcommon/xkbcommon-x11.h>
 
xcb_connection_t *conn = <...>;
int32_t device_id;
 
device_id = xkb_x11_get_core_keyboard_device_id(conn);
if (device_id == -1) <error>
 
keymap = xkb_x11_keymap_new_from_device(ctx, conn, device_id,
                                        XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!keymap) <error>

but the xkb_x11 methods are not in this library as far as I can tell.

1.5.1: test_compose_table_new_from_locale hardcodes the use of en_GB.UTF-8

Hi! πŸ‘‹

I package this project for Arch Linux. When trying to upgrade to 1.5.1 I noticed that the test test_compose_table_new_from_locale hardcodes the use of en_GB.UTF-8.

This locale may not be readily available on downstreams by default and may not be settable without root rights (which our particular build environments don't have).

This leads to:

=================================== FAILURES ===================================
________________ TestContext.test_compose_table_new_from_locale ________________

self = <tests.test_xkb.TestContext testMethod=test_compose_table_new_from_locale>

    def test_compose_table_new_from_locale(self):
        ctx = xkb.Context()
>       ct = ctx.compose_table_new_from_locale("en_GB.UTF-8")

tests/test_xkb.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xkbcommon.xkb.Context object at 0x74387ca25880>, locale = 'en_GB.UTF-8'
flags = None

    def compose_table_new_from_locale(self, locale, flags=None):
        """Create a compose table for a given locale.

        The locale is used for searching the file-system for an
        appropriate Compose file. The search order is described in
        Compose(5). It is affected by the following environment
        variables:

        XCOMPOSEFILE - see Compose(5).

        XDG_CONFIG_HOME - before $HOME/.XCompose is checked,
        $XDG_CONFIG_HOME/XCompose is checked (with a fall back to
        $HOME/.config/XCompose if XDG_CONFIG_HOME is not
        defined). This is a libxkbcommon extension to the search
        procedure in Compose(5) (since libxkbcommon 1.0.0). Note that
        other implementations, such as libX11, might not find a
        Compose file in this path.

        HOME - see Compose(5).

        XLOCALEDIR - if set, used as the base directory for the
        system's X locale files, e.g. /usr/share/X11/locale, instead
        of the preconfigured directory.
        """
        c_locale = ffi.new("char[]", locale.encode())
        table = lib.xkb_compose_table_new_from_locale(
            self._context, c_locale, flags if flags else 0)
        if not table:
>           raise XKBComposeTableCreationFailure(
                f"Could not create compose table from locale '{locale}'")
E           xkbcommon.xkb.XKBComposeTableCreationFailure: Could not create compose table from locale 'en_GB.UTF-8'

xkbcommon/xkb.py:500: XKBComposeTableCreationFailure
----------------------------- Captured stderr call -----------------------------
xkbcommon: ERROR: couldn't find a Compose file for locale "en_GB.UTF-8" (mapped to "en_GB.UTF-8")
=========================== short test summary info ============================
FAILED tests/test_xkb.py::TestContext::test_compose_table_new_from_locale - x...
========================= 1 failed, 87 passed in 0.12s =========================

Is the use of en_GB.UTF-8 strictly necessary for that test? Would C.UTF-8 work too?

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

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.

tag-mismatch (HWAsan) on build from source

Dockerfile:

FROM ubuntu:24.04
RUN apt-get update -y && \
    apt-get install -y \
        autoconf \
        clang \
        clang-tools \
        curl \
        gcc \
        lld \
        libssl-dev \
        pkg-config \
        python3-dbg \
        python3-dev \
        python3-pip \
        python3-venv
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly -y
ENV PATH=/root/.cargo/bin:$PATH \
    CC=clang \
    CXX=clang++ \
    CFLAGS="-g -O0 -fsanitize=hwaddress -fuse-ld=lld -g" \
    CCFLAGS="-g -O0 -fsanitize=hwaddress -fuse-ld=lld -g" \
    CXXFLAGS="-g -O0 -fsanitize=hwaddress -fuse-ld=lld -g" \
    CPPFLAGS="-g -O0 -fsanitize=hwaddress -fuse-ld=lld -g" \
    LDFLAGS="-fsanitize=hwaddress -fuse-ld=lld" \
    LD_PRELOAD="/usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.hwasan-aarch64.so" \
    ASAN_OPTIONS="detect_leaks=0" \
    HWASAN_OPTIONS="detect_leaks=0"
$ docker build .
$ docker run --rm -it <name>
$ python3 -m venv venv
$ source venv/bin/activate
$ python3 --version
Python 3.12.3
$ pip3 install xkbcommon --no-binary ":all:"
Collecting xkbcommon
  Downloading xkbcommon-1.5.1.tar.gz (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.2/80.2 kB 1.3 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  Γ— Preparing metadata (pyproject.toml) did not run successfully.
  β”‚ exit code: 99
  ╰─> [104 lines of output]
      ==173==ERROR: HWAddressSanitizer: tag-mismatch on address 0xffffb1688560 at pc 0xffffb156640c
      READ of size 8 at 0xffffb1688560 tags: b0/00 (ptr/mem) in thread T0
          #0 0xffffb156640c in PyInit__cffi_backend /tmp/pip-install-iycvqhbt/cffi_90ebfd0ff8434d5ab44e8f3435752cb7/src/c/_cffi_backend.c:8038:9
          #1 0x66def0 in _PyImport_LoadDynamicModuleWithSpec /usr/src/python3.12-3.12.3-1/build-static/../Python/importdl.c:169:9
          #2 0x66d338 in _imp_create_dynamic_impl /usr/src/python3.12-3.12.3-1/build-static/../Python/import.c:3775:11
          #3 0x66d338 in _imp_create_dynamic /usr/src/python3.12-3.12.3-1/build-static/../Python/clinic/import.c.h:506:20
          #4 0x502d4c in cfunction_vectorcall_FASTCALL /usr/src/python3.12-3.12.3-1/build-static/../Objects/methodobject.c:422:24
          #5 0x5652ac in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:3254:26
          #6 0x4c2f00 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_call.h:92:11
          #7 0x4c2f00 in object_vacall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:850:14
          #8 0x4c4ae4 in PyObject_CallMethodObjArgs /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:911:24
          #9 0x58bee8 in import_find_and_load /usr/src/python3.12-3.12.3-1/build-static/../Python/import.c:2779:11
          #10 0x58bee8 in PyImport_ImportModuleLevelObject /usr/src/python3.12-3.12.3-1/build-static/../Python/import.c:2862:15
          #11 0x565f6c in import_name /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:2482:15
          #12 0x565f6c in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:2135:19
          #13 0x4c3ba0 in _PyFunction_Vectorcall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:419:16
          #14 0x4c3ba0 in _PyObject_FastCallDictTstate /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:133:15
          #15 0x4c3ba0 in _PyObject_Call_Prepend /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:508:24
          #16 0x521060 in slot_tp_init /usr/src/python3.12-3.12.3-1/build-static/../Objects/typeobject.c:9014:15
          #17 0x51c7a0 in type_call /usr/src/python3.12-3.12.3-1/build-static/../Objects/typeobject.c:1673:19
          #18 0x4c20c4 in _PyObject_MakeTpCall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:240:18
          #19 0x561d20 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:2706:19
          #20 0x560070 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_ceval.h:89:16
          #21 0x560070 in _PyEval_Vector /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:1683:12
          #22 0x560070 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:578:21
          #23 0x55d264 in builtin_exec_impl /usr/src/python3.12-3.12.3-1/build-static/../Python/bltinmodule.c:1096:17
          #24 0x55d264 in builtin_exec /usr/src/python3.12-3.12.3-1/build-static/../Python/clinic/bltinmodule.c.h:586:20
          #25 0x502a38 in cfunction_vectorcall_FASTCALL_KEYWORDS /usr/src/python3.12-3.12.3-1/build-static/../Objects/methodobject.c:438:24
          #26 0x4c2c78 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_call.h:92:11
          #27 0x4c2c78 in PyObject_Vectorcall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:325:12
          #28 0x561d20 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:2706:19
          #29 0x4c3ba0 in _PyFunction_Vectorcall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:419:16
          #30 0x4c3ba0 in _PyObject_FastCallDictTstate /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:133:15
          #31 0x4c3ba0 in _PyObject_Call_Prepend /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:508:24
          #32 0x521060 in slot_tp_init /usr/src/python3.12-3.12.3-1/build-static/../Objects/typeobject.c:9014:15
          #33 0x51c7a0 in type_call /usr/src/python3.12-3.12.3-1/build-static/../Objects/typeobject.c:1673:19
          #34 0x4c20c4 in _PyObject_MakeTpCall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:240:18
          #35 0x561d20 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:2706:19
          #36 0x560070 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_ceval.h:89:16
          #37 0x560070 in _PyEval_Vector /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:1683:12
          #38 0x560070 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:578:21
          #39 0x598ddc in run_eval_code_obj /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1722:9
          #40 0x598ddc in run_mod /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1743:19
          #41 0x598ddc in PyRun_StringFlags /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1618:15
          #42 0x55d318 in builtin_exec_impl /usr/src/python3.12-3.12.3-1/build-static/../Python/bltinmodule.c:1121:17
          #43 0x55d318 in builtin_exec /usr/src/python3.12-3.12.3-1/build-static/../Python/clinic/bltinmodule.c.h:586:20
          #44 0x502a38 in cfunction_vectorcall_FASTCALL_KEYWORDS /usr/src/python3.12-3.12.3-1/build-static/../Objects/methodobject.c:438:24
          #45 0x4c2c78 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_call.h:92:11
          #46 0x4c2c78 in PyObject_Vectorcall /usr/src/python3.12-3.12.3-1/build-static/../Objects/call.c:325:12
          #47 0x561d20 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1/build-static/Python/bytecodes.c:2706:19
          #48 0x560070 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1/build-static/../Include/internal/pycore_ceval.h:89:16
          #49 0x560070 in _PyEval_Vector /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:1683:12
          #50 0x560070 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1/build-static/../Python/ceval.c:578:21
          #51 0x598f70 in run_eval_code_obj /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1722:9
          #52 0x598f70 in run_mod /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1743:19
          #53 0x67e6f0 in pyrun_file /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:1643:15
          #54 0x67e2c4 in _PyRun_SimpleFileObject /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:433:13
          #55 0x67e090 in _PyRun_AnyFileObject /usr/src/python3.12-3.12.3-1/build-static/../Python/pythonrun.c:78:15
          #56 0x6890e8 in pymain_run_file_obj /usr/src/python3.12-3.12.3-1/build-static/../Modules/main.c:360:15
          #57 0x6890e8 in pymain_run_file /usr/src/python3.12-3.12.3-1/build-static/../Modules/main.c:379:15
          #58 0x6890e8 in pymain_run_python /usr/src/python3.12-3.12.3-1/build-static/../Modules/main.c:629:21
          #59 0x6890e8 in Py_RunMain /usr/src/python3.12-3.12.3-1/build-static/../Modules/main.c:709:5
          #60 0x688ca4 in Py_BytesMain /usr/src/python3.12-3.12.3-1/build-static/../Modules/main.c:763:12
          #61 0xffffb43384c0 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #62 0xffffb4338594 in __libc_start_main csu/../csu/libc-start.c:360:3
          #63 0x5f24ec in _start (/usr/bin/python3.12+0x5f24ec) (BuildId: 18160fe6beb052a7e6830ecc99e313a3498c377d)


      Thread: T0 0xeffe00002000 stack: [0xfffffbf7e000,0xfffffc77e000) sz: 8388608 tls: [0xffffb50ed460,0xffffb50ee320)

      Memory tags around the buggy address (one tag corresponds to 16 bytes):
        0xffffb1687d00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1687e00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1687f00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688000: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688100: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688200: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688300: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688400: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
      =>0xffffb1688500: 00  00  00  00  00  00 [00] 00  00  00  00  00  00  00  00  00
        0xffffb1688600: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688700: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688800: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688900: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688a00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688b00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688c00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
        0xffffb1688d00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
      Tags for short granules around the buggy address (one tag corresponds to 16 bytes):
        0xffffb1688400: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
      =>0xffffb1688500: ..  ..  ..  ..  ..  .. [..] ..  ..  ..  ..  ..  ..  ..  ..  ..
        0xffffb1688600: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
      See https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#short-granules for a description of short granule tags

      Registers where the failure occurred (pc 0xffffb156640c):
          x0  b000ffffb1688560  x1  0000000000000000  x2  0000000000000000  x3  0000000000000001
          x4  0000000000000002  x5  5300ed5e000b4100  x6  0000000000000006  x7  00000000000001d0
          x8  00000000000000b0  x9  0000000000000000  x10 00000ffffb168856  x11 0000000000000000
          x12 0000000000000000  x13 0000000000000000  x14 0000000000000000  x15 fffffffffffff000
          x16 0000ffffb463b7f0  x17 0000000000000007  x18 0000000000000004  x19 0000ffffb1760070
          x20 0200efff00000000  x21 0000ffffb16afa20  x22 0000ffffb17729a0  x23 0000000000000000
          x24 0000ffffb1772a50  x25 000000000070f5b8  x26 0000ffffb1565fb4  x27 0000ffffb17729c0
          x28 0000000000b8a278  x29 0000fffffc77afa0  x30 0000ffffb1566410   sp 0000fffffc77ae20
      SUMMARY: HWAddressSanitizer: tag-mismatch /tmp/pip-install-iycvqhbt/cffi_90ebfd0ff8434d5ab44e8f3435752cb7/src/c/_cffi_backend.c:8038:9 in PyInit__cffi_backend
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Originally found similar in cryptography pyca/cryptography#11217 and I tried another project (xkbcommon).

How to read unicode value for each keysym name (e.g. (XKB_KEY_)percent -> 0x0025)

Hello again,

at first I would like say thank you for your previous quick implementation/support. In the project, we would like to keep only 1 layout for each key composition and because of that I now find a way how I could from percent get unicode value 0x0025 for case layout does not return any keycode for percent so percent char could be send using unicode shortcut shift+ctrl+u+<0-F>. Could be this possible? Reading defines? (as workaround I see copy these defined values to the project directly what I do not prefer)

Example from libxkbcommon:

#define XKB_KEY_percent                       0x0025  /* U+0025 PERCENT SIGN */

Building wheel fails

Hi,

I am not sure what happened but the building wheel fails:

build/temp.linux-x86_64-cpython-310/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-310/xkbcommon._ffi.c:1017:12: note: each undeclared identifier is reported only once for each function it appears in
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

reported here.

I have not replicated the same problem in my environment, yet.

"TypeError: initializer for ctype 'char *' must be a cdata pointer, not bytes" when creating keymap

Hi. I tried to create a keymap with keymap_new_from_names but got error "TypeError: initializer for ctype 'char *' must be a cdata pointer, not bytes". Am I wrong to pass a string argument?

>>> from xkbcommon import xkb
>>> ctx = xkb.Context()
>>> ctx.keymap_new_from_names(layout="gb")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/matt/.local/lib/python3.7/site-packages/xkbcommon/xkb.py", line 297, in keymap_new_from_names
    names.layout = layout.encode()
TypeError: initializer for ctype 'char *' must be a cdata pointer, not bytes

Errors in testing

I am currently trying to package python-xkbcommon to void linux, but at the test it shows this:

============================= test session starts ==============================
platform linux -- Python 3.11.0, pytest-7.1.3, pluggy-1.0.0
rootdir: /builddir/python3-xkbcommon-0.4
collected 68 items

tests/test_xkb.py .......................................FF............. [ 79%]
............FF                                                           [100%]

=================================== FAILURES ===================================
_______________________ TestBitEnum.test_StateComponent ________________________

self = <tests.test_xkb.TestBitEnum testMethod=test_StateComponent>

    def test_StateComponent(self):
        a = xkb.XKB_STATE_MODS_DEPRESSED
        b = xkb.XKB_STATE_MODS_LATCHED
        self.assertIsInstance(a | b, xkb.StateComponent)
>       self.assertEqual(str(a | b),
                         "StateComponent.XKB_STATE_MODS_LATCHED|XKB_STATE_MODS_DEPRESSED")
E       AssertionError: '3' != 'StateComponent.XKB_STATE_MODS_LATCHED|XKB_STATE_MODS_DEPRESSED'
E       - 3
E       + StateComponent.XKB_STATE_MODS_LATCHED|XKB_STATE_MODS_DEPRESSED

tests/test_xkb.py:232: AssertionError
_________________________ TestBitEnum.test_StateMatch __________________________

self = <tests.test_xkb.TestBitEnum testMethod=test_StateMatch>

    def test_StateMatch(self):
>       self.assertEqual(
            str(xkb.XKB_STATE_MATCH_ANY|xkb.XKB_STATE_MATCH_ALL
                |xkb.XKB_STATE_MATCH_NON_EXCLUSIVE),
            "StateMatch.XKB_STATE_MATCH_NON_EXCLUSIVE"
            "|XKB_STATE_MATCH_ALL"
            "|XKB_STATE_MATCH_ANY")
E       AssertionError: '65539' != 'StateMatch.XKB_STATE_MATCH_NON_EXCLUSIVE|[35 chars]_ANY'
E       - 65539
E       + StateMatch.XKB_STATE_MATCH_NON_EXCLUSIVE|XKB_STATE_MATCH_ALL|XKB_STATE_MATCH_ANY

tests/test_xkb.py:239: AssertionError
___________________ TestKeyboardState.test_state_update_key ____________________

self = <tests.test_xkb.TestKeyboardState testMethod=test_state_update_key>

    def test_state_update_key(self):
        state = self.km.state_new()
        self.assertEqual(
            state.mod_name_is_active("Lock", xkb.XKB_STATE_MODS_LOCKED),
            False)
        keydown = state.update_key(self.capslock, xkb.XKB_KEY_DOWN)
>       self.assertEqual(
            str(keydown),
            "StateComponent.XKB_STATE_LEDS"
            "|XKB_STATE_MODS_EFFECTIVE"
            "|XKB_STATE_MODS_LOCKED"
            "|XKB_STATE_MODS_DEPRESSED")
E       AssertionError: '269' != 'StateComponent.XKB_STATE_LEDS|XKB_STATE_M[56 chars]SSED'
E       - 269
E       + StateComponent.XKB_STATE_LEDS|XKB_STATE_MODS_EFFECTIVE|XKB_STATE_MODS_LOCKED|XKB_STATE_MODS_DEPRESSED

tests/test_xkb.py:269: AssertionError
___________________ TestKeyboardState.test_state_update_mask ___________________

self = <tests.test_xkb.TestKeyboardState testMethod=test_state_update_mask>

    def test_state_update_mask(self):
        master_state = self.km.state_new()
        slave_state = self.km.state_new()
        master_state.update_key(self.capslock, xkb.XKB_KEY_DOWN)
        master_state.update_key(self.capslock, xkb.XKB_KEY_UP)
        depressed_mods = master_state.serialize_mods(
            xkb.XKB_STATE_MODS_DEPRESSED)
        latched_mods = master_state.serialize_mods(
            xkb.XKB_STATE_MODS_LATCHED)
        locked_mods = master_state.serialize_mods(
            xkb.XKB_STATE_MODS_LOCKED)
        depressed_layout = master_state.serialize_layout(
            xkb.XKB_STATE_LAYOUT_DEPRESSED)
        latched_layout = master_state.serialize_layout(
            xkb.XKB_STATE_LAYOUT_LATCHED)
        locked_layout = master_state.serialize_layout(
            xkb.XKB_STATE_LAYOUT_LOCKED)
        self.assertEqual(
            slave_state.mod_name_is_active("Lock", xkb.XKB_STATE_MODS_LOCKED),
            False)
        r = slave_state.update_mask(
            depressed_mods, latched_mods, locked_mods,
            depressed_layout, latched_layout, locked_layout)
>       self.assertEqual(
            str(r),
            "StateComponent.XKB_STATE_LEDS"
            "|XKB_STATE_MODS_EFFECTIVE"
            "|XKB_STATE_MODS_LOCKED")
E       AssertionError: '268' != 'StateComponent.XKB_STATE_LEDS|XKB_STATE_MODS_EFFECTIVE|XKB_STATE_MODS_LOCKED'
E       - 268
E       + StateComponent.XKB_STATE_LEDS|XKB_STATE_MODS_EFFECTIVE|XKB_STATE_MODS_LOCKED

tests/test_xkb.py:308: AssertionError
=========================== short test summary info ============================
FAILED tests/test_xkb.py::TestBitEnum::test_StateComponent - AssertionError: ...
FAILED tests/test_xkb.py::TestBitEnum::test_StateMatch - AssertionError: '655...
FAILED tests/test_xkb.py::TestKeyboardState::test_state_update_key - Assertio...
FAILED tests/test_xkb.py::TestKeyboardState::test_state_update_mask - Asserti...
========================= 4 failed, 64 passed in 0.27s =========================

Unfortunately, there seems to be no documentation on installing from source, so i think i cannot fix this issue on my on, so i am asking for help

Errors installing v1.5 via pip on multiple distros

@sde1000 @flacjacket @mbey-mw

Somebody using a project of mine that installs xkbcommon in a Python virtual environment filed a report this morning about a weird installation error on Ubuntu 20.04. I was able to replicate on Ubuntu, and just kind of assumed the libxkbcommon on Ubuntu 20.04 was too old for the latest xkbcommon release, even though that didn't make too much sense. So I pinned the version to something older for Ubuntu 20.04 and it started working again.

But then I tested other distros and I've been running into the same error, where previously I was installing xkbcommon without any issue on distros as old as CentOS 7, as long as the libxkbcommon development package was installed.

For now, I'm pinning the version to avoid the new 1.5 release.

xkbcommon<1.5

This makes the install use the 1.0.1 version that was released on the same day. Yesterday.

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

Since I don't know exactly what is going wrong, I'm hesitant to rely on that. I'm thinking about pinning to the 1.0.1 release explicitly until I know more about the cause of this problem.

The error messages go like this, during installing packages in the venv with pip.

Collecting xkbcommon
  Downloading xkbcommon-1.5.tar.gz (79 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.9/79.9 kB 384.0 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done

...
[lots of other pip packages downloading/installing]
...

Building wheels for collected packages: dbus-python, systemd-python, pygobject, xkbcommon, inotify-simple, evdev
  Building wheel for dbus-python (pyproject.toml) ... done
  Created wheel for dbus-python: filename=dbus_python-1.3.2-cp38-cp38-linux_x86_64.whl size=125039 sha256=79164b04108e2524fc2b2836bb6c38b7b208f4d4b2a185fe658ba3e27909e968
  Stored in directory: /home/testuser/.cache/pip/wheels/ee/6d/3b/ba4374f33fc6b6c2147f5434a897800f99a6eb2a2250714829
  Building wheel for systemd-python (setup.py) ... done
  Created wheel for systemd-python: filename=systemd_python-235-cp38-cp38-linux_x86_64.whl size=185184 sha256=94ad68b89d02d752b0bcb4cef5f0af74ddc4a8e39c6ac11a0cd6cf893ebd179e
  Stored in directory: /home/testuser/.cache/pip/wheels/40/5b/21/f6b14253e0aa61edffdac63d5ddeeb25f1c092f2259ec6ab6e
  Building wheel for pygobject (pyproject.toml) ... done
  Created wheel for pygobject: filename=PyGObject-3.44.1-cp38-cp38-linux_x86_64.whl size=895199 sha256=241f5af85470028ca1c280258c5227058182e0ab891c0a77e82d72774929af90
  Stored in directory: /home/testuser/.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/testuser/.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 '/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=fc56c2245113704c99c39176c96f15d7d913fe99201644bcd03144e58f5ce156
  Stored in directory: /home/testuser/.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=108600 sha256=eff409dc98f3734f75572e4c319d4f72ee68eda01064f4dbcd9785bd1b9eb311
  Stored in directory: /home/testuser/.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)

I have a wide selection of different distros I have to keep this working on, if I'm going to use this Python module. Just want to know what's happening here.

Bindings for libxkbregistry

Thank you for the bindings, I've found them useful. Do you plan to include similar bindings for libxkbregistry?

https://xkbcommon.org/doc/current/group__registry.html

The libxkbregistry API to query for available rules, models, layouts, variants and options (RMLVO). libxkbregistry is a separate library to libxkbcommon. This library is the replacement for clients currently parsing evdev.xml directly.

https://github.com/xkbcommon/libxkbcommon/blob/master/PACKAGING

libxkbregistry is a sublibrary of libxkbcommon and cannot be built without building libxbkcommon. The files produced are otherwise independent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.