Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / python-modules / iso4217 / default.nix
blob50268536bda57fef23660c030ea07fa8aad4e23a
1 { lib
2 , buildPythonPackage
3 , fetchFromGitHub
4 , fetchurl
5 , importlib-resources
6 , pytestCheckHook
7 , python
8 , pythonOlder
9 }:
10 let
11   table = fetchurl {
12     # See https://github.com/dahlia/iso4217/blob/main/setup.py#L19
13     url = "http://www.currency-iso.org/dam/downloads/lists/list_one.xml";
14     hash = "sha256-bp8uTMR1YRaI2cJLo0kdt9xD4nNaWK+LdlheWQ26qy0=";
15   };
17 buildPythonPackage rec {
18   pname = "iso4217";
19   version = "1.11";
20   format = "setuptools";
22   disabled = pythonOlder "3.7";
24   src = fetchFromGitHub {
25     owner = "dahlia";
26     repo = pname;
27     rev = version;
28     hash = "sha256-zJYtEIrsuHKPwnSoRjyZC/0rgAZoNMZ0Oh8gQcIb20Q=";
29   };
31   propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [
32     importlib-resources
33   ];
35   nativeCheckInputs = [
36     pytestCheckHook
37   ];
39   preBuild = ''
40     # The table is already downloaded
41     export ISO4217_DOWNLOAD=0
42     # Copy the table file to satifiy the build process
43     cp -r ${table} $pname/table.xml
44   '';
46   postInstall = ''
47     # Copy the table file
48     cp -r ${table} $out/${python.sitePackages}/$pname/table.xml
49   '';
51   pytestFlagsArray = [
52     "$pname/test.py"
53   ];
55   pythonImportsCheck = [
56     "iso4217"
57   ];
59   meta = with lib; {
60     description = "ISO 4217 currency data package for Python";
61     homepage = "https://github.com/dahlia/iso4217";
62     license = with licenses; [ publicDomain ];
63     maintainers = with maintainers; [ fab ];
64   };