Should we conditionally disable dependees of conditionally disabled Python packages?

If a Python package a depends on another Python package b and b declares disabled = pythonOlder "3.6";, should a declare the same restriction or would that redundant and unnecessary, when that’s the only reason (i.e., when package a could work fine on older Python versions if its dependencies would support it)?

I’m asking, because

cd ~/dev/nixos/nixpkgs/
nix-build --show-trace maintainers/scripts/build.nix \
    --argstr maintainer das-g

currently results in

error: while evaluating the attribute 'drvPath' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:163:7:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python2.7-osmpythontools-0.2.6' at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:108:5:
while evaluating the attribute 'out.outPath' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:156:13:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'python2.7-pandas-0.24.2' at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:108:5:
while evaluating the attribute 'out.outPath' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:156:13:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python2.7-moto-1.3.14' at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:108:5:
while evaluating the attribute 'out.outPath' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:156:13:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python2.7-docker-4.3.1' at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:108:5:
while evaluating the attribute 'out.outPath' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:156:13:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python2.7-paramiko-2.7.1' at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:108:5:
while evaluating 'getOutput' at /home/das-g/dev/nixos/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /home/das-g/dev/nixos/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:157:17, called from undefined position:
while evaluating 'callPackageWith' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:117:35, called from /home/das-g/dev/nixos/nixpkgs/pkgs/top-level/python-packages.nix:781:12:
while evaluating 'makeOverridable' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:67:24, called from /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /home/das-g/dev/nixos/nixpkgs/pkgs/development/python-modules/bcrypt/default.nix:1:1, called from /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:69:16:
while evaluating 'makeOverridablePythonPackage' at /home/das-g/dev/nixos/nixpkgs/pkgs/top-level/python-packages.nix:33:37, called from /home/das-g/dev/nixos/nixpkgs/pkgs/development/python-modules/bcrypt/default.nix:6:1:
while evaluating 'makeOverridable' at /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:67:24, called from /home/das-g/dev/nixos/nixpkgs/pkgs/top-level/python-packages.nix:35:12:
while evaluating anonymous function at /home/das-g/dev/nixos/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:31:1, called from /home/das-g/dev/nixos/nixpkgs/lib/customisation.nix:69:16:
bcrypt-3.2.0 not supported for interpreter python2.7

on master and on release-20.09 of nixpkgs, which could easily be avoided by a change like

diff --git a/pkgs/development/python-modules/moto/default.nix b/pkgs/development/python-modules/moto/default.nix
index 3efc09bc001..c72b6476ddc 100644
--- a/pkgs/development/python-modules/moto/default.nix
+++ b/pkgs/development/python-modules/moto/default.nix
@@ -1,4 +1,4 @@
-{ lib, buildPythonPackage, fetchPypi, isPy27, fetchpatch
+{ lib, buildPythonPackage, fetchPypi, pythonOlder, fetchpatch
 , aws-xray-sdk
 , backports_tempfile
 , boto
@@ -29,6 +29,7 @@
 buildPythonPackage rec {
   pname = "moto";
   version = "1.3.14";
+  disabled = pythonOlder "3.6";
 
   src = fetchPypi {
     inherit pname version;
@@ -70,7 +71,7 @@ buildPythonPackage rec {
     werkzeug
     xmltodict
     idna
-  ] ++ lib.optionals isPy27 [ backports_tempfile ];
+  ];
 
   checkInputs = [ boto3 freezegun nose sure parameterized ];
 
diff --git a/pkgs/development/python-modules/osmpythontools/default.nix b/pkgs/development/python-modules/osmpythontools/default.nix
index 1c80dd6fe55..649f0f103bc 100644
--- a/pkgs/development/python-modules/osmpythontools/default.nix
+++ b/pkgs/development/python-modules/osmpythontools/default.nix
@@ -1,5 +1,6 @@
 { lib
 , buildPythonPackage
+, pythonOlder
 , fetchPypi
 , beautifulsoup4
 , geojson
@@ -14,6 +15,7 @@
 buildPythonPackage rec {
   pname = "osmpythontools";
   version = "0.2.6";
+  disabled = pythonOlder "3.6";
 
   src = fetchPypi {
     pname = "OSMPythonTools";

but I could also probably just wait until


or some alternative has been merged.
1 Like

I think it’s unnecessary, and even undesirable. Someone could come up with an overlay to revert the dependency version, and then downstream package should be able to build fine.

4 Likes

Should buildPythonPackage define the following?

let dependencies = buildInputs ++ propagatedBuildInputs;
    disableable  = builtins.filter (builtins.hasAttr "disabled") dependencies;
    depdisabled  = builtins.map    (builtins.getAttr "disabled") disableable;
in disabled = builtins.any depdisabled;

This way, disabled dependencies “bubble up” to disable dependents, and overlays that make a package enabled would also automatically re-enable dependents.

@twoolie that’s already the behavior mostly, except an error is thrown on the package which causing the failure. Evaluation will recursively descend into the dependencies.

1 Like