From f420d6343505eaaaffbd147e13fe9d0fe2da3b86 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 20 Nov 2021 12:27:49 +0100 Subject: [PATCH] Add python-rtree --- .../0001-fix-mingw-finder.patch | 24 +++++++++++ mingw-w64-python-rtree/PKGBUILD | 41 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 mingw-w64-python-rtree/0001-fix-mingw-finder.patch create mode 100644 mingw-w64-python-rtree/PKGBUILD diff --git a/mingw-w64-python-rtree/0001-fix-mingw-finder.patch b/mingw-w64-python-rtree/0001-fix-mingw-finder.patch new file mode 100644 index 0000000000..4915899a2c --- /dev/null +++ b/mingw-w64-python-rtree/0001-fix-mingw-finder.patch @@ -0,0 +1,24 @@ +--- rtree-0.9.7/rtree/finder.py.orig 2021-11-20 12:23:16.300000000 +0100 ++++ rtree-0.9.7/rtree/finder.py 2021-11-20 12:23:42.113496900 +0100 +@@ -8,6 +8,7 @@ + import sys + import ctypes + import platform ++import sysconfig + from ctypes.util import find_library + + # the current working directory of this file +@@ -33,6 +34,13 @@ + Loaded shared library + """ + if os.name == 'nt': ++ if sysconfig.get_platform().startswith("mingw"): ++ lib_name = 'libspatialindex_c' ++ path = find_library(lib_name) ++ if path is None: ++ raise OSError("could not find or load {}".format(lib_name)) ++ return ctypes.cdll.LoadLibrary(path) ++ + # check the platform architecture + if '64' in platform.architecture()[0]: + arch = '64' diff --git a/mingw-w64-python-rtree/PKGBUILD b/mingw-w64-python-rtree/PKGBUILD new file mode 100644 index 0000000000..f7b62e263f --- /dev/null +++ b/mingw-w64-python-rtree/PKGBUILD @@ -0,0 +1,41 @@ +_realname=rtree +pkgbase=mingw-w64-python-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}") +pkgver=0.9.7 +pkgrel=1 +pkgdesc="Rtree: spatial index for Python GIS (mingw-w64)" +arch=('any') +url='https://github.com/Toblerity/rtree' +license=('LGPL') +depends=("${MINGW_PACKAGE_PREFIX}-python" + "${MINGW_PACKAGE_PREFIX}-spatialindex") +makedepends=("${MINGW_PACKAGE_PREFIX}-python" + "${MINGW_PACKAGE_PREFIX}-python-wheel" + "${MINGW_PACKAGE_PREFIX}-python-setuptools") +source=("${_realname}-${pkgver}.tar.gz::https://github.com/Toblerity/rtree/archive/refs/tags/${pkgver}.tar.gz" + "0001-fix-mingw-finder.patch") +sha256sums=('920a3dc3654ee7060b6d99daa2dc51f28a2878333a2ade7916040652df9fa65a' + '3a51bacc22c95e062f26924b3461c4aa892e1873737cb0973288aaf60529cc64') + +prepare() { + cd "${srcdir}/${_realname}-${pkgver}" + + patch -Np1 -i "${srcdir}"/0001-fix-mingw-finder.patch + + cd - + cp -r "${_realname}-${pkgver}" "python-build-${CARCH}" +} + +build() { + cd "${srcdir}/python-build-${CARCH}" + ${MINGW_PREFIX}/bin/python setup.py build +} + +package() { + cd "${srcdir}/python-build-${CARCH}" + MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ + ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \ + --root="${pkgdir}" --optimize=1 --skip-build + + install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt" +}