1{
2 lib,
3 stdenv,
4 attrs,
5 buildPythonPackage,
6 colorama,
7 fetchPypi,
8 glibcLocales,
9 gnureadline,
10 importlib-metadata,
11 pyperclip,
12 pytest-cov-stub,
13 pytest-mock,
14 pytestCheckHook,
15 pythonOlder,
16 setuptools-scm,
17 typing-extensions,
18 wcwidth,
19}:
20
21buildPythonPackage rec {
22 pname = "cmd2";
23 version = "2.5.11";
24 pyproject = true;
25
26 disabled = pythonOlder "3.6";
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-MKDThQIfvkpBFmcoReVpW75W62gvkJYGZ3Y5T5VKdCk=";
31 };
32
33 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
34 # Fake the impure dependencies pbpaste and pbcopy
35 mkdir bin
36 echo '#!${stdenv.shell}' > bin/pbpaste
37 echo '#!${stdenv.shell}' > bin/pbcopy
38 chmod +x bin/{pbcopy,pbpaste}
39 export PATH=$(realpath bin):$PATH
40 '';
41
42 build-system = [ setuptools-scm ];
43
44 dependencies = [
45 attrs
46 colorama
47 pyperclip
48 wcwidth
49 ] ++ lib.optional stdenv.hostPlatform.isDarwin gnureadline;
50
51 doCheck = !stdenv.hostPlatform.isDarwin;
52
53 nativeCheckInputs = [
54 glibcLocales
55 pytestCheckHook
56 pytest-cov-stub
57 pytest-mock
58 ];
59
60 disabledTests = [
61 # Don't require vim for tests, it causes lots of rebuilds
62 "test_find_editor_not_specified"
63 "test_transcript"
64 ];
65
66 pythonImportsCheck = [ "cmd2" ];
67
68 meta = with lib; {
69 description = "Enhancements for standard library's cmd module";
70 homepage = "https://github.com/python-cmd2/cmd2";
71 changelog = "https://github.com/python-cmd2/cmd2/releases/tag/${version}";
72 license = with licenses; [ mit ];
73 maintainers = with maintainers; [ teto ];
74 };
75}