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