1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchurl
5, pytestCheckHook
6, python
7}:
8let
9 table = fetchurl {
10 # See https://github.com/dahlia/iso4217/blob/main/setup.py#L18
11 url = "http://www.currency-iso.org/dam/downloads/lists/list_one.xml";
12 sha256 = "0frhicc7s8gqglr41hzx61fic3ckvr4sg773ahp1s28n5by3y7ac";
13 };
14in
15buildPythonPackage rec {
16 pname = "iso4217";
17 version = "1.6";
18
19 src = fetchFromGitHub {
20 owner = "dahlia";
21 repo = pname;
22 rev = version;
23 sha256 = "0mdpf5a0xr5lrcfgvqi1sdn7ln2w6pkc3lg0laqkbx5mhxky0fla";
24 };
25
26 checkInputs = [
27 pytestCheckHook
28 ];
29
30 preBuild = ''
31 # The table is already downloaded
32 export ISO4217_DOWNLOAD=0
33 # Copy the table file to satifiy the build process
34 cp -r ${table} $pname/table.xml
35 '';
36
37 postInstall = ''
38 # Copy the table file
39 cp -r ${table} $out/${python.sitePackages}/$pname/table.xml
40 '';
41
42 pytestFlagsArray = [ "$pname/test.py" ];
43
44 pythonImportsCheck = [ "iso4217" ];
45
46 meta = with lib; {
47 description = "ISO 4217 currency data package for Python";
48 homepage = "https://github.com/dahlia/iso4217";
49 license = with licenses; [ publicDomain ];
50 maintainers = with maintainers; [ fab ];
51 };
52}