2020-08-27 11:40:10 +01:00
|
|
|
{ stdenv, lib
|
2021-06-03 11:09:11 +01:00
|
|
|
, buildPythonPackage, fetchPypi, pythonOlder, setuptools-scm, pytestCheckHook
|
2020-08-27 11:40:10 +01:00
|
|
|
, aiohttp
|
|
|
|
, aiohttp-cors
|
|
|
|
, appdirs
|
|
|
|
, attrs
|
|
|
|
, click
|
2021-06-13 19:13:11 +01:00
|
|
|
, colorama
|
2020-12-11 02:20:58 +00:00
|
|
|
, dataclasses
|
2020-08-27 11:40:10 +01:00
|
|
|
, mypy-extensions
|
|
|
|
, pathspec
|
2021-04-26 02:21:40 +01:00
|
|
|
, parameterized
|
2020-08-27 11:40:10 +01:00
|
|
|
, regex
|
2021-07-25 21:21:48 +01:00
|
|
|
, tomli
|
2020-08-27 11:40:10 +01:00
|
|
|
, typed-ast
|
2021-06-13 19:13:11 +01:00
|
|
|
, typing-extensions
|
|
|
|
, uvloop
|
|
|
|
}:
|
|
|
|
|
2018-04-05 08:11:53 +01:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "black";
|
2021-07-25 21:21:48 +01:00
|
|
|
version = "21.7b0";
|
2018-04-05 08:11:53 +01:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-07-25 21:21:48 +01:00
|
|
|
sha256 = "06d27adq6v6p8wspi0wwqz2pnq34p5jhnqvijbin54yyj5j3qdy8";
|
2018-04-05 08:11:53 +01:00
|
|
|
};
|
|
|
|
|
2021-06-03 11:09:11 +01:00
|
|
|
nativeBuildInputs = [ setuptools-scm ];
|
2018-07-23 16:45:58 +01:00
|
|
|
|
2019-06-24 15:13:43 +01: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-13 19:13:11 +01:00
|
|
|
checkInputs = [ pytestCheckHook parameterized ];
|
2020-08-27 11:40:10 +01:00
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
export PATH="$PATH:$out/bin"
|
2021-04-26 02:21:40 +01: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-13 19:13:11 +01:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Work around https://github.com/psf/black/issues/2105
|
|
|
|
export TMPDIR="/tmp"
|
2018-07-23 16:45:58 +01:00
|
|
|
'';
|
|
|
|
|
2020-08-27 11:40:10 +01:00
|
|
|
disabledTests = [
|
|
|
|
# requires network access
|
|
|
|
"test_gen_check_output"
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# fails on darwin
|
|
|
|
"test_expression_diff"
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
aiohttp
|
|
|
|
aiohttp-cors
|
|
|
|
appdirs
|
|
|
|
attrs
|
|
|
|
click
|
2021-06-13 19:13:11 +01:00
|
|
|
colorama
|
2020-08-27 11:40:10 +01:00
|
|
|
mypy-extensions
|
|
|
|
pathspec
|
|
|
|
regex
|
2021-07-25 21:21:48 +01:00
|
|
|
tomli
|
2021-06-13 19:13:11 +01:00
|
|
|
typed-ast # required for tests and python2 extra
|
|
|
|
uvloop
|
|
|
|
] ++ lib.optional (pythonOlder "3.7") dataclasses
|
|
|
|
++ lib.optional (pythonOlder "3.8") typing-extensions;
|
2018-04-05 08:11:53 +01:00
|
|
|
|
2020-08-27 11:40:10 +01:00
|
|
|
meta = with lib; {
|
2018-04-05 08:11:53 +01:00
|
|
|
description = "The uncompromising Python code formatter";
|
2021-06-13 19:13:11 +01:00
|
|
|
homepage = "https://github.com/psf/black";
|
|
|
|
changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md";
|
|
|
|
license = licenses.mit;
|
2018-04-05 08:11:53 +01:00
|
|
|
maintainers = with maintainers; [ sveitser ];
|
|
|
|
};
|
|
|
|
}
|