nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 137 lines 3.3 kB view raw
1{ 2 stdenv, 3 lib, 4 buildPythonPackage, 5 fetchPypi, 6 fetchpatch, 7 pythonOlder, 8 pytestCheckHook, 9 aiohttp, 10 click, 11 colorama, 12 hatch-fancy-pypi-readme, 13 hatch-vcs, 14 hatchling, 15 ipython, 16 mypy-extensions, 17 packaging, 18 pathspec, 19 parameterized, 20 platformdirs, 21 tokenize-rt, 22 tomli, 23 typing-extensions, 24 uvloop, 25}: 26 27buildPythonPackage rec { 28 pname = "black"; 29 version = "25.1.0"; 30 pyproject = true; 31 32 src = fetchPypi { 33 inherit pname version; 34 hash = "sha256-M0ltXNEiKtczkTUrSujaFSU8Xeibk6gLPiyNmhnsJmY="; 35 }; 36 37 patches = [ 38 (fetchpatch { 39 name = "click-8.2-compat-1.patch"; 40 url = "https://github.com/psf/black/commit/14e1de805a5d66744a08742cad32d1660bf7617a.patch"; 41 hash = "sha256-fHRlMetE6+09MKkuFNQQr39nIKeNrqwQuBNqfIlP4hc="; 42 }) 43 (fetchpatch { 44 name = "click-8.2-compat-2.patch"; 45 url = "https://github.com/psf/black/commit/ed64d89faa7c738c4ba0006710f7e387174478af.patch"; 46 hash = "sha256-df/J6wiRqtnHk3mAY3ETiRR2G4hWY1rmZMfm2rjP2ZQ="; 47 }) 48 (fetchpatch { 49 name = "click-8.2-compat-3.patch"; 50 url = "https://github.com/psf/black/commit/b0f36f5b4233ef4cf613daca0adc3896d5424159.patch"; 51 hash = "sha256-SGLCxbgrWnAi79IjQOb2H8mD/JDbr2SGfnKyzQsJrOA="; 52 }) 53 ]; 54 55 nativeBuildInputs = [ 56 hatch-fancy-pypi-readme 57 hatch-vcs 58 hatchling 59 ]; 60 61 propagatedBuildInputs = [ 62 click 63 mypy-extensions 64 packaging 65 pathspec 66 platformdirs 67 ] 68 ++ lib.optionals (pythonOlder "3.11") [ 69 tomli 70 typing-extensions 71 ]; 72 73 optional-dependencies = { 74 colorama = [ colorama ]; 75 d = [ aiohttp ]; 76 uvloop = [ uvloop ]; 77 jupyter = [ 78 ipython 79 tokenize-rt 80 ]; 81 }; 82 83 # Necessary for the tests to pass on Darwin with sandbox enabled. 84 # Black starts a local server and needs to bind a local address. 85 __darwinAllowLocalNetworking = true; 86 87 nativeCheckInputs = [ 88 pytestCheckHook 89 parameterized 90 ] 91 ++ lib.concatAttrValues optional-dependencies; 92 93 pytestFlags = [ 94 "-Wignore::DeprecationWarning" 95 ]; 96 97 preCheck = '' 98 export PATH="$PATH:$out/bin" 99 100 # The top directory /build matches black's DEFAULT_EXCLUDE regex. 101 # Make /build the project root for black tests to avoid excluding files. 102 touch ../.git 103 '' 104 + lib.optionalString stdenv.hostPlatform.isDarwin '' 105 # Work around https://github.com/psf/black/issues/2105 106 export TMPDIR="/tmp" 107 ''; 108 109 disabledTests = [ 110 # requires network access 111 "test_gen_check_output" 112 # broken on Python 3.13.4 113 # FIXME: remove this when fixed upstream 114 "test_simple_format[pep_701]" 115 ] 116 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 117 # fails on darwin 118 "test_expression_diff" 119 # Fail on Hydra, see https://github.com/NixOS/nixpkgs/pull/130785 120 "test_bpo_2142_workaround" 121 "test_skip_magic_trailing_comma" 122 ]; 123 # multiple tests exceed max open files on hydra builders 124 doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64); 125 126 meta = { 127 description = "Uncompromising Python code formatter"; 128 homepage = "https://github.com/psf/black"; 129 changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md"; 130 license = lib.licenses.mit; 131 mainProgram = "black"; 132 maintainers = with lib.maintainers; [ 133 sveitser 134 autophagy 135 ]; 136 }; 137}