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