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