1{
2 lib,
3 stdenv,
4 pythonOlder,
5 buildPythonPackage,
6 fetchFromGitHub,
7 setuptools-scm,
8 gmt,
9 numpy,
10 netcdf4,
11 pandas,
12 packaging,
13 xarray,
14 pytest-mpl,
15 ipython,
16 ghostscript,
17 pytestCheckHook,
18}:
19
20buildPythonPackage rec {
21 pname = "pygmt";
22 version = "0.11.0";
23 format = "pyproject";
24
25 disabled = pythonOlder "3.9";
26
27 src = fetchFromGitHub {
28 owner = "GenericMappingTools";
29 repo = "pygmt";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-DbewB/lP44bpNSQ4ht7n0coS2Ml7qmEU4CP91p5YtZg=";
32 };
33
34 postPatch = ''
35 substituteInPlace pygmt/clib/loading.py \
36 --replace "env.get(\"GMT_LIBRARY_PATH\", \"\")" "env.get(\"GMT_LIBRARY_PATH\", \"${gmt}/lib\")"
37 '';
38
39 nativeBuildInputs = [ setuptools-scm ];
40
41 propagatedBuildInputs = [
42 numpy
43 netcdf4
44 pandas
45 packaging
46 xarray
47 ];
48
49 nativeCheckInputs = [
50 pytestCheckHook
51 pytest-mpl
52 ghostscript
53 ipython
54 ];
55
56 # The *entire* test suite requires network access
57 doCheck = false;
58
59 postBuild = ''
60 export HOME=$TMP
61 '';
62
63 pythonImportsCheck = [ "pygmt" ];
64
65 meta = with lib; {
66 description = "Python interface for the Generic Mapping Tools";
67 homepage = "https://github.com/GenericMappingTools/pygmt";
68 license = licenses.bsd3;
69 changelog = "https://github.com/GenericMappingTools/pygmt/releases/tag/v${version}";
70 # pygmt.exceptions.GMTCLibNotFoundError: Error loading the GMT shared library '/nix/store/r3xnnqgl89vrnq0kzxx0bmjwzks45mz8-gmt-6.1.1/lib/libgmt.dylib'
71 broken = stdenv.isDarwin;
72 maintainers = with maintainers; [ sikmir ];
73 };
74}