diff options
author | Danilo J. S. Bellini | 2023-07-17 05:05:30 -0300 |
---|---|---|
committer | Danilo J. S. Bellini | 2023-07-17 05:05:30 -0300 |
commit | c9e095acffe1a2a18836db2f40832418eede7ac1 (patch) | |
tree | 1c05c0a597c5728b8490f1df01ec977494d54aa8 | |
parent | 6273a5e1cfb2eeee86939026bd84e781c4c30211 (diff) | |
download | aur-c9e095acffe1a2a18836db2f40832418eede7ac1.tar.gz |
v0.1_1.5.1-1
-rw-r--r-- | .SRCINFO | 23 | ||||
-rw-r--r-- | PKGBUILD | 96 | ||||
-rwxr-xr-x | setup.py | 39 |
3 files changed, 146 insertions, 12 deletions
@@ -1,15 +1,28 @@ pkgbase = python-kealib pkgdesc = Python library to access parts of kealib not exposed by GDAL - pkgver = 0.1_1.4.14 + pkgver = 0.1_1.5.1 pkgrel = 2 url = http://kealib.org arch = x86_64 license = MIT + makedepends = cmake makedepends = python-setuptools - depends = kealib=1.4.14 - depends = python + depends = kealib=1.5.1 + depends = pybind11 + depends = python-numpy + depends = python-awkward<2 options = !emptydirs - source = https://github.com/ubarsc/kealib/releases/download/kealib-1.4.14/kealib-1.4.14.tar.gz - sha256sums = da5d4a540b34afb61665cb7b6bf284825b51464eaf2a23ccca16955e2712cab2 + source = https://github.com/ubarsc/kealib/releases/download/kealib-1.5.1/kealib-1.5.1.tar.gz + source = https://raw.githubusercontent.com/scikit-hep/awkward/v1.10.2/src/awkward/_v2/cpp-headers/awkward//LayoutBuilder.h + source = https://raw.githubusercontent.com/scikit-hep/awkward/v1.10.2/src/awkward/_v2/cpp-headers/awkward//BuilderOptions.h + source = https://raw.githubusercontent.com/scikit-hep/awkward/v1.10.2/src/awkward/_v2/cpp-headers/awkward//GrowableBuffer.h + source = https://raw.githubusercontent.com/scikit-hep/awkward/v1.10.2/src/awkward/_v2/cpp-headers/awkward//utils.h + source = setup.py + sha256sums = 06cd547b1e40394b9539beaf6982bd249e8ee93d6150295e9cd9161d00829657 + sha256sums = 945b19124fadc60c99c60fb263d75ef31e9c4dda6980a5fe96353c3f20d9b330 + sha256sums = a78fc19e9cc9d4096b377e1e99f33fd908b25c3f2cf57dd889893f8042ddb883 + sha256sums = 8112164e16f7de7d8f6da3335f2f62c0f629d606ebb7326b2a499b576f85d579 + sha256sums = eb5957ca6d56eeab8601940b92d018fce3906c50958a85622faad66e0d17a4b6 + sha256sums = SKIP pkgname = python-kealib @@ -2,26 +2,108 @@ # Contributor: dobedobedo <dobe0331 at gmail dot com> _pkgname='kealib' pkgname=("python-$_pkgname") -_kea=1.4.14 +_kea=1.5.1 pkgver=0.1_$_kea pkgrel=2 pkgdesc="Python library to access parts of kealib not exposed by GDAL" arch=('x86_64') url='http://kealib.org' license=('MIT') -makedepends=('python-setuptools') -depends=("kealib=$_kea" 'python') +makedepends=('cmake' 'python-setuptools') +depends=("kealib=$_kea" 'pybind11' 'python-numpy' 'python-awkward<2') options=(!emptydirs) -source=("https://github.com/ubarsc/kealib/releases/download/$_pkgname-$_kea/$_pkgname-$_kea.tar.gz") -sha256sums=('da5d4a540b34afb61665cb7b6bf284825b51464eaf2a23ccca16955e2712cab2') +_awkward_ver=1.10.2 # Headers are the same in 1.10.3 +_awkward_raw=https://raw.githubusercontent.com/scikit-hep/awkward +_awkward_path=src/awkward/_v2/cpp-headers/awkward/ +_github=https://github.com/ubarsc/kealib +source=( + "$_github/releases/download/$_pkgname-$_kea/$_pkgname-$_kea.tar.gz" + "$_awkward_raw/v$_awkward_ver/$_awkward_path/LayoutBuilder.h" + "$_awkward_raw/v$_awkward_ver/$_awkward_path/BuilderOptions.h" + "$_awkward_raw/v$_awkward_ver/$_awkward_path/GrowableBuffer.h" + "$_awkward_raw/v$_awkward_ver/$_awkward_path/utils.h" + "setup.py" +) +sha256sums=( + '06cd547b1e40394b9539beaf6982bd249e8ee93d6150295e9cd9161d00829657' + '945b19124fadc60c99c60fb263d75ef31e9c4dda6980a5fe96353c3f20d9b330' + 'a78fc19e9cc9d4096b377e1e99f33fd908b25c3f2cf57dd889893f8042ddb883' + '8112164e16f7de7d8f6da3335f2f62c0f629d606ebb7326b2a499b576f85d579' + 'eb5957ca6d56eeab8601940b92d018fce3906c50958a85622faad66e0d17a4b6' + 'SKIP' +) + +prepare() { + cd "$srcdir/$_pkgname-$_kea" + + # Patch kealib.extrat to work with awkward < 2 + sed -i \ + -e '55i\using namespace pybind11::literals;' \ + -e 's/= to_buffers([^)]*/&, "key_format"_a="{form_key}-{attribute}"/' \ + -e 's/from_buffers(.*c[^)]*/&, "key_format"_a="{form_key}-{attribute}"/' \ + -e '/to_dict/i\pybind11::str form_json = form.attr("tojson")();' \ + -e '/to_dict/i\auto json = pybind11::module_::import("json");' \ + -e '/to_dict/i\auto json_loads = json.attr("loads");' \ + -e '/to_dict/i\pybind11::dict formDict = json_loads(form_json);' \ + -e '/to_dict/d' \ + -e 's/\(classType\) != \("ListOffsetArray"\)/\1.rfind(\2, 0) != 0/' \ + python/extrat.cpp + + # Patch kealib.testpython to work with awkward < 2 + sed -i \ + -e '/def check/{N;N;N;' \ + -e 'a\ awkward.CharBehavior.register(str)' \ + -e '}' \ + python/testpython.py + + # Let testpython assume fakegdal is a module of the package + # and that a compiled "testseg" is in the package directory + sed -i \ + -e 's/import fakegdal/from kealib &/' \ + -e "s-'./testseg'-__file__.rsplit('/', 1)[0] + '/testseg'-" \ + python/testpython.py + + # Fix a test bug, addBoolField no longer exists (it's addField now) + sed -ri 's/addBool(Field.*)(False)/add\1extrat.KEAFieldDataType.Bool, \2/' \ + python/run_test.py + + # Add the setuptools alternative to the CMake config of this package + ln -fs "$srcdir/setup.py" . + + # Create the "awkward" include directory, its license is BSD 3-clause + # (Check first line of these header files for more information) + # These files are not installed, and this assumes awkward < 2 + mkdir -p python/include/awkward + ln -fs "$srcdir/LayoutBuilder.h" python/include/awkward/ + ln -fs "$srcdir/BuilderOptions.h" python/include/awkward/ + ln -fs "$srcdir/GrowableBuffer.h" python/include/awkward/ + ln -fs "$srcdir/utils.h" python/include/awkward/ +} build() { - cd "$srcdir/$_pkgname-$_kea/python" + cd "$srcdir/$_pkgname-$_kea" python setup.py build + + py3_suffix=$(python -V | sed -r 's/.*3\.([0-9]+)\..*/3\1/') + g++ -O3 -lkea python/testseg.cpp \ + -o "build/lib.linux-$arch-cpython-$py3_suffix/kealib/testseg" +} + +check() { + py3_suffix=$(python -V | sed -r 's/.*3\.([0-9]+)\..*/3\1/') + cd "$srcdir/$_pkgname-$_kea/build/lib.linux-$arch-cpython-$py3_suffix" + echo Testing with run_test.py + python -m kealib.run_test + echo Finished run_test.py tests + echo Testing with testpython.py + KEALIB_LIBGDAL="kealib/fakegdal.cpython-$py3_suffix-$arch-linux-gnu.so" \ + python -m kealib.testpython + echo Finished testpython.py tests + rm *.kea } package() { - cd "$srcdir/$_pkgname-$_kea/python" + cd "$srcdir/$_pkgname-$_kea" python setup.py install --root="$pkgdir/" --optimize=1 --skip-build install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt" } diff --git a/setup.py b/setup.py new file mode 100755 index 000000000000..e51b22751953 --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +from pybind11.setup_helpers import Pybind11Extension +from setuptools import setup + + +setup( + name="kealib", + version="0.1", + description="Access to parts of kealib not exposed by GDAL", + long_description="", + author="Sam Gillingham", + author_email="gillingham.sam@gmail.com", + packages=["kealib"], + package_dir={"kealib": "python"}, + ext_package="kealib", + ext_modules=[ + Pybind11Extension( + name="extrat", + sources=["python/extrat.cpp"], + include_dirs=["python/include"], + libraries=["kea"], + ), + Pybind11Extension( + name="fakegdal", + sources=["python/fakegdal.cpp"], + libraries=["kea"], + ), + ], + license="LICENSE.txt", + url="https://github.com/ubarsc/kealib", + classifiers=[ + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + ], + cmdclass={"cxx_std": 17}, + zip_safe=False, + python_requires=">=3.7", +) |