Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: Add Rtree library #36760

Merged
merged 1 commit into from Apr 4, 2018
Merged

python: Add Rtree library #36760

merged 1 commit into from Apr 4, 2018

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Mar 10, 2018

Motivation for this change

This library is used by another package which I am working on packaging.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the general and Python-specific contributing guidelines.

@bgamari
Copy link
Contributor Author

bgamari commented Mar 10, 2018

Oh dear, yes, I clearly failed here. Sorry about that.

Let's try this again.

@bgamari
Copy link
Contributor Author

bgamari commented Mar 10, 2018

Alright, I believe this should be ready for review.

Thanks @FRidh!

Copy link
Member

@dotlambda dotlambda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your commit message should start with pythonPackages.rtree

propagatedBuildInputs = [ libspatialindex ];
patchPhase = ''
substituteInPlace rtree/core.py --replace \
"find_library('spatialindex_c')" "'${libspatialindex}/lib/libspatialindex_c.so.4'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very future-proof because of the .4 suffix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please use ${stdenv.hostPlatform.extensions.sharedLibrary}

name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
sha256 = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear, good catch.

inherit pname version;
sha256 = null;
};
doCheck = false; # appears to be broken
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More detail please. Did you try fixing the failures?

buildPythonPackage rec {
pname = "Rtree";
version = "0.8.3";
name = "${pname}-${version}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave this line out.

@@ -21125,6 +21125,8 @@ EOF
wsproto = callPackage ../development/python-modules/wsproto { };

h11 = callPackage ../development/python-modules/h11 { };

Rtree = callPackage ../development/python-modules/Rtree { inherit (pkgs) libspatialindex; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Rtree/rtree/g

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? The library is actually called Rtree and I see plenty of other packages whose names reflect their actual capitalization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer lowercase, but I think it's up to you.
However, plaese try to stick with the alphabetical ordering of python-packages.nix.

@bgamari
Copy link
Contributor Author

bgamari commented Apr 3, 2018

I believe I have fixed all of the noted issues save the test failures. Unfortunately the failures appear to be due to memory unsafe issues that I was unable to reproduce on under Debian with the same versions of libspatialindex and Rtree. For instance, valgrind says (one of many failures),

==10453== Invalid read of size 4
==10453==    at 0x4EF1DFA: _PyObject_Free (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FBADC3: _sre_SRE_Pattern_findall (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4EEC8AF: _PyCFunction_FastCallDict (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5DD71: call_function (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F60926: _PyEval_EvalFrameDefault (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5CEBE: _PyFunction_FastCall (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5DC54: call_function (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F60926: _PyEval_EvalFrameDefault (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5D8A5: _PyEval_EvalCodeWithName (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5DA4E: fast_function (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F5DC54: call_function (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F60926: _PyEval_EvalFrameDefault (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)

Nevertheless, I was able to use Rtree without any trouble in an application, so it's not clear to me that this should hold up merging.

@bgamari bgamari force-pushed the Rtree branch 2 times, most recently from 35e4b20 to f56999c Compare April 3, 2018 14:50
@dotlambda
Copy link
Member

@GrahamcOfBorg build python2.pkgs.Rtree python3.pkgs.Rtree

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: python2.pkgs.Rtree, python3.pkgs.Rtree

Partial log (click to expand)

Successfully installed Rtree-0.8.3
/build/Rtree-0.8.3
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/wlfbkxskz804izli29fs6qdc251ls4kd-python3.6-Rtree-0.8.3
strip is /nix/store/fzcs0fn6bb04m82frhlb78nc03ny3w55-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/wlfbkxskz804izli29fs6qdc251ls4kd-python3.6-Rtree-0.8.3/lib
patching script interpreter paths in /nix/store/wlfbkxskz804izli29fs6qdc251ls4kd-python3.6-Rtree-0.8.3
checking for references to /build in /nix/store/wlfbkxskz804izli29fs6qdc251ls4kd-python3.6-Rtree-0.8.3...
/nix/store/y10ybjlpizqjml5i62m3691nw5q2xk6j-python2.7-Rtree-0.8.3
/nix/store/wlfbkxskz804izli29fs6qdc251ls4kd-python3.6-Rtree-0.8.3

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: python2.pkgs.Rtree, python3.pkgs.Rtree

Partial log (click to expand)

Successfully installed Rtree-0.8.3
/build/Rtree-0.8.3
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/z6fypbjx82a963ij8mlz49bika858582-python3.6-Rtree-0.8.3
strip is /nix/store/3zq400fri5dv7d30lpxlqm2v9y1iis6j-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/z6fypbjx82a963ij8mlz49bika858582-python3.6-Rtree-0.8.3/lib
patching script interpreter paths in /nix/store/z6fypbjx82a963ij8mlz49bika858582-python3.6-Rtree-0.8.3
checking for references to /build in /nix/store/z6fypbjx82a963ij8mlz49bika858582-python3.6-Rtree-0.8.3...
/nix/store/f5m1hb5m5x4n06lxfaa0bai7xfgvnlhx-python2.7-Rtree-0.8.3
/nix/store/z6fypbjx82a963ij8mlz49bika858582-python3.6-Rtree-0.8.3

This is a commonly-used package for spatial indexing.

Strangely enough, the tests are broken due to memory unsafety that I was unable
to reproduce under Debian. For instance, when run with Python 3.6 valgrind
reports,

==10453== Invalid read of size 4
==10453==    at 0x4EF1DFA: _PyObject_Free (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FE7D96: _PyFaulthandler_Fini (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F8438D: Py_FinalizeEx (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F9F398: Py_Main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x400BDF: main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/bin/python3.6)
==10453==  Address 0x67b1020 is 352 bytes inside a block of size 640 free'd
==10453==    at 0x4C2DD6B: free (in /nix/store/6z028lfnxyhh8dlngpm6zrkwqxmbglj4-valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10453==    by 0x4EDDC4A: free_keys_object (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4EDEE63: dict_dealloc (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4EECF59: module_clear (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FA062B: collect (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FA13A0: _PyGC_CollectNoFail (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F79CED: PyImport_Cleanup (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F8436F: Py_FinalizeEx (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F9F398: Py_Main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x400BDF: main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/bin/python3.6)
==10453==
==10453== Conditional jump or move depends on uninitialised value(s)
==10453==    at 0x4EF1E03: _PyObject_Free (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4EFEF2D: type_dealloc (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4EFD009: subtype_dealloc (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FA063E: collect (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4FA13A0: _PyGC_CollectNoFail (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F79DF8: PyImport_Cleanup (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F8436F: Py_FinalizeEx (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x4F9F398: Py_Main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/lib/libpython3.6m.so.1.0)
==10453==    by 0x400BDF: main (in /nix/store/azw9ys2m2fpfzf730xjcxja890gpyp58-python3-3.6.4/bin/python3.6)
==10453==
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants