tuomasjjrasanen / python-uinput

Pythonic API to Linux uinput module
http://tjjr.fi/sw/python-uinput/
GNU General Public License v3.0
289 stars 71 forks source link

sysconfig.get_config_var("SO") deprecated and removed in python 3.11 #44

Open donaldmunro opened 1 year ago

donaldmunro commented 1 year ago

sysconfig.get_config_var("SO") is used in init.py:

_libsuinput_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "_libsuinput" + sysconfig.get_config_var("SO")))

but returns None in python 3.11:

python --version
Python 3.11.3

python
Python 3.11.3 (main, Apr  5 2023, 15:52:25) [GCC 12.2.1 20230201] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> print(sysconfig.get_config_var("SO"))
None

leading to errors like:

Traceback (most recent call last):
  File "/usr/lib/keyboard-center/main.py", line 8, in <module>
    from mainUi import MainWindow
  File "/usr/lib/keyboard-center/mainUi.py", line 23, in <module>
    from devices.keyboard import SUPPORTED_DEVICES, KeyboardInterface
  File "/usr/lib/keyboard-center/devices/keyboard.py", line 1, in <module>
    import uinput
  File "/usr/lib/python3.11/site-packages/uinput/__init__.py", line 86, in <module>
    _libsuinput_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "_libsuinput" + sysconfig.get_config_var("SO")))
                                                                                     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

To fix change to

sysconfig.get_config_var("EXT_SUFFIX")
ehfd commented 11 months ago

https://github.com/selkies-project/python-uinput We accept pull requests.

rkmax commented 9 months ago

@ehfd yeah the fix was merged in your fork but version 0.11.3 is not published. could you please provide me instructions of how to install your version instead this one

ehfd commented 9 months ago

setup.cfg: python-uinput @ git+https://github.com/selkies-project/python-uinput.git@0.11.3

pip3 install git+https://github.com/selkies-project/python-uinput.git@0.11.3

@rkmax

Kuba314 commented 6 months ago

Btw I e-mailed the original author of the python-uinput project (this repo's owner) a month ago about this issue and they still haven't replied. What's weird is that the github account seems active.

ehfd commented 6 months ago

We have ultimately abandoned this codebase completely. Use python-evdev.

goncalopp commented 5 months ago

Merged in https://github.com/pyinput/python-uinput2 (with minor changes)

tuomasjjrasanen commented 5 months ago

I'm alive, see my comment: https://github.com/tuomasjjrasanen/python-uinput/issues/49#issuecomment-1951352788