1{
2 lib,
3 argcomplete,
4 buildPythonPackage,
5 fetchFromGitHub,
6 hatchling,
7 hatch-vcs,
8 installShellFiles,
9 packaging,
10 platformdirs,
11 pytestCheckHook,
12 pythonOlder,
13 tomli,
14 userpath,
15 git,
16}:
17
18buildPythonPackage rec {
19 pname = "pipx";
20 version = "1.7.1";
21 pyproject = true;
22
23 disabled = pythonOlder "3.8";
24
25 src = fetchFromGitHub {
26 owner = "pypa";
27 repo = "pipx";
28 tag = version;
29 hash = "sha256-diHWzrSpXWbNosXKN5nj2FM09HicDhHWKxQDXc+AZ4o=";
30 };
31
32 build-system = [
33 hatchling
34 hatch-vcs
35 ];
36
37 dependencies = [
38 argcomplete
39 packaging
40 platformdirs
41 userpath
42 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ];
43
44 nativeBuildInputs = [
45 installShellFiles
46 argcomplete
47 ];
48
49 nativeCheckInputs = [
50 pytestCheckHook
51 git
52 ];
53
54 preCheck = ''
55 export HOME=$(mktemp -d)
56 '';
57
58 pytestFlagsArray = [
59 "--ignore=tests/test_install_all_packages.py"
60 # start local pypi server and use in tests
61 "--net-pypiserver"
62 ];
63
64 disabledTests = [
65 # disable tests which are difficult to emulate due to shell manipulations
66 "path_warning"
67 "script_from_internet"
68 "ensure_null_pythonpath"
69 # disable tests, which require internet connection
70 "install"
71 "inject"
72 "ensure_null_pythonpath"
73 "missing_interpreter"
74 "cache"
75 "internet"
76 "run"
77 "runpip"
78 "upgrade"
79 "suffix"
80 "legacy_venv"
81 "determination"
82 "json"
83 "test_auto_update_shared_libs"
84 "test_cli"
85 "test_cli_global"
86 "test_fetch_missing_python"
87 "test_list_does_not_trigger_maintenance"
88 "test_list_pinned_packages"
89 "test_list_short"
90 "test_list_standalone_interpreter"
91 "test_list_unused_standalone_interpreters"
92 "test_list_used_standalone_interpreters"
93 "test_pin"
94 "test_skip_maintenance"
95 "test_unpin"
96 "test_unpin_warning"
97 ];
98
99 postInstall = ''
100 installShellCompletion --cmd pipx \
101 --bash <(register-python-argcomplete pipx --shell bash) \
102 --zsh <(register-python-argcomplete pipx --shell zsh) \
103 --fish <(register-python-argcomplete pipx --shell fish)
104 '';
105
106 meta = with lib; {
107 description = "Install and run Python applications in isolated environments";
108 mainProgram = "pipx";
109 homepage = "https://github.com/pypa/pipx";
110 changelog = "https://github.com/pypa/pipx/blob/${version}/CHANGELOG.md";
111 license = licenses.mit;
112 maintainers = with maintainers; [ yshym ];
113 };
114}