2022-03-30 09:31:56 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, pythonOlder
|
|
|
|
, pytestCheckHook
|
2020-11-21 19:51:51 +00:00
|
|
|
, aiohttp
|
|
|
|
, aiohttp-cors
|
|
|
|
, click
|
2021-06-28 23:13:55 +00:00
|
|
|
, colorama
|
2022-10-30 15:09:59 +00:00
|
|
|
, hatch-fancy-pypi-readme
|
|
|
|
, hatch-vcs
|
|
|
|
, hatchling
|
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-12-17 10:02:37 +00:00
|
|
|
version = "22.12.0";
|
2022-10-30 15:09:59 +00:00
|
|
|
format = "pyproject";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-12-17 10:02:37 +00:00
|
|
|
hash = "sha256-IpNR5aGMow9Ee/ck0Af4kPl+E68HC7atTApEHNdZai8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
hatch-fancy-pypi-readme
|
|
|
|
hatch-vcs
|
|
|
|
hatchling
|
|
|
|
];
|
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;
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
checkInputs = [ pytestCheckHook parameterized aiohttp ];
|
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 = [
|
|
|
|
click
|
|
|
|
mypy-extensions
|
|
|
|
pathspec
|
2021-09-18 10:52:07 +00:00
|
|
|
platformdirs
|
2021-08-05 21:33:18 +00:00
|
|
|
tomli
|
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
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
passthru.optional-dependencies = {
|
|
|
|
d = [ aiohttp aiohttp-cors ];
|
|
|
|
colorama = [ colorama ];
|
|
|
|
uvloop = [ uvloop ];
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|