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