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