nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 85 lines 2.0 kB view raw
1{ stdenv 2, lib 3, buildPythonPackage 4, fetchPypi 5, pythonOlder 6, setuptools-scm 7, pytestCheckHook 8, aiohttp 9, aiohttp-cors 10, click 11, colorama 12, dataclasses 13, mypy-extensions 14, pathspec 15, parameterized 16, platformdirs 17, tomli 18, typed-ast 19, typing-extensions 20, uvloop 21}: 22 23 24buildPythonPackage rec { 25 pname = "black"; 26 version = "22.3.0"; 27 28 disabled = pythonOlder "3.6"; 29 30 src = fetchPypi { 31 inherit pname version; 32 hash = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; 33 }; 34 35 nativeBuildInputs = [ setuptools-scm ]; 36 37 # Necessary for the tests to pass on Darwin with sandbox enabled. 38 # Black starts a local server and needs to bind a local address. 39 __darwinAllowLocalNetworking = true; 40 41 checkInputs = [ pytestCheckHook parameterized ]; 42 43 preCheck = '' 44 export PATH="$PATH:$out/bin" 45 46 # The top directory /build matches black's DEFAULT_EXCLUDE regex. 47 # Make /build the project root for black tests to avoid excluding files. 48 touch ../.git 49 '' + lib.optionalString stdenv.isDarwin '' 50 # Work around https://github.com/psf/black/issues/2105 51 export TMPDIR="/tmp" 52 ''; 53 54 disabledTests = [ 55 # requires network access 56 "test_gen_check_output" 57 ] ++ lib.optionals stdenv.isDarwin [ 58 # fails on darwin 59 "test_expression_diff" 60 # Fail on Hydra, see https://github.com/NixOS/nixpkgs/pull/130785 61 "test_bpo_2142_workaround" 62 "test_skip_magic_trailing_comma" 63 ]; 64 65 propagatedBuildInputs = [ 66 aiohttp 67 aiohttp-cors 68 click 69 colorama 70 mypy-extensions 71 pathspec 72 platformdirs 73 tomli 74 uvloop 75 ] ++ lib.optional (pythonOlder "3.8") typed-ast 76 ++ lib.optional (pythonOlder "3.10") typing-extensions; 77 78 meta = with lib; { 79 description = "The uncompromising Python code formatter"; 80 homepage = "https://github.com/psf/black"; 81 changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md"; 82 license = licenses.mit; 83 maintainers = with maintainers; [ sveitser autophagy ]; 84 }; 85}