Installing `cartopy` `cmaps` `geocat.viz` `metpy` for a python Project

I am trying to install some python dependencies for a project. I need to install the following dependencies: cartopy cmaps geocat.viz metpy.

I cannot install these dependencies because [NixOS Search](cartopy package) available on nix pacakage repo is broken. After searching through github repos I adjusted the build process to fix the broken by default cartopy dependency packaged for nix. See this. These are the instructions provided to install cartopy: Installation — cartopy 0.20.0 documentation

I cannot install cmaps because it is not available on the nix package repository. See this. The actual repo for the cmaps package is here: GitHub - hhuangwx/cmaps: user defined colormaps in matplotlib..

geocat.viz is not available on the nix package repo also. This is the source: GitHub - NCAR/geocat-viz.

Finally metpy is the final dependency that needs to be installed with nix in order for this project to built out in a reproducible manner. metpy is also not available on the nix package repo but installation instructions is provided here: Install Guide — MetPy 1.4

Any help would be greatly appreciated in editing this flake.nix file in order to install these 4 dependencies.

the cartopy issue has been fixed in python3Packages.cartopy: fix failing tests with proj 9.2 by kirillrdy · Pull Request #224135 · NixOS/nixpkgs · GitHub

1 Like

Thank you @kirillrdy, I appreciate all the help. The cartopy issue has been fixed.
However I am trying to get geocat.viz and cmaps installed using the buildPythonPackage function to build but I cannot get the python dependency to install using the following snippet in my flake

        geocat = inputs.nixpkgs.buildPythonPackage rec {
          pname = "geocat.viz";
          version = "0.9.1";
          src = inputs.nixpkgs.python3Packages.fetchPypi {
            inherit pname version;
            sha256 = "1hkyw2avwpj2f1qx2d2v9pf9xxr8r6f3j0bwq3l3gzb6w8ayppj1";
          };
        };

Error:

Any idea on how I get these 3 dependencies installed.

default.nix

{}:
let
  nixpkgs = (fetchTarball "https://github.com/NixOS/nixpkgs/archive/0874168639713f547c05947c76124f78441ea46c.tar.gz");
  pkgs = import nixpkgs { };
  buildPythonPackage = pkgs.python3Packages.buildPythonPackage;
  fetchPypi = pkgs.python3Packages.fetchPypi;

  metpy = buildPythonPackage rec{
    pname = "MetPy";
    version = "1.4.1";
    src = fetchPypi {
      inherit pname version;
      hash = "sha256-oT3S2jYOv9hWJw5BdG5P1Uutyp3NvYASKegDgs4x27k=";
    };
    propagatedBuildInputs = with pkgs.python3Packages ;[ setuptools_scm pyproj numpy xarray pint scipy traitlets pooch matplotlib ];
  };
  cmaps = buildPythonPackage rec{
    pname = "cmaps";
    version = "1.0.5";
    src = fetchPypi {
      inherit pname version;
      hash = "sha256-jucIv2xAJNzQYNZYqgy7p0CsBHLlY4UStHZN6h6SjEY=";
    };
    propagatedBuildInputs = with pkgs.python3Packages ;[ numpy matplotlib ];
  };

  goecat-viz = pkgs.python3Packages.buildPythonPackage rec {
    pname = "geocat.viz";
    version = "2022.7.0";
    src = pkgs.python3Packages.fetchPypi {
      inherit pname version;
      sha256 = "sha256-7iBZitt+A/BJVsBahlVAtUfps1b0jKBBsqpPWBoqhPI=";
    };
    propagatedBuildInputs = with pkgs.python3Packages; [ cmaps metpy cartopy xarray scikit-learn pint traitlets pooch ];
  };
in
pkgs.mkShell {
  pname = "geocat-shell";
  buildInputs = [
    (pkgs.python3.withPackages (ps: [ goecat-viz ]))
  ];
}
nix-shell
python3
Python 3.9.16 (main, Dec  6 2022, 18:36:13) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import geocat.viz

hopefully this works for you, and you can incorporate it into your flake

1 Like

Thank you, I appreciate that