Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / h3 / default.nix
blob64be91a04fd9c2e2a01c414b15852d3d60ddb0eb
1 { autoPatchelfHook
2 , buildPythonPackage
3 , cmake
4 , cython
5 , fetchFromGitHub
6 , h3
7 , lib
8 , numpy
9 , pytestCheckHook
10 , scikit-build
11 , stdenv
14 buildPythonPackage rec {
15   pname = "h3";
16   version = "3.7.7";
17   format = "setuptools";
19   # pypi version does not include tests
20   src = fetchFromGitHub {
21     owner = "uber";
22     repo = "h3-py";
23     rev = "refs/tags/v${version}";
24     hash = "sha256-wXQaSMXQI0f7zfyj37mubxdqGFv7vhHQd6rH08H57d4=";
25   };
27   dontConfigure = true;
29   nativeCheckInputs = [ pytestCheckHook ];
31   nativeBuildInputs = [
32     scikit-build cmake cython
33   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
34     # On Linux the .so files ends up referring to libh3.so instead of the full
35     # Nix store path. I'm not sure why this is happening! On Darwin it works
36     # fine.
37     autoPatchelfHook
38   ];
40   # This is not needed per-se, it's only added for autoPatchelfHook to work
41   # correctly. See the note above ^^
42   buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ h3 ];
44   propagatedBuildInputs = [ numpy ];
46   # The following prePatch replaces the h3lib compilation with using the h3 packaged in nixpkgs.
47   #
48   # - Remove the h3lib submodule.
49   # - Patch CMakeLists to avoid building h3lib, and use h3 instead.
50   prePatch =
51     let
52       cmakeCommands = ''
53         include_directories(${lib.getDev h3}/include/h3)
54         link_directories(${h3}/lib)
55       '';
56     in ''
57       rm -r src/h3lib
58       substituteInPlace CMakeLists.txt --replace "add_subdirectory(src/h3lib)" "${cmakeCommands}"
59     '';
61   # Extra check to make sure we can import it from Python
62   pythonImportsCheck = [ "h3" ];
64   meta = with lib; {
65     homepage = "https://github.com/uber/h3-py";
66     description = "Hierarchical hexagonal geospatial indexing system";
67     license = licenses.asl20;
68     maintainers = [ maintainers.kalbasit ];
69   };