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