1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # tests
10 pytestCheckHook,
11 pexpect,
12}:
13
14buildPythonPackage rec {
15 pname = "readchar";
16 version = "4.0.6";
17 pyproject = true;
18
19 # Don't use wheels on PyPI
20 src = fetchFromGitHub {
21 owner = "magmax";
22 repo = "python-${pname}";
23 rev = "refs/tags/v${version}";
24 hash = "sha256-XowLJ9YAHhP9nInFVYtoLEOmlWBRWQX259vwm9SVVZU=";
25 };
26
27 postPatch = ''
28 substituteInPlace setup.cfg \
29 --replace "--cov=readchar" "" \
30 --replace "attr: readchar.__version__" "${version}"
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 nativeBuildInputs = [ setuptools ];
38
39 pythonImportsCheck = [ "readchar" ];
40
41 nativeCheckInputs = [
42 pytestCheckHook
43 pexpect
44 ];
45
46 meta = with lib; {
47 homepage = "https://github.com/magmax/python-readchar";
48 description = "Python library to read characters and key strokes";
49 license = licenses.mit;
50 maintainers = [ maintainers.mmahut ];
51 };
52}