Commit 45a706c5 authored by Robert Schütz's avatar Robert Schütz
Browse files
parent 9ca5356d
Loading
Loading
Loading
Loading
+24 −29
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, fetchpatch
, chardet
, click
, flex
, packaging
, pyicu
, requests
, ruamel-yaml
, setuptools-scm
, six
, semver
, swagger-spec-validator
, pytestCheckHook
, openapi-spec-validator
}:

buildPythonPackage rec {
  pname = "prance";
  version = "0.21.8.0";
  version = "0.22.02.22.0";
  format = "pyproject";

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "RonnyPfannschmidt";
    repo = pname;
    rev = "v${version}";
    fetchSubmodules = true;
    hash = "sha256-kGANMHfWwhW3ZBw2ZVCJZR/bV2EPhcydMKhDeDTVwcQ=";
    hash = "sha256-NtIbZp34IcMYJzaNQVL9GLdNS3NYOCRoWS1wGg/gLVA=";
  };

  patches = [
    # Fix for openapi-spec-validator 0.5.0+:
    # https://github.com/RonnyPfannschmidt/prance/pull/132
    (fetchpatch {
      name = "1-openapi-spec-validator-upgrade.patch";
      url = "https://github.com/RonnyPfannschmidt/prance/commit/55503c9b12b685863c932ededac996369e7d288a.patch";
      hash = "sha256-7SOgFsk2aaaaAYS8WJ9axqQFyEprurn6Zn12NcdQ9Bg=";
    })
    (fetchpatch {
      name = "2-openapi-spec-validator-upgrade.patch";
      url = "https://github.com/RonnyPfannschmidt/prance/commit/7e59cc69c6c62fd04875105773d9d220bb58fea6.patch";
      hash = "sha256-j6vmY3NqDswp7v9682H+/MxMGtFObMxUeL9Wbiv9hYw=";
    })
    (fetchpatch {
      name = "3-openapi-spec-validator-upgrade.patch";
      url = "https://github.com/RonnyPfannschmidt/prance/commit/7e575781d83845d7ea0c2eff57644df9b465c7af.patch";
      hash = "sha256-rexKoQ+TH3QmP20c3bA+7BLMLc+fkVhn7xsq+gle1Aw=";
    })
  ];

  postPatch = ''
    substituteInPlace setup.cfg \
      --replace "--cov=prance --cov-report=term-missing --cov-fail-under=90" "" \
      --replace "chardet>=3.0,<5.0" "chardet"
      --replace "--cov=prance --cov-report=term-missing --cov-fail-under=90" ""
  '';

  SETUPTOOLS_SCM_PRETEND_VERSION = version;
@@ -59,27 +44,37 @@ buildPythonPackage rec {

  propagatedBuildInputs = [
    chardet
    packaging
    requests
    ruamel-yaml
    six
    semver
  ];

  passthru.optional-dependencies = {
    cli = [ click ];
    flex = [ flex ];
    icu = [ pyicu ];
    osv = [ openapi-spec-validator ];
    ssv = [ swagger-spec-validator ];
  };

  nativeCheckInputs = [
    pytestCheckHook
    openapi-spec-validator
  ];
  ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);

  # Disable tests that require network
  disabledTestPaths = [
    "tests/test_convert.py"
  ];
  disabledTests = [
    "test_convert_defaults"
    "test_convert_output"
    "test_fetch_url_http"
  ];
  pythonImportsCheck = [ "prance" ];

  meta = with lib; {
    changelog = "https://github.com/RonnyPfannschmidt/prance/blob/${src.rev}/CHANGES.rst";
    description = "Resolving Swagger/OpenAPI 2.0 and 3.0.0 Parser";
    homepage = "https://github.com/RonnyPfannschmidt/prance";
    license = licenses.mit;