Unverified Commit e43f637f authored by Gergő Gutyina's avatar Gergő Gutyina Committed by GitHub
Browse files

python3Packages.netaddr: fix static build (#441076)

parents e70fe4ff 4dfe7395
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
{
  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 ];