1{
2 lib,
3 callPackage,
4 buildPythonPackage,
5 fetchPypi,
6 pythonOlder,
7 substituteAll,
8 hatchling,
9}:
10
11buildPythonPackage rec {
12 pname = "attrs";
13 version = "24.2.0";
14 disabled = pythonOlder "3.7";
15 format = "pyproject";
16
17 src = fetchPypi {
18 inherit pname version;
19 hash = "sha256-XPsbkUi1sIZWm67APyDXtr87ysyaQr6/h/+qyjYvY0Y=";
20 };
21
22 patches = [
23 (substituteAll {
24 # hatch-vcs and hatch-fancy-pypi-readme depend on pytest, which depends on attrs
25 src = ./remove-hatch-plugins.patch;
26 inherit version;
27 })
28 ];
29
30 nativeBuildInputs = [ hatchling ];
31
32 outputs = [
33 "out"
34 "testout"
35 ];
36
37 postInstall = ''
38 # Install tests as the tests output.
39 mkdir $testout
40 cp -R conftest.py tests $testout
41 '';
42
43 pythonImportsCheck = [ "attr" ];
44
45 # pytest depends on attrs, so we can't do this out-of-the-box.
46 # Instead, we do this as a passthru.tests test.
47 doCheck = false;
48
49 passthru.tests = {
50 pytest = callPackage ./tests.nix { };
51 };
52
53 meta = with lib; {
54 description = "Python attributes without boilerplate";
55 homepage = "https://github.com/python-attrs/attrs";
56 changelog = "https://github.com/python-attrs/attrs/releases/tag/${version}";
57 license = licenses.mit;
58 maintainers = [ ];
59 };
60}