2022-03-30 09:31:56 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, pythonOlder
|
|
|
|
, setuptools-scm
|
|
|
|
, pytestCheckHook
|
2020-11-21 19:51:51 +00:00
|
|
|
, aiohttp
|
|
|
|
, aiohttp-cors
|
|
|
|
, click
|
2021-06-28 23:13:55 +00:00
|
|
|
, colorama
|
2020-12-25 13:55:36 +00:00
|
|
|
, dataclasses
|
2020-11-21 19:51:51 +00:00
|
|
|
, mypy-extensions
|
|
|
|
, pathspec
|
2021-06-01 10:57:12 +00:00
|
|
|
, parameterized
|
2021-09-18 10:52:07 +00:00
|
|
|
, platformdirs
|
2021-08-05 21:33:18 +00:00
|
|
|
, tomli
|
2020-11-21 19:51:51 +00:00
|
|
|
, typed-ast
|
2021-06-28 23:13:55 +00:00
|
|
|
, typing-extensions
|
|
|
|
, uvloop
|
|
|
|
}:
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "black";
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "22.3.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-04-27 09:35:20 +00:00
|
|
|
hash = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-06-04 09:07:49 +00:00
|
|
|
nativeBuildInputs = [ setuptools-scm ];
|
2020-04-24 23:36:52 +00: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;
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkInputs = [ pytestCheckHook parameterized ];
|
2020-11-21 19:51:51 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
export PATH="$PATH:$out/bin"
|
2021-06-01 10:57:12 +00:00
|
|
|
|
|
|
|
# The top directory /build matches black's DEFAULT_EXCLUDE regex.
|
|
|
|
# Make /build the project root for black tests to avoid excluding files.
|
|
|
|
touch ../.git
|
2021-06-28 23:13:55 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Work around https://github.com/psf/black/issues/2105
|
|
|
|
export TMPDIR="/tmp"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-11-21 19:51:51 +00:00
|
|
|
disabledTests = [
|
|
|
|
# requires network access
|
|
|
|
"test_gen_check_output"
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# fails on darwin
|
|
|
|
"test_expression_diff"
|
2021-10-04 12:37:57 +00:00
|
|
|
# Fail on Hydra, see https://github.com/NixOS/nixpkgs/pull/130785
|
|
|
|
"test_bpo_2142_workaround"
|
|
|
|
"test_skip_magic_trailing_comma"
|
2020-11-21 19:51:51 +00:00
|
|
|
];
|
2022-06-16 17:23:12 +00:00
|
|
|
# multiple tests exceed max open files on hydra builders
|
|
|
|
doCheck = !(stdenv.isLinux && stdenv.isAarch64);
|
2020-11-21 19:51:51 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
aiohttp
|
|
|
|
aiohttp-cors
|
|
|
|
click
|
2021-06-28 23:13:55 +00:00
|
|
|
colorama
|
2020-11-21 19:51:51 +00:00
|
|
|
mypy-extensions
|
|
|
|
pathspec
|
2021-09-18 10:52:07 +00:00
|
|
|
platformdirs
|
2021-08-05 21:33:18 +00:00
|
|
|
tomli
|
2021-06-28 23:13:55 +00:00
|
|
|
uvloop
|
2022-03-30 09:31:56 +00:00
|
|
|
] ++ lib.optional (pythonOlder "3.8") typed-ast
|
|
|
|
++ lib.optional (pythonOlder "3.10") typing-extensions;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-21 19:51:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "The uncompromising Python code formatter";
|
2021-06-28 23:13:55 +00:00
|
|
|
homepage = "https://github.com/psf/black";
|
|
|
|
changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md";
|
|
|
|
license = licenses.mit;
|
2021-10-28 06:52:43 +00:00
|
|
|
maintainers = with maintainers; [ sveitser autophagy ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|