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.4.3";
21 pyproject = true;
22
23 disabled = pythonOlder "3.8";
24
25 src = fetchFromGitHub {
26 owner = "pypa";
27 repo = "pipx";
28 rev = "refs/tags/${version}";
29 hash = "sha256-NxXOeVXwBhGqi4DUABV8UV+cDER0ROBFdgiyYTzdvuo=";
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 = [ installShellFiles ];
45
46 nativeCheckInputs = [
47 pytestCheckHook
48 git
49 ];
50
51 preCheck = ''
52 export HOME=$(mktemp -d)
53 '';
54
55 pytestFlagsArray = [
56 "--ignore=tests/test_install_all_packages.py"
57 # start local pypi server and use in tests
58 "--net-pypiserver"
59 ];
60
61 disabledTests = [
62 # disable tests which are difficult to emulate due to shell manipulations
63 "path_warning"
64 "script_from_internet"
65 "ensure_null_pythonpath"
66 # disable tests, which require internet connection
67 "install"
68 "inject"
69 "ensure_null_pythonpath"
70 "missing_interpreter"
71 "cache"
72 "internet"
73 "run"
74 "runpip"
75 "upgrade"
76 "suffix"
77 "legacy_venv"
78 "determination"
79 "json"
80 "test_list_short"
81 "test_skip_maintenance"
82 ];
83
84 postInstall = ''
85 installShellCompletion --cmd pipx \
86 --bash <(${argcomplete}/bin/register-python-argcomplete pipx --shell bash) \
87 --zsh <(${argcomplete}/bin/register-python-argcomplete pipx --shell zsh) \
88 --fish <(${argcomplete}/bin/register-python-argcomplete pipx --shell fish)
89 '';
90
91 meta = with lib; {
92 description = "Install and run Python applications in isolated environments";
93 mainProgram = "pipx";
94 homepage = "https://github.com/pypa/pipx";
95 changelog = "https://github.com/pypa/pipx/blob/${version}/CHANGELOG.md";
96 license = licenses.mit;
97 maintainers = with maintainers; [ yshym ];
98 };
99}