python-evdev icon indicating copy to clipboard operation
python-evdev copied to clipboard

ecodes misses UInput Constants

Open antheas opened this issue 11 months ago • 12 comments

My software now has errors such as the following:

<class 'AttributeError'>: module 'evdev.ecodes' has no attribute 'UI_FF_UPLOAD'

IE uinput constants are missing

python-evdev 1.9 got pushed to fedora and arch so I am currently rushing for a mitigation

I also get squiglies everywhere in VS Code now:

Image

So, what am I to do with this?

antheas avatar Feb 20 '25 17:02 antheas

latter part is dupe of https://github.com/gvalkov/python-evdev/pull/236

antheas avatar Feb 20 '25 17:02 antheas

It's probably due to using an ancient kernel to build the wheels

antheas avatar Feb 20 '25 17:02 antheas

Botch complete:

    try:
        # .ecodes misses UInput stuff, grab from runtime if it exists
        import evdev.ecodes_runtime as ecodes_runtime

        return cast(int, getattr(ecodes_runtime, b))
    except Exception:
        pass

    return cast(int, getattr(evdev.ecodes, b))

antheas avatar Feb 20 '25 17:02 antheas

Hi, sorry, what do you mean with

latter part is dupe of https://github.com/gvalkov/python-evdev/pull/236

and

Botch complete:

?

sezanzeb avatar Feb 20 '25 22:02 sezanzeb

I made a fix for my package. But currently evdev.ecodes is missing uinput attrs on arch, fedora, and the wheel

antheas avatar Feb 20 '25 22:02 antheas

latter part is dupe of https://github.com/gvalkov/python-evdev/pull/236

Squiggles on VS code are due to the same issue as that one

antheas avatar Feb 20 '25 22:02 antheas

latter part is dupe of #236

Squiggles on VS code are due to the same issue as that one

So you are getting something like

compatibility_device.py:4: error: Module "evdev" does not explicitly export attribute "InputDevice"  [attr-defined]

?

Didn't #236 fix that?

sezanzeb avatar Feb 20 '25 22:02 sezanzeb

I did not test master. Hopefully it does (seems that it will). However, the issue is cosmetic and I can live with it for now.

The uinput issue caused a breakage and i had to push an emergency update

antheas avatar Feb 20 '25 22:02 antheas

Ah ok.

I can confirm that UI_FF_UPLOAD is missing on my machine:

>>> from evdev.ecodes import UI_FF_UPLOAD
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'UI_FF_UPLOAD' from 'evdev.ecodes' (/usr/local/lib/python3.12/dist-packages/evdev/ecodes.py)
>>> from evdev.ecodes import KEY_A
>>> 

And it seems commit https://github.com/gvalkov/python-evdev/commit/61beda72e7b101e270f914d5f1d633730e60d083 broke it.

Works on 3ff9816:

➜  python-evdev git:(3ff9816) ✗ python3 -c "from evdev.ecodes import UI_FF_UPLOAD"

Breaks after checking out to 61beda72e7b101e270f914d5f1d633730e60d083:

➜  python-evdev git:(3ff9816) ✗ git checkout 61beda72e7b101e270f914d5f1d633730e60d083
Previous HEAD position was 3ff9816 Fix ecodes.c generation
HEAD is now at 61beda7 Move from flat-layout to src-layout
➜  python-evdev git:(61beda7) ✗ sudo pip install . --break-system-packages
DEPRECATION: Loading egg at /usr/local/lib/python3.12/dist-packages/evdev-1.8.0-py3.12-linux-x86_64.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
Processing /mnt/data/Code/python-evdev
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: evdev
  Building wheel for evdev (pyproject.toml) ... done
  Created wheel for evdev: filename=evdev-1.8.0-cp312-cp312-linux_x86_64.whl size=114272 sha256=edeed36af7715cb8417685de073b8d05176f7c48da06cdb12cbdaa68fc460bb8
  Stored in directory: /root/.cache/pip/wheels/2e/97/d6/f9226942d8cb19f6194457f5d4583aef9b6f42fc1f2de7c7fb
Successfully built evdev
Installing collected packages: evdev
  Attempting uninstall: evdev
    Found existing installation: evdev 1.8.0
    Uninstalling evdev-1.8.0:
      Successfully uninstalled evdev-1.8.0
Successfully installed evdev-1.8.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
➜  python-evdev git:(61beda7) ✗ python3 -c "from evdev.ecodes import UI_FF_UPLOAD"   
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'UI_FF_UPLOAD' from 'evdev.ecodes' (/usr/local/lib/python3.12/dist-packages/evdev/ecodes.py)
➜  python-evdev git:(61beda7) ✗ 

sezanzeb avatar Feb 20 '25 22:02 sezanzeb

No, it was 4ca0a8b, sorry, I accidentally imported the root-level evdev folder that didn't exist anymore from https://github.com/gvalkov/python-evdev/commit/61beda72e7b101e270f914d5f1d633730e60d083, which made it work again.

sezanzeb avatar Feb 21 '25 07:02 sezanzeb

Fixed in a98b68f9ac7ac32dbd175f6090e2458ec612f75c. I'll make a release this weekend.

gvalkov avatar Feb 22 '25 09:02 gvalkov

Release 1.9.1 is out. It should land in Fedora 41 stable in one week (bodhi link).

gvalkov avatar Feb 23 '25 20:02 gvalkov