nixpkgs/pkgs/development/python-modules/black/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, buildPythonPackage
, fetchPypi
, pythonOlder
, setuptools-scm
, pytestCheckHook
2020-08-27 12:40:10 +02:00
, aiohttp
, aiohttp-cors
, click
, colorama
2020-08-27 12:40:10 +02:00
, mypy-extensions
, pathspec
, parameterized
2021-09-05 17:42:51 +02:00
, platformdirs
2021-07-25 22:21:48 +02:00
, tomli
2020-08-27 12:40:10 +02:00
, typed-ast
, typing-extensions
, uvloop
}:
buildPythonPackage rec {
pname = "black";
2022-06-28 17:47:31 +02:00
version = "22.6.0";
disabled = pythonOlder "3.6";
src = fetchPypi {
inherit pname version;
2022-06-28 17:47:31 +02:00
hash = "sha256-bG054ortN5rsQNocZUNMd9deZbtZoeHCg95UX7Tnxsk=";
};
nativeBuildInputs = [ setuptools-scm ];
2018-07-23 17:45:58 +02:00
# Necessary for the tests to pass on Darwin with sandbox enabled.
# Black starts a local server and needs to bind a local address.
__darwinAllowLocalNetworking = true;
checkInputs = [ pytestCheckHook parameterized ];
2020-08-27 12:40:10 +02:00
preCheck = ''
export PATH="$PATH:$out/bin"
# The top directory /build matches black's DEFAULT_EXCLUDE regex.
# Make /build the project root for black tests to avoid excluding files.
touch ../.git
'' + lib.optionalString stdenv.isDarwin ''
# Work around https://github.com/psf/black/issues/2105
export TMPDIR="/tmp"
2018-07-23 17:45:58 +02:00
'';
2020-08-27 12:40:10 +02:00
disabledTests = [
# requires network access
"test_gen_check_output"
] ++ lib.optionals stdenv.isDarwin [
# fails on darwin
"test_expression_diff"
# Fail on Hydra, see https://github.com/NixOS/nixpkgs/pull/130785
"test_bpo_2142_workaround"
"test_skip_magic_trailing_comma"
2020-08-27 12:40:10 +02:00
];
# multiple tests exceed max open files on hydra builders
doCheck = !(stdenv.isLinux && stdenv.isAarch64);
2020-08-27 12:40:10 +02:00
propagatedBuildInputs = [
aiohttp
aiohttp-cors
click
colorama
2020-08-27 12:40:10 +02:00
mypy-extensions
pathspec
2021-09-05 17:42:51 +02:00
platformdirs
2021-07-25 22:21:48 +02:00
tomli
uvloop
] ++ lib.optional (pythonOlder "3.8") typed-ast
++ lib.optional (pythonOlder "3.10") typing-extensions;
2020-08-27 12:40:10 +02:00
meta = with lib; {
description = "The uncompromising Python code formatter";
homepage = "https://github.com/psf/black";
changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md";
license = licenses.mit;
2021-10-25 12:39:19 +02:00
maintainers = with maintainers; [ sveitser autophagy ];
};
}