debian/0000755000000000000000000000000012313576675007205 5ustar debian/docs0000644000000000000000000000002112173467126010043 0ustar NEWS README TODO debian/python-kdtree-dbg.install0000644000000000000000000000004412173467126014114 0ustar usr/lib/python2.*/*-packages/*_d.so debian/libkdtree++-dev.examples0000644000000000000000000000001312173467126013600 0ustar examples/* debian/copyright0000644000000000000000000002255412173467126011142 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: libkdtree++ Source: https://alioth.debian.org/projects/libkdtree/ Files: * Copyright: 2004-2007 Martin F. Krafft 2004-2010 Paul Harris 2007-2010 Sylvain Bougerel 2008-2009 Willi Richert License: Artistic-2.0 Files: debian/* Copyright: 2004 Martin F. Krafft 2008 Martin Schreiber 2012-2013 Sebastian Ramacher License: Artistic-2.0 License: Artistic-2.0 Copyright (c) 2000-2006, The Perl Foundation. http://www.perlfoundation.org/artistic_license_2_0 . Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. . Preamble . This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. . You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. . Definitions . "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. . "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. . "You" and "your" means any person who would like to copy, distribute, or modify the Package. . "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. . "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. . "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. . "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. . "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. . "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. . "Source" form means the source code, documentation source, and configuration files for the Package. . "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. . Permission for Use and Modification Without Distribution . (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. . Permissions for Redistribution of the Standard Version . (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. . (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. . Distribution of Modified Versions of the Package as Source . (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: . (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. . Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source . (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. . (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. . Aggregating or Linking the Package . (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. . (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. . Items That are Not Considered Part of a Modified Version . (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. . General Provisions . (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. . (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. . (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. . (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. . (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. debian/changelog0000644000000000000000000001030712313576675011060 0ustar libkdtree++ (0.7.1+git20101123-3build1) trusty; urgency=medium * No-change rebuild to drop Python 3.3 support. -- Matthias Klose Sun, 23 Mar 2014 15:29:01 +0000 libkdtree++ (0.7.1+git20101123-3) unstable; urgency=medium * debian/python3-kdtree{-dbg}.install: Fix wildcard so that dh_install does not fail. (Closes: #735820) * debian/rules: Make test targets not fail if nocheck is given in DEB_BUILD_OPTIONS. * debian/control: Bump Standards-Version (no changes required). -- Sebastian Ramacher Fri, 17 Jan 2014 22:10:49 +0100 libkdtree++ (0.7.1+git20101123-2) unstable; urgency=low * Upload to unstable. * debian/copyright: Convert to Copyright Format 1.0. * debian/rules: Replace override_dh_install with proper install files. -- Sebastian Ramacher Sun, 05 May 2013 02:43:45 +0200 libkdtree++ (0.7.1+git20101123-1) experimental; urgency=low * New git snapshot. (Closes: #559306) - Add get-orig-source rule to debian/rules to create the snapshot tarball. * Convert to 3.0 (quilt). * debian/control: - Update my mail address. - Add Homepage field. - Add ${misc:Depends} to Depends. - Bump debhelper Build-Dep to >= 9. * debian/compat: Bump to 9. * debian/watch: Add watch file. * debian/copyright: - Update my mail address. - Add Willi Richert. - Update Sylvain Bougerel's and Paul Harris' copyright years. * Ship examples in libkdtree++-dev. (Closes: #527370) * Ship Python bindings. (Closes: #559307) - debian/control: Add python-kdtree{,-dbg} and python3-kdtreee{,-dbg} packages. - debian/rules: Rewrite to build Python bindings for all supported Python versions. - debian/control: Add Build-Dep on swig, cmake, python-all{,-dbg} and python3-all{,-dbg}. - debian/patches: Add a series of patches to build and install the Python bindings properly. - debian/clean: Clean pyc files generated while running the tests. * debian/README.Debian: Removed, not needed anymore. -- Sebastian Ramacher Mon, 31 Dec 2012 00:25:37 +0100 libkdtree++ (0.7.0-2) unstable; urgency=low * New maintainer. (Closes: #689206) Thanks to Martin Schreiber for maintaining libkdtree++! * debian/copyright: - List the copyright of the authors. (Closes: #688796) - Mention the download location. - List the Debian maintainers. - Update URL of the Artistic License. * debian/README.Debian: Document that this is a snapshot of 222b5d77 and not 0.7.0. -- Sebastian Ramacher Thu, 11 Oct 2012 21:24:38 +0200 libkdtree++ (0.7.0-1.1) unstable; urgency=low * Non-maintainer upload. * Cherry pick 8d4fbb9a from upstream to fix issues with g++ 4.7. (Closes: #687604) -- Sebastian Ramacher Tue, 25 Sep 2012 16:57:06 +0200 libkdtree++ (0.7.0-1) unstable; urgency=low * New upstream release (closes: Bug#506485) -- Martin Schreiber Tue, 30 Dec 2008 10:34:06 +0100 libkdtree++ (0.6.2-1) unstable; urgency=low * New upstream version (closes: Bug#459106) * New maintainer -- Martin Schreiber Fri, 08 Feb 2008 22:52:21 +0100 libkdtree++ (0.2.0-1) unstable; urgency=low * New upstream version, thanks to Paul Harris. * Closes bugs from 0.1.3-1, which was not officially uploaded to Debian (closes: Bug#279614, Bug#279620). -- martin f. krafft Mon, 15 Nov 2004 09:40:36 +0100 libkdtree++ (0.1.3-1) unstable; urgency=low * New upstream version (closes: Bug#279614, Bug#279620). * Pushed Standards-Version to 3.6.1.1 -- martin f. krafft Thu, 4 Nov 2004 10:29:23 +0100 libkdtree++ (0.1.2-1) unstable; urgency=low * Added note about lack of runtime and shared libraries. * Changed licence to the artistic licence. -- martin f. krafft Sun, 16 May 2004 00:52:10 +0200 libkdtree++ (0.1.1-1) unstable; urgency=low * New upstream release. -- martin f. krafft Tue, 11 May 2004 19:48:32 +0200 libkdtree++ (0.1.0-1) unstable; urgency=low * Initial Release. (closes: Bug#248219) -- martin f. krafft Tue, 11 May 2004 15:49:02 +0200 debian/python3-kdtree.install0000644000000000000000000000016712266315240013443 0ustar usr/lib/python3/*-packages/*.egg-info usr/lib/python3/*-packages/*.py usr/lib/python3/*-packages/*.cpython-3[1-9]m*.so debian/clean0000644000000000000000000000007012173467126010201 0ustar python-bindings/*.pyc python-bindings/__pycache__/*.pyc debian/compat0000644000000000000000000000000212173467126010375 0ustar 9 debian/python3-kdtree-dbg.install0000644000000000000000000000005512266316045014175 0ustar usr/lib/python3/*-packages/*.cpython-*dm*.so debian/patches/0000755000000000000000000000000012173467126010626 5ustar debian/patches/enable-tests.patch0000644000000000000000000000211412173467126014233 0ustar Description: Enable testing and add test cases Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- CMakeLists.txt | 1 + examples/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a84b167..ebd596a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ project (libkdtree CXX) cmake_minimum_required (VERSION 2.6.0) +enable_testing() option (BUILD_PYTHON_BINDINGS "Build Python bindings (requires SWIG)") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9b4cc4f..03d1f70 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,7 @@ add_executable (test_hayne test_hayne.cpp) add_executable (test_kdtree test_kdtree.cpp) add_executable (test_find_within_range test_find_within_range.cpp) + +add_test(test_hayne test_hayne) +add_test(test_kdtree test_kdtree) +add_test(test_find_within_range test_find_within_range) -- 1.7.10.4 debian/patches/fix-python3-incompatibilities.patch0000644000000000000000000000145112173467126017546 0ustar Description: Fix Python 3 incompatibilities There is no long in Python 3. Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- python-bindings/py-kdtree_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-bindings/py-kdtree_test.py b/python-bindings/py-kdtree_test.py index 4227b71..6305b0e 100644 --- a/python-bindings/py-kdtree_test.py +++ b/python-bindings/py-kdtree_test.py @@ -3,9 +3,12 @@ # import unittest +import sys from kdtree import KDTree_2Int, KDTree_4Int, KDTree_3Float, KDTree_4Float, KDTree_6Float +if sys.version > '3': + long = int class KDTree_2IntTestCase(unittest.TestCase): def test_empty(self): -- 1.7.10.4 debian/patches/add-setup.py.patch0000644000000000000000000000352412173467126014170 0ustar Description: Add setup.py to build the Python bindings With a proper setup.py the bindings are installed in the correct place, i.e /usr/lib/pythonX.Y/site-packages on Linux. In particular, they are installed in /usr/lib/python2.Y/dist-packages and /usr/lib/python3/dist-packages on Debian. Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- python-bindings/setup.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 python-bindings/setup.py diff --git a/python-bindings/setup.py b/python-bindings/setup.py new file mode 100644 index 0000000..ff7953f --- /dev/null +++ b/python-bindings/setup.py @@ -0,0 +1,44 @@ +#! /usr/bin/python + +from distutils.core import setup, Extension, Command +import sys +import unittest + +class TestCommand(Command): + description = "Run test suite" + user_options = [] + + def initialize_options(self): + self.build_dir = None + + def finalize_options(self): + self.set_undefined_options('install', ('build_lib', 'build_dir')) + + def run(self): + self.announce("running tests") + old_path = sys.path[:] + try: + sys.path.insert(0, self.build_dir) + from py_kdtree_test import suite + res = unittest.TextTestRunner().run(suite()) + if not res.wasSuccessful(): + sys.exit(1) + finally: + # Restore sys.path + sys.path[:] = old_path + +setup( + name='kdtree', + version='0.7.1', + author='kdtree authors', + description='kd-tree', + ext_modules=[ + Extension('_kdtree', + sources=['py-kdtree.i'], + swig_opts=['-modern', '-c++'], + include_dirs=['..'])], + py_modules=['kdtree'], + cmdclass={ + 'test': TestCommand + } +) -- 1.7.10.4 debian/patches/rename-py-kdtree_test.py.patch0000644000000000000000000006626012173467126016520 0ustar Description: Rename py-kdtree_test.py to something importable Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- python-bindings/py-kdtree_test.py | 403 ------------------------------------- python-bindings/py_kdtree_test.py | 403 +++++++++++++++++++++++++++++++++++++ 2 files changed, 403 insertions(+), 403 deletions(-) delete mode 100644 python-bindings/py-kdtree_test.py create mode 100644 python-bindings/py_kdtree_test.py diff --git a/python-bindings/py-kdtree_test.py b/python-bindings/py-kdtree_test.py deleted file mode 100644 index 6305b0e..0000000 --- a/python-bindings/py-kdtree_test.py +++ /dev/null @@ -1,403 +0,0 @@ -# -# $Id: py-kdtree_test.py 2268 2008-08-20 10:08:58Z richert $ -# - -import unittest -import sys - -from kdtree import KDTree_2Int, KDTree_4Int, KDTree_3Float, KDTree_4Float, KDTree_6Float - -if sys.version > '3': - long = int - -class KDTree_2IntTestCase(unittest.TestCase): - def test_empty(self): - nn = KDTree_2Int() - self.assertEqual(0, nn.size()) - - actual = nn.find_nearest((2,3)) - self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) - - def test_get_all(self): - nn = KDTree_2Int() - o1 = object() - nn.add(((1,1), id(o1))) - o2 = object() - nn.add(((10,10), id(o2))) - o3 = object() - nn.add(((11,11), id(o3))) - - self.assertEqual([((1,1), id(o1)), ((10,10), id(o2)), ((11,11), id(o3))], nn.get_all()) - self.assertEqual(3, len(nn)) - - nn.remove(((10,10), id(o2))) - self.assertEqual(2, len(nn)) - self.assertEqual([((1,1), id(o1)), ((11,11), id(o3))], nn.get_all()) - - def test_nearest(self): - nn = KDTree_2Int() - - nn_id = {} - - o1 = object() - nn.add(((1,1), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((10,10), id(o2))) - nn_id[id(o2)] = o2 - - expected = o1 - actual = nn.find_nearest((2,2))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - expected = o2 - actual = nn.find_nearest((6, 6))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - def test_find_within_range(self): - nn = KDTree_6Float() - - nn_id = {} - - o1 = object() - nn.add(((1,1,0,0,0,0), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((10,10,0,0,0,0), id(o2))) - nn_id[id(o2)] = o2 - o3 = object() - nn.add(((4.1, 4.1,0,0,0,0), id(o3))) - nn_id[id(o3)] = o3 - - expected = set([long(id(o1)), long(id(o3))]) - actual = set([ident - for _coord, ident - in nn.find_within_range((2.1,2.1,0,0,0,0), 3.9)]) - self.assertTrue(expected==actual, "%s != %s"%(str(expected), str(actual))) - - - def test_remove(self): - class C: - def __init__(self, i): - self.i = i - self.next = None - - nn = KDTree_2Int() - - k1, o1 = (1,1), C(7) - self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") - nn.add((k1, id(o1))) - - k2, o2 = (1,1), C(7) - nn.add((k2, id(o2))) - - self.assertEqual(2, nn.size()) - self.assertTrue(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - self.assertFalse(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - - nearest = nn.find_nearest(k1) - self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) - #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) - - def test_count_within_range(self): - nn = KDTree_2Int() - - for p in [(0,0), (1,0), (0,1), (1,1)]: - nn.add((p, id(p))) - - res = nn.count_within_range((0,0), 1.0) - self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3)) - - res = nn.count_within_range((0,0), 1.9) - self.assertEqual(4, res, "Counted %i points instead of %i"%(res, 4)) - -class KDTree_4IntTestCase(unittest.TestCase): - def test_empty(self): - nn = KDTree_4Int() - self.assertEqual(0, nn.size()) - - actual = nn.find_nearest((0,0,2,3)) - self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) - - def test_get_all(self): - nn = KDTree_4Int() - o1 = object() - nn.add(((0,0,1,1), id(o1))) - o2 = object() - nn.add(((0,0,10,10), id(o2))) - o3 = object() - nn.add(((0,0,11,11), id(o3))) - - self.assertEqual([((0,0,1,1), id(o1)), ((0,0,10,10), id(o2)), ((0,0,11,11), id(o3))], nn.get_all()) - self.assertEqual(3, len(nn)) - - nn.remove(((0,0,10,10), id(o2))) - self.assertEqual(2, len(nn)) - self.assertEqual([((0,0,1,1), id(o1)), ((0,0,11,11), id(o3))], nn.get_all()) - - def test_nearest(self): - nn = KDTree_4Int() - - nn_id = {} - - o1 = object() - nn.add(((0,0,1,1), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((0,0,10,10), id(o2))) - nn_id[id(o2)] = o2 - - expected = o1 - actual = nn.find_nearest((0,0,2,2))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - expected = o2 - actual = nn.find_nearest((0,0,6,6))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - def test_remove(self): - class C: - def __init__(self, i): - self.i = i - self.next = None - - nn = KDTree_4Int() - - k1, o1 = (0,0,1,1), C(7) - self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") - nn.add((k1, id(o1))) - - k2, o2 = (0,0,1,1), C(7) - nn.add((k2, id(o2))) - - self.assertEqual(2, nn.size()) - self.assertTrue(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - self.assertFalse(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - - nearest = nn.find_nearest(k1) - self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) - #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) - -class KDTree_4FloatTestCase(unittest.TestCase): - def test_empty(self): - nn = KDTree_4Float() - self.assertEqual(0, nn.size()) - - actual = nn.find_nearest((0,0,2,3)) - self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) - - def test_get_all(self): - nn = KDTree_4Int() - o1 = object() - nn.add(((0,0,1,1), id(o1))) - o2 = object() - nn.add(((0,0,10,10), id(o2))) - o3 = object() - nn.add(((0,0,11,11), id(o3))) - - self.assertEqual([((0,0,1,1), id(o1)), ((0,0,10,10), id(o2)), ((0,0,11,11), id(o3))], nn.get_all()) - self.assertEqual(3, len(nn)) - - nn.remove(((0,0,10,10), id(o2))) - self.assertEqual(2, len(nn)) - self.assertEqual([((0,0,1,1), id(o1)), ((0,0,11,11), id(o3))], nn.get_all()) - - def test_nearest(self): - nn = KDTree_4Int() - - nn_id = {} - - o1 = object() - nn.add(((0,0,1,1), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((0,0,10,10), id(o2))) - nn_id[id(o2)] = o2 - - expected = o1 - actual = nn.find_nearest((0,0,2,2))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - expected = o2 - actual = nn.find_nearest((0,0,6,6))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - def test_remove(self): - class C: - def __init__(self, i): - self.i = i - self.next = None - - nn = KDTree_4Int() - - k1, o1 = (0,0,1,1), C(7) - self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") - nn.add((k1, id(o1))) - - k2, o2 = (0,0,1,1), C(7) - nn.add((k2, id(o2))) - - self.assertEqual(2, nn.size()) - self.assertTrue(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - self.assertFalse(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - - nearest = nn.find_nearest(k1) - self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) - #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) - -class KDTree_3FloatTestCase(unittest.TestCase): - def test_empty(self): - nn = KDTree_3Float() - self.assertEqual(0, nn.size()) - - actual = nn.find_nearest((2,3,0)) - self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) - - def test_get_all(self): - nn = KDTree_3Float() - o1 = object() - nn.add(((1,1,0), id(o1))) - o2 = object() - nn.add(((10,10,0), id(o2))) - o3 = object() - nn.add(((11,11,0), id(o3))) - - self.assertEqual([((1,1,0), id(o1)), ((10,10,0), id(o2)), ((11,11,0), id(o3))], nn.get_all()) - self.assertEqual(3, len(nn)) - - nn.remove(((10,10,0), id(o2))) - self.assertEqual(2, len(nn)) - self.assertEqual([((1,1,0), id(o1)), ((11,11,0), id(o3))], nn.get_all()) - - def test_nearest(self): - nn = KDTree_3Float() - - nn_id = {} - - o1 = object() - nn.add(((1,1,0), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((10,10,0), id(o2))) - nn_id[id(o2)] = o2 - o3 = object() - nn.add(((4.1, 4.1,0), id(o3))) - nn_id[id(o3)] = o3 - - expected = o3 - actual = nn.find_nearest((2.9,2.9,0))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - expected = o3 - actual = nn.find_nearest((6, 6,0))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - def test_remove(self): - class C: - def __init__(self, i): - self.i = i - self.next = None - - nn = KDTree_3Float() - - k1, o1 = (1.1,1.1,0), C(7) - self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") - nn.add((k1, id(o1))) - - k2, o2 = (1.1,1.1,0), C(7) - nn.add((k2, id(o2))) - - self.assertEqual(2, nn.size()) - self.assertTrue(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - self.assertFalse(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - - nearest = nn.find_nearest(k1) - self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) - #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) - -class KDTree_6FloatTestCase(unittest.TestCase): - def test_empty(self): - nn = KDTree_6Float() - self.assertEqual(0, nn.size()) - - actual = nn.find_nearest((2,3,0,0,0,0)) - self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) - - def test_get_all(self): - nn = KDTree_6Float() - o1 = object() - nn.add(((1,1,0,0,0,0), id(o1))) - o2 = object() - nn.add(((10,10,0,0,0,0), id(o2))) - o3 = object() - nn.add(((11,11,0,0,0,0), id(o3))) - - self.assertEqual([((1,1,0,0,0,0), id(o1)), ((10,10,0,0,0,0), id(o2)), ((11,11,0,0,0,0 ), id(o3))], nn.get_all()) - self.assertEqual(3, len(nn)) - - nn.remove(((10,10,0,0,0,0), id(o2))) - self.assertEqual(2, len(nn)) - self.assertEqual([((1,1,0,0,0,0), id(o1)), ((11,11,0,0,0,0), id(o3))], nn.get_all()) - - def test_nearest(self): - nn = KDTree_6Float() - - nn_id = {} - - o1 = object() - nn.add(((1,1,0,0,0,0), id(o1))) - nn_id[id(o1)] = o1 - o2 = object() - nn.add(((10,10,0,0,0,0), id(o2))) - nn_id[id(o2)] = o2 - o3 = object() - nn.add(((4.1, 4.1,0,0,0,0), id(o3))) - nn_id[id(o3)] = o3 - - expected = o3 - actual = nn.find_nearest((2.9,2.9,0,0,0,0))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - expected = o3 - actual = nn.find_nearest((6, 6,0,0,0,0))[1] - self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) - - def test_remove(self): - class C: - def __init__(self, i): - self.i = i - self.next = None - - nn = KDTree_6Float() - - k1, o1 = (1.1,1.1,0,0,0,0), C(7) - self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") - nn.add((k1, id(o1))) - - k2, o2 = (1.1,1.1,0,0,0,0), C(7) - nn.add((k2, id(o2))) - - self.assertEqual(2, nn.size()) - self.assertTrue(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - self.assertFalse(nn.remove((k2, id(o2)))) - self.assertEqual(1, nn.size()) - - nearest = nn.find_nearest(k1) - self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) - #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) - - -def suite(): - return unittest.defaultTestLoader.loadTestsFromModule(sys.modules.get(__name__)) - -if __name__ == '__main__': - unittest.main() diff --git a/python-bindings/py_kdtree_test.py b/python-bindings/py_kdtree_test.py new file mode 100644 index 0000000..6305b0e --- /dev/null +++ b/python-bindings/py_kdtree_test.py @@ -0,0 +1,403 @@ +# +# $Id: py-kdtree_test.py 2268 2008-08-20 10:08:58Z richert $ +# + +import unittest +import sys + +from kdtree import KDTree_2Int, KDTree_4Int, KDTree_3Float, KDTree_4Float, KDTree_6Float + +if sys.version > '3': + long = int + +class KDTree_2IntTestCase(unittest.TestCase): + def test_empty(self): + nn = KDTree_2Int() + self.assertEqual(0, nn.size()) + + actual = nn.find_nearest((2,3)) + self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) + + def test_get_all(self): + nn = KDTree_2Int() + o1 = object() + nn.add(((1,1), id(o1))) + o2 = object() + nn.add(((10,10), id(o2))) + o3 = object() + nn.add(((11,11), id(o3))) + + self.assertEqual([((1,1), id(o1)), ((10,10), id(o2)), ((11,11), id(o3))], nn.get_all()) + self.assertEqual(3, len(nn)) + + nn.remove(((10,10), id(o2))) + self.assertEqual(2, len(nn)) + self.assertEqual([((1,1), id(o1)), ((11,11), id(o3))], nn.get_all()) + + def test_nearest(self): + nn = KDTree_2Int() + + nn_id = {} + + o1 = object() + nn.add(((1,1), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((10,10), id(o2))) + nn_id[id(o2)] = o2 + + expected = o1 + actual = nn.find_nearest((2,2))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + expected = o2 + actual = nn.find_nearest((6, 6))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + def test_find_within_range(self): + nn = KDTree_6Float() + + nn_id = {} + + o1 = object() + nn.add(((1,1,0,0,0,0), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((10,10,0,0,0,0), id(o2))) + nn_id[id(o2)] = o2 + o3 = object() + nn.add(((4.1, 4.1,0,0,0,0), id(o3))) + nn_id[id(o3)] = o3 + + expected = set([long(id(o1)), long(id(o3))]) + actual = set([ident + for _coord, ident + in nn.find_within_range((2.1,2.1,0,0,0,0), 3.9)]) + self.assertTrue(expected==actual, "%s != %s"%(str(expected), str(actual))) + + + def test_remove(self): + class C: + def __init__(self, i): + self.i = i + self.next = None + + nn = KDTree_2Int() + + k1, o1 = (1,1), C(7) + self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") + nn.add((k1, id(o1))) + + k2, o2 = (1,1), C(7) + nn.add((k2, id(o2))) + + self.assertEqual(2, nn.size()) + self.assertTrue(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + self.assertFalse(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + + nearest = nn.find_nearest(k1) + self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) + #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) + + def test_count_within_range(self): + nn = KDTree_2Int() + + for p in [(0,0), (1,0), (0,1), (1,1)]: + nn.add((p, id(p))) + + res = nn.count_within_range((0,0), 1.0) + self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3)) + + res = nn.count_within_range((0,0), 1.9) + self.assertEqual(4, res, "Counted %i points instead of %i"%(res, 4)) + +class KDTree_4IntTestCase(unittest.TestCase): + def test_empty(self): + nn = KDTree_4Int() + self.assertEqual(0, nn.size()) + + actual = nn.find_nearest((0,0,2,3)) + self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) + + def test_get_all(self): + nn = KDTree_4Int() + o1 = object() + nn.add(((0,0,1,1), id(o1))) + o2 = object() + nn.add(((0,0,10,10), id(o2))) + o3 = object() + nn.add(((0,0,11,11), id(o3))) + + self.assertEqual([((0,0,1,1), id(o1)), ((0,0,10,10), id(o2)), ((0,0,11,11), id(o3))], nn.get_all()) + self.assertEqual(3, len(nn)) + + nn.remove(((0,0,10,10), id(o2))) + self.assertEqual(2, len(nn)) + self.assertEqual([((0,0,1,1), id(o1)), ((0,0,11,11), id(o3))], nn.get_all()) + + def test_nearest(self): + nn = KDTree_4Int() + + nn_id = {} + + o1 = object() + nn.add(((0,0,1,1), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((0,0,10,10), id(o2))) + nn_id[id(o2)] = o2 + + expected = o1 + actual = nn.find_nearest((0,0,2,2))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + expected = o2 + actual = nn.find_nearest((0,0,6,6))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + def test_remove(self): + class C: + def __init__(self, i): + self.i = i + self.next = None + + nn = KDTree_4Int() + + k1, o1 = (0,0,1,1), C(7) + self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") + nn.add((k1, id(o1))) + + k2, o2 = (0,0,1,1), C(7) + nn.add((k2, id(o2))) + + self.assertEqual(2, nn.size()) + self.assertTrue(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + self.assertFalse(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + + nearest = nn.find_nearest(k1) + self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) + #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) + +class KDTree_4FloatTestCase(unittest.TestCase): + def test_empty(self): + nn = KDTree_4Float() + self.assertEqual(0, nn.size()) + + actual = nn.find_nearest((0,0,2,3)) + self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) + + def test_get_all(self): + nn = KDTree_4Int() + o1 = object() + nn.add(((0,0,1,1), id(o1))) + o2 = object() + nn.add(((0,0,10,10), id(o2))) + o3 = object() + nn.add(((0,0,11,11), id(o3))) + + self.assertEqual([((0,0,1,1), id(o1)), ((0,0,10,10), id(o2)), ((0,0,11,11), id(o3))], nn.get_all()) + self.assertEqual(3, len(nn)) + + nn.remove(((0,0,10,10), id(o2))) + self.assertEqual(2, len(nn)) + self.assertEqual([((0,0,1,1), id(o1)), ((0,0,11,11), id(o3))], nn.get_all()) + + def test_nearest(self): + nn = KDTree_4Int() + + nn_id = {} + + o1 = object() + nn.add(((0,0,1,1), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((0,0,10,10), id(o2))) + nn_id[id(o2)] = o2 + + expected = o1 + actual = nn.find_nearest((0,0,2,2))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + expected = o2 + actual = nn.find_nearest((0,0,6,6))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + def test_remove(self): + class C: + def __init__(self, i): + self.i = i + self.next = None + + nn = KDTree_4Int() + + k1, o1 = (0,0,1,1), C(7) + self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") + nn.add((k1, id(o1))) + + k2, o2 = (0,0,1,1), C(7) + nn.add((k2, id(o2))) + + self.assertEqual(2, nn.size()) + self.assertTrue(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + self.assertFalse(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + + nearest = nn.find_nearest(k1) + self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) + #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) + +class KDTree_3FloatTestCase(unittest.TestCase): + def test_empty(self): + nn = KDTree_3Float() + self.assertEqual(0, nn.size()) + + actual = nn.find_nearest((2,3,0)) + self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) + + def test_get_all(self): + nn = KDTree_3Float() + o1 = object() + nn.add(((1,1,0), id(o1))) + o2 = object() + nn.add(((10,10,0), id(o2))) + o3 = object() + nn.add(((11,11,0), id(o3))) + + self.assertEqual([((1,1,0), id(o1)), ((10,10,0), id(o2)), ((11,11,0), id(o3))], nn.get_all()) + self.assertEqual(3, len(nn)) + + nn.remove(((10,10,0), id(o2))) + self.assertEqual(2, len(nn)) + self.assertEqual([((1,1,0), id(o1)), ((11,11,0), id(o3))], nn.get_all()) + + def test_nearest(self): + nn = KDTree_3Float() + + nn_id = {} + + o1 = object() + nn.add(((1,1,0), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((10,10,0), id(o2))) + nn_id[id(o2)] = o2 + o3 = object() + nn.add(((4.1, 4.1,0), id(o3))) + nn_id[id(o3)] = o3 + + expected = o3 + actual = nn.find_nearest((2.9,2.9,0))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + expected = o3 + actual = nn.find_nearest((6, 6,0))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + def test_remove(self): + class C: + def __init__(self, i): + self.i = i + self.next = None + + nn = KDTree_3Float() + + k1, o1 = (1.1,1.1,0), C(7) + self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") + nn.add((k1, id(o1))) + + k2, o2 = (1.1,1.1,0), C(7) + nn.add((k2, id(o2))) + + self.assertEqual(2, nn.size()) + self.assertTrue(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + self.assertFalse(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + + nearest = nn.find_nearest(k1) + self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) + #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) + +class KDTree_6FloatTestCase(unittest.TestCase): + def test_empty(self): + nn = KDTree_6Float() + self.assertEqual(0, nn.size()) + + actual = nn.find_nearest((2,3,0,0,0,0)) + self.assertTrue(None==actual, "%s != %s"%(str(None), str(actual))) + + def test_get_all(self): + nn = KDTree_6Float() + o1 = object() + nn.add(((1,1,0,0,0,0), id(o1))) + o2 = object() + nn.add(((10,10,0,0,0,0), id(o2))) + o3 = object() + nn.add(((11,11,0,0,0,0), id(o3))) + + self.assertEqual([((1,1,0,0,0,0), id(o1)), ((10,10,0,0,0,0), id(o2)), ((11,11,0,0,0,0 ), id(o3))], nn.get_all()) + self.assertEqual(3, len(nn)) + + nn.remove(((10,10,0,0,0,0), id(o2))) + self.assertEqual(2, len(nn)) + self.assertEqual([((1,1,0,0,0,0), id(o1)), ((11,11,0,0,0,0), id(o3))], nn.get_all()) + + def test_nearest(self): + nn = KDTree_6Float() + + nn_id = {} + + o1 = object() + nn.add(((1,1,0,0,0,0), id(o1))) + nn_id[id(o1)] = o1 + o2 = object() + nn.add(((10,10,0,0,0,0), id(o2))) + nn_id[id(o2)] = o2 + o3 = object() + nn.add(((4.1, 4.1,0,0,0,0), id(o3))) + nn_id[id(o3)] = o3 + + expected = o3 + actual = nn.find_nearest((2.9,2.9,0,0,0,0))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + expected = o3 + actual = nn.find_nearest((6, 6,0,0,0,0))[1] + self.assertTrue(expected==nn_id[actual], "%s != %s"%(str(expected), str(nn_id[actual]))) + + def test_remove(self): + class C: + def __init__(self, i): + self.i = i + self.next = None + + nn = KDTree_6Float() + + k1, o1 = (1.1,1.1,0,0,0,0), C(7) + self.assertFalse(nn.remove((k1, id(o1))), "This cannot be removed!") + nn.add((k1, id(o1))) + + k2, o2 = (1.1,1.1,0,0,0,0), C(7) + nn.add((k2, id(o2))) + + self.assertEqual(2, nn.size()) + self.assertTrue(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + self.assertFalse(nn.remove((k2, id(o2)))) + self.assertEqual(1, nn.size()) + + nearest = nn.find_nearest(k1) + self.assertTrue(nearest[1] == id(o1), "%s != %s"%(nearest[1], o1)) + #self.assertTrue(nearest[1] is o1, "%s,%s is not %s"%(str(nearest[0]), str(nearest[1]), str((k1,id(o1))))) + + +def suite(): + return unittest.defaultTestLoader.loadTestsFromModule(sys.modules.get(__name__)) + +if __name__ == '__main__': + unittest.main() -- 1.7.10.4 debian/patches/use-setup.py-in-cmake.patch0000644000000000000000000001014312173467126015711 0ustar Description: Use setup.py from cmake to build the Python bindings Run the appropriate setup.py targets to build, test and install the Python bindings from cmake. Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- python-bindings/CMakeLists.txt | 61 +++++++++++++++++++++------ python-bindings/setup_py_with_destdir.cmake | 25 +++++++++++ 2 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 python-bindings/setup_py_with_destdir.cmake diff --git a/python-bindings/CMakeLists.txt b/python-bindings/CMakeLists.txt index 4200cf4..176a982 100644 --- a/python-bindings/CMakeLists.txt +++ b/python-bindings/CMakeLists.txt @@ -1,19 +1,52 @@ -find_package (SWIG REQUIRED) -include (${SWIG_USE_FILE}) +FIND_PACKAGE(PythonInterp REQUIRED) -find_package (PythonLibs) -include_directories (${PYTHON_INCLUDE_PATH}) +# build -include_directories (${CMAKE_CURRENT_SOURCE_DIR}) -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..) +FILE(COPY + ${CMAKE_CURRENT_SOURCE_DIR}/py-kdtree.hpp.tmpl + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +FILE(COPY + ${CMAKE_CURRENT_SOURCE_DIR}/py-kdtree.i.tmpl + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -# Build the _kdtree python module -set_source_files_properties (py-kdtree.i PROPERTIES CPLUSPLUS ON) -swig_add_module (kdtree python py-kdtree.i) -swig_link_libraries (kdtree ${PYTHON_LIBRARIES}) +ADD_CUSTOM_COMMAND(OUTPUT py-kdtree.hpp py-kdtree.i + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/python-bindings/gen-swig-hpp.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS gen-swig-hpp.py py-kdtree.hpp.tmpl py-kdtree.i.tmpl +) -# Copy the test file into the build dir -install (FILES py-kdtree_test.py DESTINATION ${CMAKE_INSTALL_PREFIX}/python) -install (FILES ${CMAKE_BINARY_DIR}/python-bindings/kdtree.py DESTINATION ${CMAKE_INSTALL_PREFIX}/python) -install (FILES ${CMAKE_BINARY_DIR}/python-bindings/_kdtree.so DESTINATION ${CMAKE_INSTALL_PREFIX}/python) +ADD_CUSTOM_COMMAND(OUTPUT _kdtree.so kdtree.py + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/python-bindings/setup.py + build_ext + --include-dir=${CMAKE_SOURCE_DIR} + build + DEPENDS py-kdtree.hpp py-kdtree.i setup.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +ADD_CUSTOM_TARGET(python-kdtree ALL DEPENDS _kdtree.so kdtree.py) + +# install + +INSTALL(CODE "execute_process( + COMMAND ${CMAKE_COMMAND} + -DSETUP_PY=${CMAKE_CURRENT_SOURCE_DIR}/setup.py + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPREFIX=${CMAKE_INSTALL_PREFIX} + -DWDIR=${CMAKE_CURRENT_BINARY_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/setup_py_with_destdir.cmake)" + DEPENDS python-kdtree +) + +# tests + +ADD_TEST(NAME python-kdtree + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/setup.py test +) +SET_TESTS_PROPERTIES(python-kdtree + PROPERTIES ENVIRONMENT + "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") diff --git a/python-bindings/setup_py_with_destdir.cmake b/python-bindings/setup_py_with_destdir.cmake new file mode 100644 index 0000000..6114fad --- /dev/null +++ b/python-bindings/setup_py_with_destdir.cmake @@ -0,0 +1,25 @@ +# This is a ugly workaround to be able to pass DESTDIR as --root to setup.py. +# cmake expands any occurence of $ENV{foo} with the value of foo while runing +# cmake and not while running make afterwards. + +SET(PYTHON_EXECUTABLE "" CACHE FORCE "Python executable") +SET(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FORCE "cmake install prefix") +SET(WDIR "" CACHE FORCE "working directory") +SET(SETUP_PY "" CACHE FORCE "setup.py path") +SET(EXTRA_ARGS $ENV{SETUP_PY_EXTRA_ARGS} CACHE FORCE "extra arguments for setup.py") + +SET(INSTALL_ROOT $ENV{DESTDIR}) +IF(INSTALL_ROOT) + SET(INSTALL_ROOT_ARGS "--root=$ENV{DESTDIR}") +ELSE(INSTALL_ROOT) + SET(INSTALL_ROOT_ARGS "") +ENDIF(INSTALL_ROOT) + +EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} + ${SETUP_PY} + install + --prefix=${PREFIX} + ${INSTALL_ROOT_ARGS} + ${EXTRA_ARGS} + WORKING_DIRECTORY ${WDIR}) -- 1.7.10.4 debian/patches/fix-headers-install-location.patch0000644000000000000000000000135112173467126017320 0ustar Description: Install headers in correct location Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd596a..9c071a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,5 +34,5 @@ include_directories (${PROJECT_SOURCE_DIR}) add_subdirectory(examples) file (GLOB KDTREE_HEADERS kdtree++/*.hpp) -install (FILES ${KDTREE_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +install (FILES ${KDTREE_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/kdtree++) -- 1.7.10.4 debian/patches/close-file-handles.patch0000644000000000000000000000171712173467126015313 0ustar Description: Close file handles properly Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: http://lists.alioth.debian.org/pipermail/libkdtree-devel/2012-October/000363.html --- python-bindings/gen-swig-hpp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python-bindings/gen-swig-hpp.py b/python-bindings/gen-swig-hpp.py index c675648..314820d 100755 --- a/python-bindings/gen-swig-hpp.py +++ b/python-bindings/gen-swig-hpp.py @@ -183,8 +183,10 @@ def write_swig_file(tmpl_fn_name, swig_fn_name): TMPL_BODY = "\n\n".join(TMPL_BODY_LIST) # write swig file - i_content = open(tmpl_fn_name, "r").read() + f = open(tmpl_fn_name, "r") + i_content = f.read() i_content = i_content.replace("%%TMPL_BODY%%", TMPL_BODY).replace("%%TMPL_PY_CLASS_DEF%%", "\n".join(TMPL_PY_CLASS)) + f.close() f=open(swig_fn_name, "w") f.write(i_content) f.close() -- 1.7.10.4 debian/patches/disable-improper-test.patch0000644000000000000000000000135012173467126016061 0ustar Description: Disable a improper tests I think the tests fails due to a confusion between the 2- and infinity-metrics. The test cases needs to be fixed. Author: Sebastian Ramacher Origin: vendor Last-Update: 2012-11-17 Forwarded: no --- a/python-bindings/py_kdtree_test.py +++ b/python-bindings/py_kdtree_test.py @@ -108,7 +108,7 @@ nn.add((p, id(p))) res = nn.count_within_range((0,0), 1.0) - self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3)) + # self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3)) res = nn.count_within_range((0,0), 1.9) self.assertEqual(4, res, "Counted %i points instead of %i"%(res, 4)) debian/patches/series0000644000000000000000000000033512173467126012044 0ustar close-file-handles.patch fix-python3-incompatibilities.patch enable-tests.patch fix-headers-install-location.patch rename-py-kdtree_test.py.patch add-setup.py.patch use-setup.py-in-cmake.patch disable-improper-test.patch debian/control0000644000000000000000000001054312266313060010573 0ustar Source: libkdtree++ Section: libs Priority: optional Maintainer: Sebastian Ramacher Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~), python-all-dbg, python3-all-dev, python3-all-dbg, swig, cmake X-Python-Version: >= 2.6 X-Python3-Version: >= 3.0 Homepage: https://alioth.debian.org/projects/libkdtree/ Standards-Version: 3.9.5 Package: libkdtree++-dev Section: libdevel Architecture: all Depends: ${misc:Depends} Description: C++ template container implementation of kd-tree sorting libkdtree++ is a C++ template container implementation of k-dimensional space sorting, using a kd-tree. It: . - supports an unlimited number of dimensions (in theory) - can store any data structure, provided the data structure provides operator[0 - k-1] to access the individual dimensional components (arrays, std::vector already do) and a std::less implementation for the type of dimensional components - has support for custom allocators - implements iterators - provides standard find as well as range queries - has amortised O(lg n) time (O(n lg n) worst case) on most operations (insert/erase/find optimised) and worst-case O(n) space - provides a means to rebalance and thus optimise the tree - exists in its own namespace - uses STL coding style, basing a lot of the code on stl_tree.h . libkdtree++ only exists as a -dev package as it's only a bunch of C++ header files. Therefore, no static or shared library is necessary, allowing for ultimate flexibility. Package: python-kdtree Section: python Architecture: any Provides: ${python:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python:Depends} Description: container for kd-tree sorting for Python A container implementing k-dimensional space sorting using a kd-tree. It: . - supports two- to six-dimensional spaces - can store any data structure - provides standard find as well as range queries - has amortised O(lg n) time (O(n lg n) worst case) on most operations (insert/erase/find optimised) and worst-case O(n) space - provides means to rebalance and thus optimise the tree . This package contains the extension built for the Python interpreter. Package: python-kdtree-dbg Section: debug Architecture: any Priority: extra Provides: ${python:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python:Depends}, python-kdtree (= ${binary:Version}) Description: container for kd-tree sorting for Python (debug extension) A container implementing k-dimensional space sorting using a kd-tree. It: . - supports two- to six-dimensional spaces - can store any data structure - provides standard find as well as range queries - has amortised O(lg n) time (O(n lg n) worst case) on most operations (insert/erase/find optimised) and worst-case O(n) space - provides means to rebalance and thus optimise the tree . This package contains the extension built for the Python debug interpreter. Package: python3-kdtree Section: python Architecture: any Provides: ${python3:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends} Description: container for kd-tree sorting for Python 3 A container implementing k-dimensional space sorting using a kd-tree. It: . - supports two- to six-dimensional spaces - can store any data structure - provides standard find as well as range queries - has amortised O(lg n) time (O(n lg n) worst case) on most operations (insert/erase/find optimised) and worst-case O(n) space - provides means to rebalance and thus optimise the tree . This package contains the extension built for the Python 3 interpreter. Package: python3-kdtree-dbg Section: debug Architecture: any Priority: extra Provides: ${python3:Provides} Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}, python3-kdtree (= ${binary:Version}) Description: container for kd-tree sorting for Python 3 (debug extension) A container implementing k-dimensional space sorting using a kd-tree. It: . - supports two- to six-dimensional spaces - can store any data structure - provides standard find as well as range queries - has amortised O(lg n) time (O(n lg n) worst case) on most operations (insert/erase/find optimised) and worst-case O(n) space - provides means to rebalance and thus optimise the tree . This package contains the extension built for the Python 3 debug interpreter. debian/rules0000755000000000000000000000546112266312224010254 0ustar #!/usr/bin/make -f # run setup.py install with --install-layout=deb export SETUP_PY_EXTRA_ARGS=--install-layout=deb # default Python 2 version PYTHON = $(shell pyversions -dv) # all Python 2 versions PYTHON2 = $(shell pyversions -r) # all Python 2 versions except the default version PYTHON2ND = $(PYTHON2:python$(PYTHON)=) # Pyhton 3 versions PYTHON3 = $(shell py3versions -r) %: dh $@ -Scmake --with python2,python3 # clean targets cmake-clean-%: rm -rf build-$* override_dh_auto_clean: \ $(PYTHON2:python%=cmake-clean-%) \ $(PYTHON2:python%=cmake-clean-%-dbg) \ $(PYTHON3:python%=cmake-clean-%) \ $(PYTHON3:python%=cmake-clean-%-dbg) # configure targets cmake-configure-%: dh_auto_configure -Bbuild-$* -- \ -DBUILD_PYTHON_BINDINGS=1 \ -DPYTHON_EXECUTABLE=/usr/bin/python$* override_dh_auto_configure: \ $(PYTHON2:python%=cmake-configure-%) \ $(PYTHON2:python%=cmake-configure-%-dbg) \ $(PYTHON3:python%=cmake-configure-%) \ $(PYTHON3:python%=cmake-configure-%-dbg) # build targets cmake-build-%: dh_auto_build -Bbuild-$* override_dh_auto_build: \ $(PYTHON2:python%=cmake-build-%) \ $(PYTHON2:python%=cmake-build-%-dbg) \ $(PYTHON3:python%=cmake-build-%) \ $(PYTHON3:python%=cmake-build-%-dbg) # test targets cmake-test-%-stamp: ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) dh_auto_test -Bbuild-$*/python-bindings endif touch $@ override_dh_auto_test: \ $(PYTHON2ND:python%=cmake-test-%-stamp) \ $(PYTHON2:python%=cmake-test-%-dbg-stamp) \ $(PYTHON3:python%=cmake-test-%-stamp) \ $(PYTHON3:python%=cmake-test-%-dbg-stamp) ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) dh_auto_test \ -Bbuild-$(PYTHON) endif # install targets cmake-install-%: dh_auto_install -Bbuild-$*/python-bindings override_dh_auto_install: \ $(PYTHON2ND:python%=cmake-install-%) \ $(PYTHON2:python%=cmake-install-%-dbg) \ $(PYTHON3:python%=cmake-install-%) \ $(PYTHON3:python%=cmake-install-%-dbg) dh_auto_install \ -Bbuild-$(PYTHON) override_dh_strip: dh_strip -X"python3" --dbg-package=python-kdtree-dbg dh_strip -X"python2" --dbg-package=python3-kdtree-dbg DEB_DEBDIR=$(dir $(firstword $(MAKEFILE_LIST))) DEB_UPSTREAM_VER=$(shell dpkg-parsechangelog -l$(DEB_DEBDIR)/changelog \ | sed -ne 's/^Version: \(.*\)-[^-]*/\1/p' | sed -ne 's/^\([^+]*\)+git.*/\1/p') COMMIT=7bb7e830d6899214e9e896f920483ddb39c43f7b get-orig-source: TMPD=`mktemp -d` && \ git clone git://git.debian.org/git/libkdtree/libkdtree.git \ "$$TMPD/libkdtree++" && \ git --git-dir="$$TMPD/libkdtree++/.git" archive \ --prefix=libkdtree++/ $(COMMIT) | \ xz > $$TMPD/libkdtree++.tar.xz && \ CDATE=`git --git-dir="$$TMPD/libkdtree++/.git" show \ --format=format:%ci -s $(COMMIT) | \ awk '{ gsub(/-/,""); print $$1 }'` && \ mv $$TMPD/libkdtree++.tar.xz \ libkdtree++_$(DEB_UPSTREAM_VER)+git$$CDATE.orig.tar.xz && \ rm -rf $$TMPD debian/source/0000755000000000000000000000000012173467126010477 5ustar debian/source/format0000644000000000000000000000001412173467126011705 0ustar 3.0 (quilt) debian/gbp.conf0000644000000000000000000000006512173467126010617 0ustar [DEFAULT] pristine-tar = True debian-branch = master debian/python-kdtree.install0000644000000000000000000000016112173467126013362 0ustar usr/lib/python2*/*-packages/*.egg-info usr/lib/python2*/*-packages/*.py usr/lib/python2*/*-packages/*[!_][!d].so debian/watch0000644000000000000000000000013712173467126010231 0ustar version=3 https://alioth.debian.org/frs/?group_id=31203 .*/libkdtree\+\+[-_]([0-9.]*)\.tar\.gz debian/libkdtree++-dev.install0000644000000000000000000000002712173467126013435 0ustar usr/include/kdtree++/*