Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
175 lines (161 loc) · 6.75 KB
/
Copy pathpyproject.toml
File metadata and controls
175 lines (161 loc) · 6.75 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
[build-system]
requires = ["setuptools>=77"]
build-backend = "setuptools.build_meta"
[project]
name = "python-libei"
version = "0.8.2"
description = "Inject, receive and capture input on Wayland from Python: ctypes bindings for libei, libeis and liboeffis, plus the RemoteDesktop and InputCapture portals"
readme = "README.md"
license = "MIT"
requires-python = ">=3.10"
authors = [{name = "Dennis K. Paulsen"}]
keywords = [
"wayland",
"libei",
"libeis",
"liboeffis",
"input",
"input-emulation",
"emulated-input",
"input-capture",
"eis",
"portal",
"xdg-desktop-portal",
"remote-desktop",
"automation",
"gui-testing",
"accessibility",
"ctypes",
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: POSIX :: BSD :: FreeBSD",
"Operating System :: POSIX :: Linux",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Desktop Environment",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
"Typing :: Typed",
]
# Zero hard dependencies: the native libraries (libei/libeis/liboeffis) are
# loaded lazily via ctypes at first use, not at import time, so this package
# never fails to import just because a caller hasn't installed them. See
# src/libei/_capi/loader.py.
dependencies = []
[project.optional-dependencies]
# libei.portal negotiates the RemoteDesktop portal directly over D-Bus, which
# needs PyGObject for Gio/GLib. The native GObject-introspection libraries
# still have to come from the distro -- PyPI's PyGObject wheel only supplies
# the Python side. Not needed for libei.ei/libei.eis/libei.oeffis.
portal = ["PyGObject>=3.42"]
dev = ["pytest>=7", "ruff>=0.6", "mypy>=1.11"]
[project.urls]
homepage = "https://github.com/ctrondlp/python-libei"
repository = "https://github.com/ctrondlp/python-libei"
issues = "https://github.com/ctrondlp/python-libei/issues"
documentation = "https://github.com/ctrondlp/python-libei/tree/main/docs"
pyguitest = "https://github.com/ctrondlp/pyguitest"
changelog = "https://github.com/ctrondlp/python-libei/blob/main/CHANGELOG.md"
[tool.setuptools.packages.find]
where = ["src"]
# PEP 561: ship the marker so type checkers use our annotations.
[tool.setuptools.package-data]
libei = ["py.typed"]
[tool.pytest.ini_options]
testpaths = ["tests"]
# The suite imports `libei` from the checkout rather than requiring an
# install, so `scripts/pre-commit-test.sh` runs on an interpreter with only
# the dev tools in it -- which is what that script's own header asks for, and
# what pyguitest and pyguitest-recorder already do. CI installs the package,
# so the installed path is still covered there. Without this, conftest's
# `from libei import ei` fails at collection and the whole check reports an
# ImportError instead of running anything.
pythonpath = ["src"]
markers = [
"integration: requires the real libei/libeis/liboeffis shared libraries to be installed",
]
[tool.ruff]
line-length = 88
target-version = "py310"
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"I", # isort
"D", # pydocstyle
"B", # bugbear
"UP", # pyupgrade
"C4", # comprehensions
"SIM", # simplification
"RET", # return consistency
"ARG", # unused arguments
"C901", # cyclomatic complexity
]
ignore = [
"D203", # incompatible with D211; keep no blank line before class docstring
"D213", # incompatible with D212; keep the summary on the first line
"D401", # properties read better as noun phrases than imperatives
"D105", # __enter__/__exit__ and friends document themselves
]
[tool.ruff.lint.mccabe]
# pyguitest's ceiling; python-libei's own worst case (InputCaptureSession.
# negotiate(), forking on portal version) sits at 14, just under it. A
# ceiling on what gets added, not a claim everything else is close to it.
max-complexity = 15
[tool.ruff.lint.pydocstyle]
convention = "pep257"
[tool.ruff.lint.per-file-ignores]
# Tests use fakes with deliberately unused arguments and multi-with blocks
# that read better nested; matching pyguitest's/pyguitest-recorder's own
# per-file-ignores for the same reasons.
"tests/*" = [
"ARG001", "ARG002", "ARG003", "ARG005", # fakes accept arguments they ignore
"SIM117", # nested with-blocks read better in tests
"D100", "D101", "D102", "D103", "D104", "D107",
]
[tool.mypy]
python_version = "3.10"
mypy_path = "src"
files = ["src", "tests"]
strict = true
# ctypes function objects are typed Callable[..., Any] -- there's no way to
# give LazyLibrary.function() a properly parameterized return type without a
# TypeVar per bound function, which the runtime signature can't provide.
# Every property in ei.py/eis.py/oeffis.py re-types a raw C call's result,
# so this fires everywhere in the wrapper layer for no actionable reason.
warn_return_any = false
# mypy defaults this to true and imports sqlite3 unconditionally to honor
# it -- a crash, not a fallback, on a Python built without it. Confirmed on
# FreeBSD 15 (GhostBSD's python3.11 port has no _sqlite3), which is the
# only place this has come up, but the flag is harmless anywhere the
# module is present: the cache just becomes one file per module instead of
# one sqlite db.
sqlite_cache = false
# Without this, results depend on the OS mypy happens to run on: it
# defaults to `sys.platform` of the invoking interpreter, and typeshed
# gates os.memfd_create to sys.platform == "linux" even though FreeBSD has
# implemented the syscall for years -- confirmed working at runtime on
# FreeBSD 15 (hasattr(os, "memfd_create") is True, round-trips real data),
# so the three call sites in tests/test_ei_objects.py,
# tests/test_eis_objects.py and tests/test_integration_extras.py are
# correct and this was a typeshed staleness false-positive, not a bug.
# Pinning to "linux" makes CI and every contributor's machine check the
# same thing regardless of what they develop on.
platform = "linux"
# PyGObject is an optional extra (see [project.optional-dependencies].portal),
# so `gi` may or may not be importable where mypy runs. Without this, the two
# error codes differ by environment -- import-untyped when PyGObject is
# installed, import-not-found when it isn't -- and an inline ignore pinned to
# either one fails in the other. libei.portal already treats gi as Any.
[[tool.mypy.overrides]]
module = ["gi.*"]
ignore_missing_imports = true