2021-02-09 00:43:47 +01:00
|
|
|
{ autoPatchelfHook
|
2019-07-17 02:39:52 +02:00
|
|
|
, buildPythonPackage
|
|
|
|
, cmake
|
2021-02-09 00:43:47 +01:00
|
|
|
, cython
|
|
|
|
, fetchFromGitHub
|
2019-07-17 02:39:52 +02:00
|
|
|
, h3
|
2021-02-09 00:43:47 +01:00
|
|
|
, lib
|
|
|
|
, numpy
|
|
|
|
, pytestCheckHook
|
|
|
|
, scikit-build
|
|
|
|
, stdenv
|
2019-07-17 02:39:52 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "h3";
|
2021-06-19 03:39:07 +02:00
|
|
|
version = "3.7.3";
|
2019-07-17 02:39:52 +02:00
|
|
|
|
2021-02-09 00:43:47 +01:00
|
|
|
# pypi version does not include tests
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "uber";
|
|
|
|
repo = "h3-py";
|
|
|
|
rev = "v${version}";
|
2021-06-19 03:39:07 +02:00
|
|
|
sha256 = "0wc1fz8v59r97wlayr4lnsgwzd4fxm991xbs9690d4vwdkapafll";
|
2019-07-17 02:39:52 +02:00
|
|
|
};
|
|
|
|
|
2021-02-09 00:43:47 +01:00
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
scikit-build cmake cython
|
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
|
|
|
# On Linux the .so files ends up referring to libh3.so instead of the full
|
|
|
|
# Nix store path. I'm not sure why this is happening! On Darwin it works
|
|
|
|
# fine.
|
|
|
|
autoPatchelfHook
|
2019-07-17 02:39:52 +02:00
|
|
|
];
|
|
|
|
|
2021-02-09 00:43:47 +01:00
|
|
|
# This is not needed per-se, it's only added for autoPatchelfHook to work
|
|
|
|
# correctly. See the note above ^^
|
|
|
|
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ h3 ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ numpy ];
|
|
|
|
|
|
|
|
# The following prePatch replaces the h3lib compilation with using the h3 packaged in nixpkgs.
|
|
|
|
#
|
|
|
|
# - Remove the h3lib submodule.
|
|
|
|
# - Patch CMakeLists to avoid building h3lib, and use h3 instead.
|
|
|
|
prePatch =
|
|
|
|
let
|
|
|
|
cmakeCommands = ''
|
|
|
|
include_directories(${h3}/include/h3)
|
|
|
|
link_directories(${h3}/lib)
|
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
rm -r src/h3lib
|
|
|
|
substituteInPlace CMakeLists.txt --replace "add_subdirectory(src/h3lib)" "${cmakeCommands}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Extra check to make sure we can import it from Python
|
|
|
|
pythonImportsCheck = [ "h3" ];
|
2019-07-17 02:39:52 +02:00
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-07-17 02:39:52 +02:00
|
|
|
homepage = "https://github.com/uber/h3-py";
|
2021-02-09 00:43:47 +01:00
|
|
|
description = "Hierarchical hexagonal geospatial indexing system";
|
2019-07-17 02:39:52 +02:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.kalbasit ];
|
|
|
|
};
|
|
|
|
}
|