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 ]
47 ++ lib.optionals (pythonOlder "3.11") [ tomli ];
48
49 # We need to disable tests because this package is part of the bootstrap chain
50 # and its test dependencies cannot be built yet when this is being built.
51 doCheck = false;
52
53 passthru.tests = {
54 pytest = buildPythonPackage {
55 pname = "${pname}-pytest";
56 inherit src version;
57 format = "other";
58
59 dontBuild = true;
60 dontInstall = true;
61
62 nativeCheckInputs = [
63 build
64 filelock
65 pytest-mock
66 pytest-rerunfailures
67 pytest-xdist
68 pytestCheckHook
69 setuptools
70 virtualenv
71 wheel
72 ];
73
74 pytestFlags = [
75 "-Wignore::DeprecationWarning"
76 ];
77
78 __darwinAllowLocalNetworking = true;
79
80 disabledTests = [
81 # Tests often fail with StopIteration
82 "test_isolat"
83 "test_default_pip_is_never_too_old"
84 "test_build"
85 "test_with_get_requires"
86 "test_init"
87 "test_output"
88 "test_wheel_metadata"
89 # Tests require network access to run pip install
90 "test_verbose_output"
91 "test_requirement_installation"
92 ]
93 ++ lib.optionals stdenv.hostPlatform.isDarwin [
94 # Expects Apple's Python and its quirks
95 "test_can_get_venv_paths_with_conflicting_default_scheme"
96 ];
97 };
98 };
99
100 pythonImportsCheck = [ "build" ];
101
102 meta = with lib; {
103 mainProgram = "pyproject-build";
104 description = "Simple, correct PEP517 package builder";
105 longDescription = ''
106 build will invoke the PEP 517 hooks to build a distribution package. It
107 is a simple build tool and does not perform any dependency management.
108 '';
109 homepage = "https://github.com/pypa/build";
110 changelog = "https://github.com/pypa/build/blob/${version}/CHANGELOG.rst";
111 license = licenses.mit;
112 maintainers = [ maintainers.fab ];
113 teams = [ teams.python ];
114 };
115}