summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/readchar/default.nix
blob: 1e21838fdc2dae2ef394e1b2425a97cc4bd71176 (plain)
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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # tests
  pytest-cov-stub,
  pytestCheckHook,
  pexpect,
}:

buildPythonPackage rec {
  pname = "readchar";
  version = "4.2.1";
  pyproject = true;

  # Don't use wheels on PyPI
  src = fetchFromGitHub {
    owner = "magmax";
    repo = "python-${pname}";
    tag = "v${version}";
    hash = "sha256-r+dKGv0a7AU+Ef94AGCCJLQolLqTTxaNmqRQYkxk15s=";
  };

  postPatch = ''
    # Tags on GitHub still have a postfix (-dev0)
    sed -i 's/\(version = "\)[^"]*\(".*\)/\1${version}\2/' pyproject.toml
    # run Linux tests on Darwin as well
    # see https://github.com/magmax/python-readchar/pull/99 for why this is not upstreamed
    substituteInPlace tests/linux/conftest.py \
      --replace 'sys.platform.startswith("linux")' 'sys.platform.startswith(("darwin", "linux"))'
  '';

  build-system = [ setuptools ];

  pythonImportsCheck = [ "readchar" ];

  nativeCheckInputs = [
    pytest-cov-stub
    pytestCheckHook
    pexpect
  ];

  meta = {
    description = "Python library to read characters and key strokes";
    homepage = "https://github.com/magmax/python-readchar";
    changelog = "https://github.com/magmax/python-readchar/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ mmahut ];
  };
}