From d2e9be2b076699b1a8e8d6b6f9ea4bebbd6956f9 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 2 Jul 2025 04:19:06 +0200 Subject: [PATCH] buildPython*: throw on empty format This is the ratchet that disallows introducing new python packages that do not define a package format. --- doc/release-notes/rl-2511.section.md | 4 ++++ .../interpreters/python/mk-python-derivation.nix | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 2a90ec5891e5..2c5eb1492217 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -61,6 +61,10 @@ - `reaction` has been updated to version 2, which includes some breaking changes. For more information, [check the release article](https://blog.ppom.me/en-reaction-v2). +- The `buildPythonPackage` and `buildPythonApplication` functions now require + an explicit `format` attribute. Previously the default format used setuptools + and called `setup.py` from the source tree, which is deprecated. + The modern alternative is to configure `pyproject = true` with `build-system = [ setuptools ]`. ### Deprecations {#sec-nixpkgs-release-25.11-lib-deprecations} diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index f4c86aa91112..4c1ac3664af4 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -211,7 +211,7 @@ let else if format != null then format else - "setuptools"; + throw "${name} does not configure a `format`. To build with setuptools as before, set `pyproject = true` and `build-system = [ setuptools ]`.`"; withDistOutput = withDistOutput' format'; @@ -268,11 +268,12 @@ let isSetuptoolsDependency = isSetuptoolsDependency' (attrs.pname or null); + name = namePrefix + attrs.name or "${finalAttrs.pname}-${finalAttrs.version}"; + in (cleanAttrs attrs) // { - - name = namePrefix + attrs.name or "${finalAttrs.pname}-${finalAttrs.version}"; + inherit name; inherit catchConflicts;