diff --git a/pkgs/development/python-modules/netaddr/default.nix b/pkgs/development/python-modules/netaddr/default.nix index 0a9c8457e96d..f2f244118236 100644 --- a/pkgs/development/python-modules/netaddr/default.nix +++ b/pkgs/development/python-modules/netaddr/default.nix @@ -1,8 +1,8 @@ { lib, + stdenv, buildPythonPackage, fetchPypi, - pythonOlder, setuptools, pytestCheckHook, }: @@ -12,14 +12,24 @@ buildPythonPackage rec { version = "1.3.0"; pyproject = true; - disabled = pythonOlder "3.7"; - src = fetchPypi { inherit pname version; hash = "sha256-XDw9mJW1Ubdjd5un23oDSH3B+OOzha+BmvNBrp725Io="; }; - nativeBuildInputs = [ setuptools ]; + # Test suite uses internal packaging._musllinux module to detect libc flavor. The module assumes + # the python executable is dynamically linked - it then attempts to parse linked library name to + # detect musl. It won't work on a static build. + postPatch = + if (stdenv.targetPlatform.isMusl && stdenv.targetPlatform.isStatic) then + '' + substituteInPlace netaddr/tests/__init__.py \ + --replace-fail "IS_MUSL = _get_musl_version(sys.executable) is not None" "IS_MUSL = True" + '' + else + null; + + build-system = [ setuptools ]; nativeCheckInputs = [ pytestCheckHook ];