1{
2 lib,
3 stdenv,
4 build,
5 buildPythonPackage,
6 fetchFromGitHub,
7 flit-core,
8 filelock,
9 packaging,
10 pyproject-hooks,
11 pytest-mock,
12 pytest-rerunfailures,
13 pytest-xdist,
14 pytestCheckHook,
15 pythonOlder,
16 setuptools,
17 tomli,
18 wheel,
19}:
20
21buildPythonPackage rec {
22 pname = "build";
23 version = "1.2.1";
24 format = "pyproject";
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchFromGitHub {
29 owner = "pypa";
30 repo = "build";
31 rev = "refs/tags/${version}";
32 hash = "sha256-G0g+1v19sQMUuQlZKGELZOwwX07i7TIdEdaYzr8bKtI=";
33 };
34
35 postPatch = ''
36 # not strictly required, causes circular dependency cycle
37 sed -i '/importlib-metadata >= 4.6/d' pyproject.toml
38 '';
39
40 nativeBuildInputs = [ flit-core ];
41
42 propagatedBuildInputs = [
43 packaging
44 pyproject-hooks
45 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ];
46
47 # We need to disable tests because this package is part of the bootstrap chain
48 # and its test dependencies cannot be built yet when this is being built.
49 doCheck = false;
50
51 passthru.tests = {
52 pytest = buildPythonPackage {
53 pname = "${pname}-pytest";
54 inherit src version;
55 format = "other";
56
57 dontBuild = true;
58 dontInstall = true;
59
60 nativeCheckInputs = [
61 build
62 filelock
63 pytest-mock
64 pytest-rerunfailures
65 pytest-xdist
66 pytestCheckHook
67 setuptools
68 wheel
69 ];
70
71 pytestFlagsArray = [
72 "-W"
73 "ignore::DeprecationWarning"
74 ];
75
76 __darwinAllowLocalNetworking = true;
77
78 disabledTests =
79 [
80 # Tests often fail with StopIteration
81 "test_isolat"
82 "test_default_pip_is_never_too_old"
83 "test_build"
84 "test_with_get_requires"
85 "test_init"
86 "test_output"
87 "test_wheel_metadata"
88 ]
89 ++ lib.optionals stdenv.isDarwin [
90 # Expects Apple's Python and its quirks
91 "test_can_get_venv_paths_with_conflicting_default_scheme"
92 ];
93 };
94 };
95
96 pythonImportsCheck = [ "build" ];
97
98 meta = with lib; {
99 mainProgram = "pyproject-build";
100 description = "Simple, correct PEP517 package builder";
101 longDescription = ''
102 build will invoke the PEP 517 hooks to build a distribution package. It
103 is a simple build tool and does not perform any dependency management.
104 '';
105 homepage = "https://github.com/pypa/build";
106 changelog = "https://github.com/pypa/build/blob/${version}/CHANGELOG.rst";
107 license = licenses.mit;
108 maintainers = teams.python.members ++ [ maintainers.fab ];
109 };
110}