1{ stdenv, fetchPypi, buildPythonPackage, pythonOlder, isPy3k
2, pyperclip, six, pyparsing, vim, wcwidth, colorama, attrs
3, contextlib2 ? null, typing ? null, setuptools_scm
4, pytest, mock ? null, pytest-mock
5, which, glibcLocales
6}:
7buildPythonPackage rec {
8 pname = "cmd2";
9 version = "1.3.8";
10
11 src = fetchPypi {
12 inherit pname version;
13 sha256 = "b6f6254def8ba479088702f97bca1b999c12e0c38ac5d82dc50a44db93c7108c";
14 };
15
16 LC_ALL="en_US.UTF-8";
17
18 postPatch = stdenv.lib.optional stdenv.isDarwin ''
19 # Fake the impure dependencies pbpaste and pbcopy
20 mkdir bin
21 echo '#!${stdenv.shell}' > bin/pbpaste
22 echo '#!${stdenv.shell}' > bin/pbcopy
23 chmod +x bin/{pbcopy,pbpaste}
24 export PATH=$(realpath bin):$PATH
25 '';
26
27 disabled = !isPy3k;
28
29 buildInputs = [
30 setuptools_scm
31 ];
32
33 propagatedBuildInputs = [
34 colorama
35 pyperclip
36 six
37 pyparsing
38 wcwidth
39 attrs
40 ]
41 ++ stdenv.lib.optionals (pythonOlder "3.5") [contextlib2 typing]
42 ;
43
44
45 doCheck = !stdenv.isDarwin;
46 # pytest-cov
47 # argcomplete will generate errors
48 checkInputs= [ pytest mock which vim glibcLocales pytest-mock ]
49 ++ stdenv.lib.optional (pythonOlder "3.6") [ mock ];
50 checkPhase = ''
51 # test_path_completion_user_expansion might be fixed in the next release
52 py.test -k 'not test_path_completion_user_expansion'
53 '';
54
55 meta = with stdenv.lib; {
56 description = "Enhancements for standard library's cmd module";
57 homepage = "https://github.com/python-cmd2/cmd2";
58 maintainers = with maintainers; [ teto ];
59 };
60}