initial import

This commit is contained in:
2025-06-22 20:39:04 -05:00
commit f8a70886f0
3428 changed files with 302546 additions and 0 deletions

80
python-cython/PKGBUILD Normal file
View File

@@ -0,0 +1,80 @@
# Maintainer: Jesus E. <heckyel@riseup.net>
pkgbase=python-cython
pkgname=(python-cython tauthon-cython)
pkgver=0.29.21
_debver=0.29.21
_debrel=3
pkgrel=1
arch=(i686 x86_64)
url="https://cython.org"
license=(Apache-2.0)
makedepends=(python-setuptools tauthon-setuptools quilt)
source=($pkgbase-$pkgver.tar.gz::"https://github.com/cython/cython/archive/$pkgver.tar.gz"
https://deb.debian.org/debian/pool/main/c/cython/cython_$_debver-$_debrel.debian.tar.xz
cython-hash-int-conversion.patch::"https://github.com/cython/cython/commit/28251032.patch")
sha512sums=('2c0c3e3fff07106eb98862f71cd5dec9ff29460cf9b9e4de74537ca5e033f7523989beb5fbdc14723beaf94a535976f75c803e791b87e017961d9694b8c37679'
'e6e897a8d54693843d7a9ef18919c5ae483488103fa472bbd088be288a454d070cc365e8a8d4610a62b43bb65cbf4fdc902558abef4326074668c15c8d394d56'
'2c1808e73a1b520460c33bcd6b60d9a5995b72f7bb2af76d687f8a67061b8cb494bae967a79310d5917c2fb1e784a56c53becedd6639a0e44cc635063120fe48')
prepare() {
cd cython-$pkgver
if [[ ${pkgver%.*} = ${_debver%.*} ]]; then
# Debian patches
export QUILT_PATCHES=debian/patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
export QUILT_DIFF_ARGS='--no-timestamps'
mv "$srcdir"/debian .
quilt push -av
fi
patch -p1 -i ../cython-hash-int-conversion.patch
cp -r $srcdir/cython-$pkgver $srcdir/cython-$pkgver-tauthon
find $srcdir/cython-$pkgver-tauthon -name '*.py' | xargs sed -e 's|/usr/bin/env python|/usr/bin/env tauthon|' -e 's|/usr/bin/python|/usr/bin/tauthon|' -i
}
build() {
cd cython-$pkgver
python setup.py build
cd ../cython-$pkgver-tauthon
tauthon setup.py build
}
package_python-cython() {
pkgdesc="C-Extensions for Python"
depends=(python-setuptools)
replaces=(cython)
conflicts=(cython)
provides=(cython)
cd cython-$pkgver
python setup.py install --root="$pkgdir" --skip-build
for f in cygdb cython cythonize; do
mv "$pkgdir"/usr/bin/$f "$pkgdir"/usr/bin/${f}3
ln -s ${f}3 "$pkgdir"/usr/bin/$f
done
install -Dm644 LICENSE.txt $pkgdir/usr/share/licenses/$pkgname/LICENSE.txt
}
package_tauthon-cython() {
pkgdesc="C-Extensions for Tauthon"
depends=(tauthon-setuptools)
replaces=(cython2)
conflicts=(cython2)
provides=(cython2)
cd cython-$pkgver-tauthon
tauthon setup.py install --root="$pkgdir" --skip-build
for f in cygdb cython cythonize; do
mv "$pkgdir"/usr/bin/$f "$pkgdir"/usr/bin/${f}-tauthon
done
install -Dm644 LICENSE.txt $pkgdir/usr/share/licenses/$pkgname/LICENSE.txt
}

View File

@@ -0,0 +1,106 @@
From 28251032f86c266065e4976080230481b1a1bb29 Mon Sep 17 00:00:00 2001
From: Robert Bradshaw <robertwb@google.com>
Date: Mon, 10 Dec 2018 11:54:20 +0100
Subject: [PATCH] Non-int conversion to Py_hash_t.
Still requires the more conservative __index__ here rather than a possibly
truncating __int__ because this is used in a context where floating point
values should probably be treated specially.
This fixes Github issue #2752.
---
Cython/Utility/ModuleSetupCode.c | 4 ++--
Cython/Utility/TypeConversion.c | 20 ++++++++++++++++++++
tests/run/py_hash_t.pyx | 18 ++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index 1f2e4bfae0..f2f62f98bc 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -651,10 +651,10 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#if PY_VERSION_HEX < 0x030200A4
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
+ #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
+ #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c
index 796c8bed9b..5938d2d78a 100644
--- a/Cython/Utility/TypeConversion.c
+++ b/Cython/Utility/TypeConversion.c
@@ -102,6 +102,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
@@ -420,6 +421,25 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
}
+static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
+ if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
+ return __Pyx_PyIndex_AsSsize_t(o);
+#if PY_MAJOR_VERSION < 3
+ } else if (likely(PyInt_CheckExact(o))) {
+ return PyInt_AS_LONG(o);
+#endif
+ } else {
+ Py_ssize_t ival;
+ PyObject *x;
+ x = PyNumber_Index(o);
+ if (!x) return -1;
+ ival = PyInt_AsLong(x);
+ Py_DECREF(x);
+ return ival;
+ }
+}
+
+
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
diff --git a/tests/run/py_hash_t.pyx b/tests/run/py_hash_t.pyx
index f18a8c3acc..ccdcd82e61 100644
--- a/tests/run/py_hash_t.pyx
+++ b/tests/run/py_hash_t.pyx
@@ -2,12 +2,30 @@
cimport cython
+class IntLike(object):
+ def __init__(self, value):
+ self.value = value
+ def __index__(self):
+ return self.value
+
+
def assign_py_hash_t(x):
"""
>>> assign_py_hash_t(12)
12
>>> assign_py_hash_t(-12)
-12
+
+ >>> assign_py_hash_t(IntLike(-3))
+ -3
+ >>> assign_py_hash_t(IntLike(1 << 100)) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ OverflowError: ...
+ >>> assign_py_hash_t(IntLike(1.5)) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ TypeError: __index__ ... (type float)
"""
cdef Py_hash_t h = x
return h