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