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