2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchPypi,
|
|
|
|
pythonOlder,
|
|
|
|
pytestCheckHook,
|
|
|
|
aiohttp,
|
|
|
|
click,
|
|
|
|
colorama,
|
|
|
|
hatch-fancy-pypi-readme,
|
|
|
|
hatch-vcs,
|
|
|
|
hatchling,
|
|
|
|
ipython,
|
|
|
|
mypy-extensions,
|
|
|
|
packaging,
|
|
|
|
pathspec,
|
|
|
|
parameterized,
|
|
|
|
platformdirs,
|
|
|
|
tokenize-rt,
|
|
|
|
tomli,
|
|
|
|
typing-extensions,
|
|
|
|
uvloop,
|
2021-06-28 23:13:55 +00:00
|
|
|
}:
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "black";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "24.4.2";
|
2022-10-30 15:09:59 +00:00
|
|
|
format = "pyproject";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
disabled = pythonOlder "3.8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-yHK1MFfwAAhdpmoZxV1o9vjdysJkI5KtOjVYeEBvvU0=";
|
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
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs =
|
|
|
|
[
|
|
|
|
click
|
|
|
|
mypy-extensions
|
|
|
|
packaging
|
|
|
|
pathspec
|
|
|
|
platformdirs
|
|
|
|
]
|
|
|
|
++ lib.optionals (pythonOlder "3.11") [
|
|
|
|
tomli
|
|
|
|
typing-extensions
|
|
|
|
];
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2024-10-04 16:56:33 +00:00
|
|
|
optional-dependencies = {
|
2024-06-05 15:53:02 +00:00
|
|
|
colorama = [ colorama ];
|
|
|
|
d = [ aiohttp ];
|
|
|
|
uvloop = [ uvloop ];
|
2023-03-15 16:39:30 +00:00
|
|
|
jupyter = [
|
|
|
|
ipython
|
|
|
|
tokenize-rt
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
parameterized
|
2024-10-04 16:56:33 +00:00
|
|
|
] ++ lib.flatten (lib.attrValues optional-dependencies);
|
2020-11-21 19:51:51 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
pytestFlagsArray = [
|
2024-06-05 15:53:02 +00:00
|
|
|
"-W"
|
|
|
|
"ignore::DeprecationWarning"
|
2024-02-29 20:09:43 +00:00
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
preCheck =
|
|
|
|
''
|
|
|
|
export PATH="$PATH:$out/bin"
|
2021-06-01 10:57:12 +00:00
|
|
|
|
2024-06-05 15:53:02 +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
|
|
|
|
''
|
2024-09-26 11:04:55 +00:00
|
|
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2024-06-05 15:53:02 +00:00
|
|
|
# Work around https://github.com/psf/black/issues/2105
|
|
|
|
export TMPDIR="/tmp"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# requires network access
|
|
|
|
"test_gen_check_output"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-06-05 15:53:02 +00:00
|
|
|
# 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"
|
|
|
|
];
|
2022-06-16 17:23:12 +00:00
|
|
|
# multiple tests exceed max open files on hydra builders
|
2024-09-26 11:04:55 +00:00
|
|
|
doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
|
2020-11-21 19:51:51 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "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;
|
2023-08-10 07:59:29 +00:00
|
|
|
mainProgram = "black";
|
2024-06-05 15:53:02 +00:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
sveitser
|
|
|
|
autophagy
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|