1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 installShellFiles,
8 wheel,
9 setuptools,
10
11 # docs
12 sphinx,
13 sphinx-issues,
14
15 # checks
16 freezegun,
17 git,
18 mock,
19 scripttest,
20 virtualenv,
21 pretend,
22 proxy-py,
23 pytestCheckHook,
24 tomli-w,
25 werkzeug,
26
27 # coupled downsteam dependencies
28 pip-tools,
29}:
30
31let
32 self = buildPythonPackage rec {
33 pname = "pip";
34 version = "25.0.1";
35 format = "pyproject";
36
37 src = fetchFromGitHub {
38 owner = "pypa";
39 repo = pname;
40 tag = version;
41 hash = "sha256-V069rAL6U5KBnSc09LRCu0M7qQCH5NbMghVttlmIoRY=";
42 };
43
44 postPatch = ''
45 # Remove vendored Windows PE binaries
46 # Note: These are unused but make the package unreproducible.
47 find -type f -name '*.exe' -delete
48 '';
49
50 nativeBuildInputs = [
51 installShellFiles
52 setuptools
53 wheel
54
55 # docs
56 sphinx
57 sphinx-issues
58 ];
59
60 outputs = [
61 "out"
62 "man"
63 ];
64
65 # pip uses a custom sphinx extension and unusual conf.py location, mimic the internal build rather than attempting
66 # to fit sphinxHook see https://github.com/pypa/pip/blob/0778c1c153da7da457b56df55fb77cbba08dfb0c/noxfile.py#L129-L148
67 postBuild = ''
68 cd docs
69
70 # remove references to sphinx extentions only required for html doc generation
71 # sphinx.ext.intersphinx requires network connection or packaged object.inv files for python and pypug
72 # sphinxcontrib.towncrier is not currently packaged
73 for ext in sphinx.ext.intersphinx sphinx_copybutton sphinx_inline_tabs sphinxcontrib.towncrier myst_parser; do
74 substituteInPlace html/conf.py --replace-fail '"'$ext'",' ""
75 done
76
77 PYTHONPATH=$src/src:$PYTHONPATH sphinx-build -v \
78 -d build/doctrees/man \
79 -c html \
80 -d build/doctrees/man \
81 -b man \
82 man \
83 build/man
84 cd ..
85 '';
86
87 doCheck = false;
88
89 nativeCheckInputs = [
90 freezegun
91 git
92 mock
93 scripttest
94 virtualenv
95 pretend
96 pytestCheckHook
97 proxy-py
98 tomli-w
99 werkzeug
100 ];
101
102 postInstall = ''
103 installManPage docs/build/man/*
104
105 installShellCompletion --cmd pip \
106 --bash <($out/bin/pip completion --bash --no-cache-dir) \
107 --fish <($out/bin/pip completion --fish --no-cache-dir) \
108 --zsh <($out/bin/pip completion --zsh --no-cache-dir)
109 '';
110
111 passthru.tests = {
112 inherit pip-tools;
113 pytest = self.overridePythonAttrs { doCheck = true; };
114 };
115
116 meta = {
117 description = "PyPA recommended tool for installing Python packages";
118 license = with lib.licenses; [ mit ];
119 homepage = "https://pip.pypa.io/";
120 changelog = "https://pip.pypa.io/en/stable/news/#v${lib.replaceStrings [ "." ] [ "-" ] version}";
121 };
122 };
123in
124self