boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.76k stars 433 forks source link

dumpkeys tries to run during pip install on linux #563

Closed Avasam closed 1 year ago

Avasam commented 2 years ago

dumpkeys tries to run when doing pip install git+https://github.com/boppreh/keyboard.git#egg=keyboard This leads to issues with github actions since I cannot add the running user to the input and tty groups (group changes are not affected until the user session is restarted).

I cannot sudo pip install either because that breaks Pyright's ability to find modules and Pyinstaller's module collection. As the warning WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv hints at.

https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:16

Collecting keyboard
  Cloning https://github.com/boppreh/keyboard.git to /tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3325
  Running command git clone --filter=blob:none --quiet https://github.com/boppreh/keyboard.git /tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e14[18](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:19)abd2f2b0ad60b3325
  Resolved https://github.com/boppreh/keyboard.git to commit 8ea01e14fc823bae07[20](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:21)b9989afed3f6b966c697
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      /tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3325/keyboard/_nixkeyboard.py:1[22](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:23): UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
        device = aggregate_devices('kbd')
      Couldn't get a file descriptor referring to the console.
      Traceback (most recent call last):
        File "/tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3325/keyboard/_nixkeyboard.py", line 73, in build_tables
          dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
        File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/subprocess.py", line 420, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/subprocess.py", line 5[24](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:25), in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['dumpkeys', '--keys-only']' returned non-zero exit status 1.

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b33[25](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:26)/setup.py", line 7, in <module>
          import keyboard
        File "/tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3325/keyboard/__init__.py", line 241, in <module>
          _os_keyboard.init()
        File "/tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3325/keyboard/_nixkeyboard.py", line 1[26](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:27), in init
          build_tables()
        File "/tmp/pip-install-h8ccibra/keyboard_7f4dd7e9b5e1418abd2f2b0ad60b3[32](https://github.com/Toufool/Auto-Split/runs/7545894064?check_suite_focus=true#step:6:33)5/keyboard/_nixkeyboard.py", line 76, in build_tables
Error:           raise ValueError('Failed to run dumpkeys to get key names. Check if your user is part of the "tty" group, and if not, add it with "sudo usermod -a -G tty USER".')
      ValueError: Failed to run dumpkeys to get key names. Check if your user is part of the "tty" group, and if not, add it with "sudo usermod -a -G tty USER".
      # ERROR: Failed to read device '/dev/input/event0'. You must be in the 'input' group to access global events. Use 'sudo usermod -a -G input USERNAME' to add user to the required group.
      # ERROR: Failed to read device '/dev/input/event1'. You must be in the 'input' group to access global events. Use 'sudo usermod -a -G input USERNAME' to add user to the required group.
      # ERROR: Failed to read device '/dev/input/event2'. You must be in the 'input' group to access global events. Use 'sudo usermod -a -G input USERNAME' to add user to the required group.
      [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.