14 buildPythonPackage rec {
17 format = "setuptools";
19 # pypi version does not include tests
20 src = fetchFromGitHub {
23 rev = "refs/tags/v${version}";
24 hash = "sha256-wXQaSMXQI0f7zfyj37mubxdqGFv7vhHQd6rH08H57d4=";
29 nativeCheckInputs = [ pytestCheckHook ];
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
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.
48 # - Remove the h3lib submodule.
49 # - Patch CMakeLists to avoid building h3lib, and use h3 instead.
53 include_directories(${lib.getDev h3}/include/h3)
54 link_directories(${h3}/lib)
58 substituteInPlace CMakeLists.txt --replace "add_subdirectory(src/h3lib)" "${cmakeCommands}"
61 # Extra check to make sure we can import it from Python
62 pythonImportsCheck = [ "h3" ];
65 homepage = "https://github.com/uber/h3-py";
66 description = "Hierarchical hexagonal geospatial indexing system";
67 license = licenses.asl20;
68 maintainers = [ maintainers.kalbasit ];