1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # tests
10 pytest-cov-stub,
11 pytestCheckHook,
12 pexpect,
13}:
14
15buildPythonPackage rec {
16 pname = "readchar";
17 version = "4.2.1";
18 pyproject = true;
19
20 # Don't use wheels on PyPI
21 src = fetchFromGitHub {
22 owner = "magmax";
23 repo = "python-${pname}";
24 tag = "v${version}";
25 hash = "sha256-r+dKGv0a7AU+Ef94AGCCJLQolLqTTxaNmqRQYkxk15s=";
26 };
27
28 postPatch = ''
29 # Tags on GitHub still have a postfix (-dev0)
30 sed -i 's/\(version = "\)[^"]*\(".*\)/\1${version}\2/' pyproject.toml
31 # run Linux tests on Darwin as well
32 # see https://github.com/magmax/python-readchar/pull/99 for why this is not upstreamed
33 substituteInPlace tests/linux/conftest.py \
34 --replace 'sys.platform.startswith("linux")' 'sys.platform.startswith(("darwin", "linux"))'
35 '';
36
37 build-system = [ setuptools ];
38
39 pythonImportsCheck = [ "readchar" ];
40
41 nativeCheckInputs = [
42 pytest-cov-stub
43 pytestCheckHook
44 pexpect
45 ];
46
47 meta = with lib; {
48 description = "Python library to read characters and key strokes";
49 homepage = "https://github.com/magmax/python-readchar";
50 changelog = "https://github.com/magmax/python-readchar/releases/tag/v${version}";
51 license = licenses.mit;
52 maintainers = with maintainers; [ mmahut ];
53 };
54}