|
| 1 | +{ |
| 2 | + description = "Unofficial Python SDK for the FinWise API"; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
| 7 | + }; |
| 8 | + |
| 9 | + outputs = { self, nixpkgs, flake-utils }: |
| 10 | + flake-utils.lib.eachDefaultSystem (system: |
| 11 | + let |
| 12 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 13 | + |
| 14 | + pythonVersions = { |
| 15 | + python311 = pkgs.python311; |
| 16 | + python312 = pkgs.python312; |
| 17 | + python313 = pkgs.python313; |
| 18 | + }; |
| 19 | + |
| 20 | + defaultPython = pythonVersions.python311; |
| 21 | + |
| 22 | + mkFinwise = python: python.pkgs.buildPythonPackage rec { |
| 23 | + pname = "finwise-python"; |
| 24 | + version = "1.2.0"; |
| 25 | + pyproject = true; |
| 26 | + |
| 27 | + src = pkgs.lib.cleanSourceWith { |
| 28 | + filter = name: type: |
| 29 | + let baseName = baseNameOf (toString name); |
| 30 | + in !( |
| 31 | + baseName == ".git" || |
| 32 | + baseName == ".github" || |
| 33 | + baseName == ".venv" || |
| 34 | + baseName == ".mypy_cache" || |
| 35 | + baseName == ".pytest_cache" || |
| 36 | + baseName == ".ruff_cache" || |
| 37 | + baseName == "site" || |
| 38 | + baseName == "__pycache__" || |
| 39 | + baseName == "result" || |
| 40 | + baseName == ".direnv" || |
| 41 | + pkgs.lib.hasSuffix ".egg-info" baseName |
| 42 | + ); |
| 43 | + src = ./.; |
| 44 | + }; |
| 45 | + |
| 46 | + build-system = with python.pkgs; [ |
| 47 | + hatchling |
| 48 | + ]; |
| 49 | + |
| 50 | + dependencies = with python.pkgs; [ |
| 51 | + httpx |
| 52 | + pydantic |
| 53 | + ]; |
| 54 | + |
| 55 | + nativeCheckInputs = with python.pkgs; [ |
| 56 | + pytestCheckHook |
| 57 | + pytest-cov |
| 58 | + respx |
| 59 | + ]; |
| 60 | + |
| 61 | + pythonImportsCheck = [ "finwise" ]; |
| 62 | + |
| 63 | + meta = with pkgs.lib; { |
| 64 | + description = "Unofficial Python SDK for the FinWise API"; |
| 65 | + homepage = "https://github.com/rameezk/finwise-python"; |
| 66 | + license = licenses.mit; |
| 67 | + maintainers = [ ]; |
| 68 | + platforms = platforms.unix; |
| 69 | + }; |
| 70 | + }; |
| 71 | + |
| 72 | + mkDevShell = python: pkgs.mkShell { |
| 73 | + packages = [ |
| 74 | + (python.withPackages (ps: with ps; [ |
| 75 | + httpx |
| 76 | + pydantic |
| 77 | + pytest |
| 78 | + pytest-cov |
| 79 | + respx |
| 80 | + mypy |
| 81 | + ruff |
| 82 | + hatchling |
| 83 | + pip |
| 84 | + build |
| 85 | + ])) |
| 86 | + ]; |
| 87 | + |
| 88 | + shellHook = '' |
| 89 | + echo "FinWise Python SDK development environment" |
| 90 | + echo "Python version: $(python --version)" |
| 91 | + ''; |
| 92 | + }; |
| 93 | + |
| 94 | + docsShell = pkgs.mkShell { |
| 95 | + packages = [ |
| 96 | + (defaultPython.withPackages (ps: with ps; [ |
| 97 | + mkdocs |
| 98 | + mkdocs-material |
| 99 | + ])) |
| 100 | + ]; |
| 101 | + |
| 102 | + shellHook = '' |
| 103 | + echo "FinWise Python SDK documentation environment" |
| 104 | + echo "Run 'mkdocs serve' to preview docs locally" |
| 105 | + ''; |
| 106 | + }; |
| 107 | + |
| 108 | + in { |
| 109 | + packages = { |
| 110 | + default = mkFinwise defaultPython; |
| 111 | + finwise-python311 = mkFinwise pythonVersions.python311; |
| 112 | + finwise-python312 = mkFinwise pythonVersions.python312; |
| 113 | + finwise-python313 = mkFinwise pythonVersions.python313; |
| 114 | + }; |
| 115 | + |
| 116 | + devShells = { |
| 117 | + default = mkDevShell defaultPython; |
| 118 | + python311 = mkDevShell pythonVersions.python311; |
| 119 | + python312 = mkDevShell pythonVersions.python312; |
| 120 | + python313 = mkDevShell pythonVersions.python313; |
| 121 | + docs = docsShell; |
| 122 | + }; |
| 123 | + |
| 124 | + apps = { |
| 125 | + docs-serve = { |
| 126 | + type = "app"; |
| 127 | + program = toString (pkgs.writeShellScript "docs-serve" '' |
| 128 | + cd ${./.} |
| 129 | + ${defaultPython.withPackages (ps: with ps; [ mkdocs mkdocs-material ])}/bin/mkdocs serve |
| 130 | + ''); |
| 131 | + }; |
| 132 | + docs-build = { |
| 133 | + type = "app"; |
| 134 | + program = toString (pkgs.writeShellScript "docs-build" '' |
| 135 | + cd ${./.} |
| 136 | + ${defaultPython.withPackages (ps: with ps; [ mkdocs mkdocs-material ])}/bin/mkdocs build |
| 137 | + ''); |
| 138 | + }; |
| 139 | + }; |
| 140 | + |
| 141 | + checks = { |
| 142 | + default = mkFinwise defaultPython; |
| 143 | + }; |
| 144 | + } |
| 145 | + ); |
| 146 | +} |
0 commit comments