1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchurl,
6 importlib-resources,
7 pytestCheckHook,
8 python,
9 pythonOlder,
10 setuptools,
11}:
12let
13 table = fetchurl {
14 # See https://github.com/dahlia/iso4217/blob/main/setup.py#L19
15 url = "https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml";
16 hash = "sha256-r1mRvI/qcOYOGKVzXHJGFdYxc+YlzpcdnWJExaF0Mp0=";
17 };
18in
19buildPythonPackage rec {
20 pname = "iso4217";
21 version = "1.14";
22 pyproject = true;
23
24 disabled = pythonOlder "3.7";
25
26 src = fetchFromGitHub {
27 owner = "dahlia";
28 repo = "iso4217";
29 tag = version;
30 hash = "sha256-lGXNSUBv/So3UgqXQ5AksqrCJVoyU8icDCfOda7Y5BE=";
31 };
32
33 build-system = [ setuptools ];
34
35 dependencies = lib.optionals (pythonOlder "3.9") [ importlib-resources ];
36
37 nativeCheckInputs = [ pytestCheckHook ];
38
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} iso4217/table.xml
44 '';
45
46 postInstall = ''
47 # Copy the table file
48 cp -r ${table} $out/${python.sitePackages}/iso4217/table.xml
49 '';
50
51 enabledTestPaths = [ "iso4217/test.py" ];
52
53 pythonImportsCheck = [ "iso4217" ];
54
55 meta = with lib; {
56 description = "ISO 4217 currency data package for Python";
57 homepage = "https://github.com/dahlia/iso4217";
58 license = with licenses; [ publicDomain ];
59 maintainers = with maintainers; [ fab ];
60 };
61}