-
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathsetup.py
More file actions
147 lines (126 loc) · 4.38 KB
/
setup.py
File metadata and controls
147 lines (126 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import codecs
from os import getenv, path
from pathlib import Path
from re import M, search
from subprocess import run
from setuptools import setup
from setuptools.command.install import install
class CouldNotFindExpectedInstallDirectory(Exception):
def __str__(self):
return (
"Could not find expected install directory. This is required to"
" setup the hintsd service. Set the 'HINTS_EXPECTED_BIN_DIR'"
" environment variable with the location hints will be installed"
" in. For example:"
" 'export HINTS_EXPECTED_BIN_DIR=\"$HOME/.local/bin\"'."
" Then attemp to re-install."
)
with open("README.md", "r") as fh:
long_description = fh.read()
here = path.abspath(path.dirname(__file__))
def read(*parts):
with codecs.open(path.join(here, *parts), "r") as fp:
return fp.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def get_bin_dir(self):
bin_dir = ""
try:
pipx_bin_dir_cmd = run(
["uv", "tool", "dir", "--bin"],
check=True,
capture_output=True,
)
bin_dir = pipx_bin_dir_cmd.stdout.decode("utf-8").strip()
except: # pylint: disable=bare-except
bin_dir = getenv("HINTS_EXPECTED_BIN_DIR", "")
if not bin_dir:
raise CouldNotFindExpectedInstallDirectory()
return bin_dir
def install_hintsd_service(self):
"""Install hintsd service for the current user."""
bin_dir = self.get_bin_dir()
if bin_dir:
user_service_directory = Path(path.expanduser("~")) / ".config/systemd/user"
user_service_directory.mkdir(parents=True, exist_ok=True)
with open(
user_service_directory / "hintsd.service",
mode="w+",
encoding="utf-8",
) as service_file:
service_file.write(
"[Unit]\n"
"Description=Hints daemon\n"
"StartLimitIntervalSec=0\n"
"[Service]\n"
"Type=simple\n"
f"ExecStart={bin_dir}/hintsd\n"
"Restart=always\n"
"RestartSec=1s\n"
"[Install]\n"
"WantedBy=default.target\n"
)
def run(self):
install.run(self)
self.install_hintsd_service()
dynamic_version = find_version("hints", "__init__.py")
s = setup(
name="hints",
version=dynamic_version,
author="Alfredo Sequeida",
description="Hints lets you navigate GUI applications in Linux without your"
' mouse by displaying "hints" you can type on your keyboard to interact'
" with GUI elements.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/AlfredoSequeida/hints",
download_url="https://github.com/AlfredoSequeida/hints/archive/"
+ dynamic_version
+ ".tar.gz",
keywords=[
"vim",
"vimium",
"hints",
"mouseless",
"keyboard",
"keyboard navigation",
"linux",
"x11",
"wayland",
],
python_requires=">=3.10",
platforms=["Linux"],
classifiers=[
"Intended Audience :: End Users/Desktop",
"Topic :: Desktop Environment",
"Topic :: Desktop Environment :: Window Managers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
],
license="GPLv3",
packages=["hints", "hints.backends", "hints.huds", "hints.window_systems"],
include_package_data=True,
install_requires=[
"PyGObject==3.50.0",
"pillow",
"pyscreenshot",
"opencv-python",
"evdev",
"dbus-python",
"rich",
],
entry_points={
"console_scripts": [
"hints = hints.hints:main",
"hintsd = hints.mouse_service:main",
]
},
cmdclass={"install": PostInstallCommand},
)