at 23.11-beta 2.4 kB view raw
1{ stdenv 2, lib 3, buildPythonPackage 4, fetchPypi 5, pythonOlder 6, pytestCheckHook 7, aiohttp 8, aiohttp-cors 9, click 10, colorama 11, hatch-fancy-pypi-readme 12, hatch-vcs 13, hatchling 14, ipython 15, mypy-extensions 16, packaging 17, pathspec 18, parameterized 19, platformdirs 20, tokenize-rt 21, tomli 22, typed-ast 23, typing-extensions 24, uvloop 25}: 26 27buildPythonPackage rec { 28 pname = "black"; 29 version = "23.9.1"; 30 format = "pyproject"; 31 32 disabled = pythonOlder "3.8"; 33 34 src = fetchPypi { 35 inherit pname version; 36 hash = "sha256-JLaz/1xtnqCKiIj2l36uhY4fNA1yYM9W1wpJgjI2ti0="; 37 }; 38 39 nativeBuildInputs = [ 40 hatch-fancy-pypi-readme 41 hatch-vcs 42 hatchling 43 ]; 44 45 propagatedBuildInputs = [ 46 click 47 mypy-extensions 48 packaging 49 pathspec 50 platformdirs 51 ] ++ lib.optionals (pythonOlder "3.11") [ 52 tomli 53 typing-extensions 54 ]; 55 56 passthru.optional-dependencies = { 57 colorama = [ 58 colorama 59 ]; 60 d = [ 61 aiohttp 62 ]; 63 uvloop = [ 64 uvloop 65 ]; 66 jupyter = [ 67 ipython 68 tokenize-rt 69 ]; 70 }; 71 72 # Necessary for the tests to pass on Darwin with sandbox enabled. 73 # Black starts a local server and needs to bind a local address. 74 __darwinAllowLocalNetworking = true; 75 76 nativeCheckInputs = [ 77 pytestCheckHook 78 parameterized 79 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies); 80 81 preCheck = '' 82 export PATH="$PATH:$out/bin" 83 84 # The top directory /build matches black's DEFAULT_EXCLUDE regex. 85 # Make /build the project root for black tests to avoid excluding files. 86 touch ../.git 87 '' + lib.optionalString stdenv.isDarwin '' 88 # Work around https://github.com/psf/black/issues/2105 89 export TMPDIR="/tmp" 90 ''; 91 92 disabledTests = [ 93 # requires network access 94 "test_gen_check_output" 95 ] ++ lib.optionals stdenv.isDarwin [ 96 # fails on darwin 97 "test_expression_diff" 98 # Fail on Hydra, see https://github.com/NixOS/nixpkgs/pull/130785 99 "test_bpo_2142_workaround" 100 "test_skip_magic_trailing_comma" 101 ]; 102 # multiple tests exceed max open files on hydra builders 103 doCheck = !(stdenv.isLinux && stdenv.isAarch64); 104 105 meta = with lib; { 106 description = "The uncompromising Python code formatter"; 107 homepage = "https://github.com/psf/black"; 108 changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md"; 109 license = licenses.mit; 110 mainProgram = "black"; 111 maintainers = with maintainers; [ sveitser autophagy ]; 112 }; 113}