1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5, chardet
6, requests
7, ruamel-yaml
8, setuptools-scm
9, six
10, semver
11, pytestCheckHook
12, openapi-spec-validator
13}:
14
15buildPythonPackage rec {
16 pname = "prance";
17 version = "0.21.8.0";
18 format = "pyproject";
19
20 src = fetchFromGitHub {
21 owner = "RonnyPfannschmidt";
22 repo = pname;
23 rev = "v${version}";
24 fetchSubmodules = true;
25 hash = "sha256-kGANMHfWwhW3ZBw2ZVCJZR/bV2EPhcydMKhDeDTVwcQ=";
26 };
27
28 patches = [
29 # Fix for openapi-spec-validator 0.5.0+:
30 # https://github.com/RonnyPfannschmidt/prance/pull/132
31 (fetchpatch {
32 name = "1-openapi-spec-validator-upgrade.patch";
33 url = "https://github.com/RonnyPfannschmidt/prance/commit/55503c9b12b685863c932ededac996369e7d288a.patch";
34 hash = "sha256-7SOgFsk2aaaaAYS8WJ9axqQFyEprurn6Zn12NcdQ9Bg=";
35 })
36 (fetchpatch {
37 name = "2-openapi-spec-validator-upgrade.patch";
38 url = "https://github.com/RonnyPfannschmidt/prance/commit/7e59cc69c6c62fd04875105773d9d220bb58fea6.patch";
39 hash = "sha256-j6vmY3NqDswp7v9682H+/MxMGtFObMxUeL9Wbiv9hYw=";
40 })
41 (fetchpatch {
42 name = "3-openapi-spec-validator-upgrade.patch";
43 url = "https://github.com/RonnyPfannschmidt/prance/commit/7e575781d83845d7ea0c2eff57644df9b465c7af.patch";
44 hash = "sha256-rexKoQ+TH3QmP20c3bA+7BLMLc+fkVhn7xsq+gle1Aw=";
45 })
46 ];
47
48 postPatch = ''
49 substituteInPlace setup.cfg \
50 --replace "--cov=prance --cov-report=term-missing --cov-fail-under=90" "" \
51 --replace "chardet>=3.0,<5.0" "chardet"
52 '';
53
54 SETUPTOOLS_SCM_PRETEND_VERSION = version;
55
56 nativeBuildInputs = [
57 setuptools-scm
58 ];
59
60 propagatedBuildInputs = [
61 chardet
62 requests
63 ruamel-yaml
64 six
65 semver
66 ];
67
68 checkInputs = [
69 pytestCheckHook
70 openapi-spec-validator
71 ];
72
73 # Disable tests that require network
74 disabledTestPaths = [
75 "tests/test_convert.py"
76 ];
77 disabledTests = [
78 "test_fetch_url_http"
79 ];
80 pythonImportsCheck = [ "prance" ];
81
82 meta = with lib; {
83 description = "Resolving Swagger/OpenAPI 2.0 and 3.0.0 Parser";
84 homepage = "https://github.com/RonnyPfannschmidt/prance";
85 license = licenses.mit;
86 maintainers = [ maintainers.costrouc ];
87 };
88}