1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 libspatialindex,
7 numpy,
8 pytestCheckHook,
9 pythonOlder,
10 setuptools,
11 wheel,
12}:
13
14buildPythonPackage rec {
15 pname = "rtree";
16 version = "1.4.1";
17 pyproject = true;
18
19 disabled = pythonOlder "3.9";
20
21 src = fetchFromGitHub {
22 owner = "Toblerity";
23 repo = "rtree";
24 tag = version;
25 hash = "sha256-ilhHBAYa4GaKUt8CmmJRS569D9INHZmWS6lK/+AIiqY=";
26 };
27
28 postPatch = ''
29 substituteInPlace rtree/finder.py --replace \
30 'find_library("spatialindex_c")' '"${libspatialindex}/lib/libspatialindex_c${stdenv.hostPlatform.extensions.sharedLibrary}"'
31 '';
32
33 nativeBuildInputs = [
34 setuptools
35 wheel
36 ];
37
38 buildInputs = [ libspatialindex ];
39
40 nativeCheckInputs = [
41 numpy
42 pytestCheckHook
43 ];
44
45 pythonImportsCheck = [ "rtree" ];
46
47 meta = with lib; {
48 description = "R-Tree spatial index for Python GIS";
49 homepage = "https://github.com/Toblerity/rtree";
50 changelog = "https://github.com/Toblerity/rtree/blob/${src.tag}/CHANGES.rst";
51 license = licenses.mit;
52 maintainers = with maintainers; [ bgamari ];
53 teams = [ teams.geospatial ];
54 };
55}