{ lib, buildPythonPackage, fetchPypi, nose, pkgconfig }:

buildPythonPackage rec {
  pname = "pkgconfig";
  version = "1.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "048c3b457da7b6f686b647ab10bf09e2250e4c50acfe6f215398a8b5e6fcdb52";
  };

  checkInputs = [ nose ];

  # Apparently many our expressions get pythonPackages.pkgconfig and expect
  # to have the pkg-config executable on $PATH
  # For some reason, propagatedNativeBuildInputs don't seem enough.
  propagatedBuildInputs = [ pkgconfig ];

  checkPhase = ''
    nosetests
  '';

  patches = [ ./executable.patch ];
  postPatch = ''
    substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/pkg-config"'
  '';

  meta = with lib; {
    description = "Interface Python with pkg-config";
    homepage = https://github.com/matze/pkgconfig;
    license = licenses.mit;
  };
}

{ lib, buildPythonPackage, fetchPypi, nose, pkgconfig }:

buildPythonPackage rec {
  pname = "pkgconfig";
  version = "1.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "048c3b457da7b6f686b647ab10bf09e2250e4c50acfe6f215398a8b5e6fcdb52";
  };

  checkInputs = [ nose ];

  nativeBuildInputs = [ pkgconfig ];

  checkPhase = ''
    nosetests
  '';

  patches = [ ./executable.patch ];
  postPatch = ''
    substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/pkg-config"'
  '';

  meta = with lib; {
    description = "Interface Python with pkg-config";
    homepage = https://github.com/matze/pkgconfig;
    license = licenses.mit;
  };
}

Revert "python*Packages.pkgconfig: try avoiding multiple breakages"
Revert "python*Packages.pkgconfig: try avoiding multiple breakages"

This reverts commit 3d979f432cef1836386ecf0cf466da06d01f422f.
The remaining problems should be fixed by eb3f0aef438e55058f21747fe95e947977ad4734.
