Skip to content

Commit 0e1e0be

Browse files
authored
pyproject.toml, new installation tool, improve github workflows (#1221)
1 parent d011005 commit 0e1e0be

38 files changed

+749
-632
lines changed

.github/workflows/installation.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Installation
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
deb:
7+
runs-on: ubuntu-latest
8+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Install .deb
12+
run: |
13+
sudo apt update
14+
15+
# build dependencies
16+
sudo apt install gettext -y
17+
18+
sudo scripts/build-deb.sh
19+
find build
20+
sudo apt install -f ./dist/input-remapper-*.deb
21+
- name: DBus Hello
22+
run: |
23+
# Test if files have been placed at the correct places in ubuntus file system.
24+
# By sending the hello command, we tests the service file, binaries and module
25+
26+
# Make sure we aren't just importing the module from the cloned repo in the
27+
# cwd. Commands should import the installed package
28+
cd /
29+
[ ! -d "inputremapper" ]
30+
31+
# Need to use sudo, because sys.path is weird in the ci otherwise
32+
sudo input-remapper-control --command hello 2>&1 | grep 'Daemon answered with "hello"'
33+
34+
generic:
35+
runs-on: ubuntu-latest
36+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
37+
steps:
38+
- uses: actions/checkout@v3
39+
- name: Generic installation
40+
run: |
41+
sudo scripts/ci-install-deps.sh
42+
43+
# Check if the generic installation method works too. Also, using `--root /`
44+
# should not break the system somehow
45+
sudo python3 -m install --root /
46+
47+
sudo systemctl daemon-reload
48+
sudo systemctl restart input-remapper
49+
- name: DBus Hello
50+
run: |
51+
# Make sure we aren't just importing the module from the cloned repo in the
52+
# cwd. Commands should import the installed package
53+
cd /
54+
[ ! -d "inputremapper" ]
55+
sudo input-remapper-control --command hello 2>&1 | grep 'Daemon answered with "hello"'
56+
- name: uninstall
57+
run: |
58+
cd $GITHUB_WORKSPACE
59+
60+
printf y | sudo python3 -m install.uninstall
61+
62+
if pip show input-remapper; then
63+
echo "Expected input-remapper package to be uninstalled"
64+
exit 1
65+
fi
66+
67+
if [ -f /usr/share/dbus-1/system.d/inputremapper.Control.conf ]; then
68+
echo "Expected input-remappers files to be removed"
69+
exit 1
70+
fi
71+
72+
if pgrep -f input-remapper; then
73+
echo "Expected input-remapper processes to not be running"
74+
exit 1
75+
fi
76+
77+
if systemctl list-unit-files input-remapper.service; then
78+
echo "Expected input-remapper service to be missing"
79+
exit 1
80+
fi

.github/workflows/lint.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ name: Lint
33
on: [push, pull_request]
44

55
jobs:
6-
black:
6+
lint:
77
runs-on: ubuntu-latest
88
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
9-
strategy:
10-
matrix:
11-
python-version: ["3.11"]
129
steps:
1310
- uses: actions/checkout@v3
14-
- name: Set up Python ${{ matrix.python-version }}
11+
- name: Set up Python 3.14
1512
uses: actions/setup-python@v4
1613
with:
17-
python-version: ${{ matrix.python-version }}
14+
python-version: 3.14
1815
cache: 'pip'
19-
cache-dependency-path: setup.py
16+
cache-dependency-path: pyproject.toml
2017
- name: Install dependencies
2118
run: |
2219
scripts/ci-install-deps.sh
23-
pip install black
24-
- name: Analysing the code with black --check --diff
20+
pip install black ruff
21+
- name: black --check --diff
2522
run: |
2623
black --version
2724
black --check --diff ./inputremapper ./tests
25+
- name: ruff
26+
run: |
27+
ruff --version
28+
ruff check ./inputremapper ./install

.github/workflows/reviewdog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
cache: 'pip'
23-
cache-dependency-path: setup.py
23+
cache-dependency-path: pyproject.toml
2424
- uses: reviewdog/action-setup@master
2525
with:
2626
reviewdog_version: latest
2727
- name: Install dependencies
2828
shell: bash
2929
run: |
3030
scripts/ci-install-deps.sh
31-
pip install flake8 pylint mypy black types-setuptools
31+
pip install flake8 pylint mypy black
3232
- name: Set env for PR
3333
if: github.event_name == 'pull_request'
3434
shell: bash

.github/workflows/test.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
1010
strategy:
1111
matrix:
12-
python-version: ["3.8", "3.14"] # min and max supported versions?
12+
python-version: ["3.10", "3.13"] # min and max supported versions
1313
steps:
1414
- uses: actions/checkout@v3
1515
- name: Set up Python ${{ matrix.python-version }}
@@ -18,20 +18,19 @@ jobs:
1818
python-version: ${{ matrix.python-version }}
1919
# broken "Error: Cache folder path is retrieved for pip but doesn't exist on disk: /home/runner/.cache/pip"
2020
# cache: 'pip'
21-
# cache-dependency-path: setup.py
21+
# cache-dependency-path: pyproject.toml
2222
- name: Install dependencies
2323
run: |
24-
# Install deps as root since we will run tests as root
25-
sudo scripts/ci-install-deps.sh
26-
sudo pip install .
24+
# see https://pygobject.gnome.org/getting_started.html
25+
sudo apt update
26+
sudo apt install \
27+
libgirepository-2.0-dev gcc libcairo2-dev pkg-config python3-dev \
28+
libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-4 gobject-introspection
29+
pip install -e .
2730
- name: Run tests
2831
run: |
29-
# FIXME: Had some permissions issues, currently worked around by running tests as root
30-
mkdir test_tmp
31-
export TMPDIR="$(realpath test_tmp)"
32+
# Don't run tests as root, otherwise (I think) they run on the systems python
33+
# version (3.12 currently)
34+
python3 --version
3235
33-
export DATA_DIR="/home/runner/work/input-remapper/input-remapper/data/"
34-
# try this if input-remappers data cannot be found, and set DATA_DIR to a matching directory
35-
# find / -type f -name "input-remapper.glade"
36-
37-
sudo -E python -m unittest discover tests/unit
36+
python -m unittest discover tests/unit

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
inputremapper/commit_hash.py
21
mo
32

43
*.glade~

.mypy.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
21
[mypy]
32
plugins = pydantic.mypy
4-
5-
# ignore the missing evdev stubs
6-
[mypy-evdev.*]
73
ignore_missing_imports = True

.reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
runner:
33
mypy:
44
name: mypy
5-
cmd: mypy --show-column-numbers inputremapper tests --ignore-missing-imports
5+
cmd: mypy --show-column-numbers inputremapper tests install --ignore-missing-imports
66
errorformat:
77
- "%f:%l:%c: %m"
88

DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: input-remapper
22
Version: 2.2.0
33
Architecture: all
44
Maintainer: Sezanzeb <[email protected]>
5-
Depends: build-essential, libpython3-dev, libdbus-1-dev, python3, python3-setuptools, python3-evdev, python3-dasbus, python3-gi, gettext, python3-cairo, libgtk-3-0, libgtksourceview-4-dev, python3-pydantic, python3-packaging, python3-psutil
5+
Depends: build-essential, libpython3-dev, libdbus-1-dev, python3, python3-evdev, python3-dasbus, python3-gi, gettext, python3-cairo, libgtk-3-0, libgtksourceview-4-dev, python3-pydantic, python3-packaging, python3-psutil
66
Description: A tool to change the mapping of your input device buttons
77
Replaces: python3-key-mapper, key-mapper, input-remapper-gtk, input-remapper-daemon, python3-inputremapper
88
Conflicts: python3-key-mapper, key-mapper, input-remapper-gtk, input-remapper-daemon, python3-inputremapper

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@
2727

2828
Either download an installable .deb file from the [latest release](https://github.com/sezanzeb/input-remapper/releases):
2929

30-
```bash
30+
```sh
3131
wget https://github.com/sezanzeb/input-remapper/releases/download/2.2.0/input-remapper-2.2.0.deb
3232
sudo apt install -f ./input-remapper-2.2.0.deb
3333
```
3434

3535
Or install the very latest changes via:
3636

37-
```bash
38-
sudo apt install git python3-setuptools gettext
37+
```sh
38+
sudo apt install git gettext
3939
git clone https://github.com/sezanzeb/input-remapper.git
4040
cd input-remapper
41-
./scripts/build.sh
41+
./scripts/build-deb.sh
4242
sudo apt purge input-remapper input-remapper-daemon input-remapper-gtk python3-inputremapper
4343
sudo apt install -f ./dist/input-remapper-2.2.0.deb
4444
```
4545

4646
Input Remapper is also available in the repositories of [Debian](https://tracker.debian.org/pkg/input-remapper)
4747
and [Ubuntu](https://packages.ubuntu.com/oracular/input-remapper) via
4848

49-
```bash
49+
```sh
5050
sudo apt install input-remapper
5151
```
5252

@@ -56,7 +56,7 @@ Input Remapper ≥ 2.0 requires at least Ubuntu 22.04.
5656

5757
### Fedora
5858

59-
```bash
59+
```sh
6060
sudo dnf install input-remapper
6161
sudo systemctl enable --now input-remapper
6262
```
@@ -65,7 +65,7 @@ sudo systemctl enable --now input-remapper
6565

6666
### Arch
6767

68-
```bash
68+
```sh
6969
yay -S input-remapper-git
7070
sudo systemctl enable --now input-remapper
7171
```
@@ -82,13 +82,19 @@ You can also use pip to install some of them. Python packages need to be install
8282
globally for the service to be able to import them. Don't use `--user`. Conda and such
8383
may also cause problems due to changed python paths and versions.
8484

85-
```bash
86-
sudo pip install evdev pydantic dasbus PyGObject setuptools
85+
```sh
86+
sudo pip install evdev pydantic dasbus PyGObject
8787
```
8888

89-
```bash
89+
```sh
9090
git clone https://github.com/sezanzeb/input-remapper.git
9191
cd input-remapper
92-
sudo python3 setup.py install
92+
sudo python3 -m install --root /
9393
sudo systemctl enable --now input-remapper
9494
```
95+
96+
To uninstall:
97+
98+
```sh
99+
sudo python3 -m install.uninstall
100+
```

bin/input-remapper-control

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,8 @@
2323
import os
2424
import sys
2525

26-
27-
def fix_import_path():
28-
# Installations via `sudo python3 setup.py install` install into /usr/local/lib
29-
# instead of /usr/local. sys.path is missing /usr/local/lib when udev is running
30-
# its rules.
31-
try:
32-
import inputremapper
33-
except ModuleNotFoundError:
34-
python_folder = f"python{sys.version_info.major}.{sys.version_info.minor}"
35-
usr_local_lib = f"/usr/local/lib/{python_folder}/dist-packages"
36-
if not os.path.exists(usr_local_lib):
37-
return
38-
39-
print(f'Appending "{usr_local_lib}" to sys.path')
40-
sys.path.append(usr_local_lib)
41-
42-
43-
fix_import_path()
44-
45-
4626
from inputremapper.bin.input_remapper_control import InputRemapperControlBin
4727

28+
4829
if __name__ == "__main__":
4930
InputRemapperControlBin.main(InputRemapperControlBin.parse_args())

0 commit comments

Comments
 (0)