diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 099f933870cb..ecda096fd2a2 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -163,8 +163,85 @@ following are specific to `buildPythonPackage`: * `catchConflicts ? true`: If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. -* `disabled ? false`: If `true`, package is not built for the particular Python - interpreter version. +* `disabled ? false`: + If set to `true` for a particular Python interpreter version or implementation, the package is marked with `meta.problems.unsupportedPython`, and will throw an error message complaining the Python interpreter being unsupported during package instantiation. + + ```nix + { + lib, + pythonAtLeast, + buildPythonPackage, + fetchFromGitHub, + setuptools, + }: + buildPythonPackage (finalAttrs: { + pname = "coconut"; + version = "3.1.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "evhub"; + repo = "coconut"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Vd6ZY3PlbPOy63/0/0YJ1U2PpsVdctOoInyKftj//cM="; + }; + + disabled = pythonAtLeast "3.13"; + + build-system = [ + setuptools + ]; + + meta = { + homepage = "http://coconut-lang.org/"; + }; + }) + ``` + + One can also choose to mark a package with `meta.problems.unsupportedPython` providing a custom `message` and optional `urls`: + + ```nix + { + lib, + python, + pythonAtLeast, + buildPythonPackage, + fetchFromGitHub, + setuptools, + }: + buildPythonPackage (finalAttrs: { + pname = "coconut"; + version = "3.1.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "evhub"; + repo = "coconut"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Vd6ZY3PlbPOy63/0/0YJ1U2PpsVdctOoInyKftj//cM="; + }; + + build-system = [ + setuptools + ]; + + meta = { + homepage = "http://coconut-lang.org/"; + problems.unsupportedPython = lib.optionalAttrs (pythonAtLeast "3.13") { + message = lib.removePrefix (python.libPrefix + "-") finalAttrs.name + " requires Python <3.13"; + urls = [ + "https://github.com/evhub/coconut/issues/873" + ]; + }; + }; + }) + ``` + + ::: {.note} + Referencing `.disabled` or `finalAtts.disabled` for Python packages are deprecated. + Use ` ? meta.problems.unsupportedPython` instead (the same goes with `finalAttrs`). + ::: + * `dontWrapPythonPrograms ? false`: Skip wrapping of Python programs. * `permitUserSite ? false`: Skip setting the `PYTHONNOUSERSITE` environment variable in wrapped programs. diff --git a/doc/release-notes/rl-2611.section.md b/doc/release-notes/rl-2611.section.md index f0e70c04ec4f..cf0640dcb311 100644 --- a/doc/release-notes/rl-2611.section.md +++ b/doc/release-notes/rl-2611.section.md @@ -255,6 +255,12 @@ - `swiftpm` is no longer wrapped to include Git to fetch dependencies. Users with Git-based dependencies will need to add `git` to their dev shells or include it in their environment if they weren’t already. +- `buildPythonPackage` and `buildPythonApplication` now uses `meta.problems.unsupportedPython` to mark Python packages with unsupported Python interpreters. + - The `disabled` argument automatically converts to `meta.problems.unsupportedPython` with the default message. + - Overriding the `passthru.disabled` attribute no longer affects such marks. + - ` ? meta.problems.unsupportedPython` is now the canonical way to identify if the package uses an incompatible Python interpreter. + The `passthru.disabled` attribute is deprecated and will be removed in future releases. + - `vimacs` has been removed, as it has not been maintained in 10 years and was built for an old version of vim (6.0). - The deprecated `appimageTools.extractType1`, `appimageTools.extractType2`, and `appimageTools.wrapType1` aliases now emit warnings. Use `appimageTools.extract` and `appimageTools.wrapType2` instead. diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index eee99a70d25c..9eb202996e14 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -418,12 +418,14 @@ lib.extendMkDerivation { passthru = { inherit - disabled pyproject build-system dependencies optional-dependencies ; + + disabled = finalAttrs ? meta.problems.unsupportedPython; + updateScript = nix-update-script { }; # __stdenvPythonCompat[Pos] attributes are here for overrideStdenvCompat in `python-packages-base.nix` to work. # They are internal and subject to changes. @@ -439,7 +441,22 @@ lib.extendMkDerivation { platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; } - // meta; + // meta + // { + problems = + let + disabled' = meta ? problems.unsupportedPython || disabled; + in + meta.problems or { } + // { + ${if disabled' then "unsupportedPython" else null} = meta.problems.unsupportedPython or { } // { + kind = "broken"; + message = + meta.problems.unsupportedPython.message + or "${removePrefix namePrefix finalAttrs.name} not supported for interpreter ${python.executable}"; + }; + }; + }; } // optionalAttrs (attrs ? checkPhase) { # If given use the specified checkPhase, otherwise use the setup hook. @@ -475,20 +492,5 @@ lib.extendMkDerivation { # This derivation transformation function must be independent to `attrs` # for fixed-point arguments support in the future. - transformDrv = - let - # Workaround to make the `lib.extendDerivation`-based disabled functionality - # respect `.overrideAttrs` - # It doesn't cover `..overrideAttrs`. - disablePythonPackage = - drv: - extendDerivation ( - drv.disabled - -> throw "${removePrefix namePrefix drv.name} not supported for interpreter ${python.executable}" - ) { } drv - // { - overrideAttrs = fdrv: disablePythonPackage (drv.overrideAttrs fdrv); - }; - in - drv: disablePythonPackage (toPythonModule drv); + transformDrv = toPythonModule; }