2020-11-21 19:51:51 +00:00
|
|
|
{ stdenv, lib
|
2021-06-04 09:07:49 +00:00
|
|
|
, buildPythonPackage, fetchPypi, pythonOlder, setuptools-scm, pytestCheckHook
|
2020-11-21 19:51:51 +00:00
|
|
|
, aiohttp
|
|
|
|
, aiohttp-cors
|
|
|
|
, attrs
|
|
|
|
, 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
|
2020-11-21 19:51:51 +00:00
|
|
|
, regex
|
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";
|
2021-09-26 12:46:18 +00:00
|
|
|
version = "21.9b0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-09-26 12:46:18 +00:00
|
|
|
sha256 = "sha256-feTPx+trcQ3jJXEtQBJWiRAdIdJSg+7X6ZmHIs8Q65E=";
|
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
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
aiohttp
|
|
|
|
aiohttp-cors
|
|
|
|
attrs
|
|
|
|
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
|
2020-11-21 19:51:51 +00:00
|
|
|
regex
|
2021-08-05 21:33:18 +00:00
|
|
|
tomli
|
2021-06-28 23:13:55 +00:00
|
|
|
typed-ast # required for tests and python2 extra
|
|
|
|
uvloop
|
|
|
|
] ++ lib.optional (pythonOlder "3.7") dataclasses
|
|
|
|
++ lib.optional (pythonOlder "3.8") 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
|
|
|
};
|
|
|
|
}
|