Skip to content

Commit

Permalink
* python stuff into a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
kth5 committed Apr 26, 2019
1 parent 4757a27 commit bb65316
Show file tree
Hide file tree
Showing 148 changed files with 55,644 additions and 0 deletions.
38 changes: 38 additions & 0 deletions python/pyalpm/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer : Rémy Oudompheng <remy@archlinux.org>

pkgname=pyalpm
pkgver=0.8.5
pkgrel=2
pkgdesc="Libalpm bindings for Python 3"
arch=(x86_64 powerpc64le)
url="https://git.archlinux.org/pyalpm.git/"
license=('GPL')
makedepends=('git' 'python-pytest')
depends=('python>=3.6' 'pacman>=5.0')
source=("git+https://git.archlinux.org/pyalpm.git#commit=6b47d1655688fe2957ef52a16aeca8b474546df2" "memleak.patch")
validpgpkeys=('E499C79F53C96A54E572FEE1C06086337C50773E')
sha512sums=('SKIP'
'b7dacb28bc13f5c9fb9c9295d1a3d323b7b7c0893d69b110f3036b73a4930e8463b5a19011b0e5996ff55157768376c2e53ab97c557afe29bbe3b5d0c8a1e027')

prepare() {
cd ${srcdir}/${pkgname}
# Rever memleak patch
patch -NRp1 -i ${srcdir}/memleak.patch
}

build() {
cd ${srcdir}/${pkgname}
python setup.py build
}

check() {
cd ${srcdir}/${pkgname}
PYTHONPATH="$PWD/build/lib.linux-$CARCH-3.7" pytest
}

package() {
cd ${srcdir}/${pkgname}
python setup.py install --root=${pkgdir}
}
44 changes: 44 additions & 0 deletions python/pyalpm/memleak.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From c02555c5d83e63b1a308e7c165d5615198e6d813 Mon Sep 17 00:00:00 2001
From: Jelle van der Waa <jelle@vdwaa.nl>
Date: Wed, 16 Jan 2019 09:30:28 +0100
Subject: src: dealloc alpm_handle when object goes out of scope

By default alpm_handle is leaked when Handle is out of scope since
alpm_release is never called. Call alpm_release in tp_dealloc to
actually free the alloc'd memory.
---
src/handle.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/src/handle.c b/src/handle.c
index 08853f0..5e196df 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -377,6 +377,16 @@ static PyMethodDef pyalpm_handle_methods[] = {
{NULL, NULL, 0, NULL},
};

+static void pyalpm_dealloc(PyObject* self) {
+ alpm_handle_t *handle = ALPM_HANDLE(self);
+ int ret = alpm_release(handle);
+ if (ret == -1) {
+ PyErr_Format(alpm_error, "unable to release alpm handle");
+ }
+ handle = NULL;
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
PyTypeObject AlpmHandleType = {
PyVarObject_HEAD_INIT(NULL, 0)
"alpm.Handle", /*tp_name*/
@@ -387,6 +397,7 @@ PyTypeObject AlpmHandleType = {
.tp_methods = pyalpm_handle_methods,
.tp_getset = pyalpm_handle_getset,
.tp_new = pyalpm_initialize,
+ .tp_dealloc = (destructor) pyalpm_dealloc,
};

/** Initializes Handle class in module */
--
cgit v1.2.1-1-g437b

74 changes: 74 additions & 0 deletions python/pygobject/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=pygobject
pkgname=(python-gobject python2-gobject pygobject-devel)
pkgver=3.30.4
pkgrel=1
pkgdesc="Python Bindings for GLib/GObject/GIO/GTK+"
url="https://wiki.gnome.org/Projects/PyGObject"
arch=(x86_64 powerpc64le)
license=(LGPL)
depends=(gobject-introspection-runtime)
makedepends=(python{,2}-cairo gobject-introspection git meson)
optdepends=('cairo: Cairo bindings')
_commit=30fc1cced45d7061f8f4c41d481fae0d345a25b5 # tags/3.30.4^0
source=("git+https://gitlab.gnome.org/GNOME/pygobject.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
cd $pkgbase
git describe --tags | sed 's/-/+/g'
}

prepare() {
cd $pkgbase
}

_build() (
arch-meson $pkgbase build-$1 -D python=/usr/bin/$1
ninja -C build-$1
)

_package() {
DESTDIR="$pkgdir" meson install -C build-$1
$1 -m compileall -d /usr/lib "$pkgdir/usr/lib"
$1 -O -m compileall -d /usr/lib "$pkgdir/usr/lib"
}

build() {
_build python
_build python2
}

package_python-gobject() {
depends=("pygobject-devel=$pkgver" python)

_package python

### Split -devel
mkdir -p "$srcdir/devel"
mv "$pkgdir"/usr/{include,lib/pkgconfig} "$srcdir/devel"
}

package_python2-gobject() {
pkgdesc="${pkgdesc/Python/Python2}"
depends=("pygobject-devel=$pkgver" python2)

_package python2

### Remove -devel
rm -r "$pkgdir"/usr/{include,lib/pkgconfig}
}

package_pygobject-devel() {
pkgdesc="Common development files for pygobject"
optdepends=()

mkdir -p "$pkgdir/usr/lib"
mv devel/include "$pkgdir/usr"
mv devel/pkgconfig "$pkgdir/usr/lib"
}

# vim:set sw=2 et:
70 changes: 70 additions & 0 deletions python/pygobject2/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgbase=pygobject2
pkgname=(python-gobject2 python2-gobject2 pygobject2-devel)
pkgver=2.28.7
pkgrel=2
pkgdesc="Python bindings for GObject (legacy)"
url="http://www.pygtk.org/"
arch=(x86_64 powerpc64le)
license=(LGPL)
depends=(glib2)
makedepends=(python python2 git)
options=(!emptydirs)
_commit=c9594b6a91e6ca2086fedec2ed8249e0a9c029fc # tags/PYGOBJECT_2_28_7^0
source=("git+https://git.gnome.org/browse/pygobject#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
cd pygobject
git describe --tags | sed 's/^PYGOBJECT_//;s/_/./g;s/-/+/g'
}

prepare() {
mkdir build-py{2,3} devel
cd pygobject
find . \( -name '*.py' -o -name '*.py.in' \) -exec sed -i '1s|python$|&2|' {} +
autoreconf -fvi
}

_build() (
cd build-py$1
../pygobject/configure --prefix=/usr --disable-introspection PYTHON=/usr/bin/python$1
sed -i 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
)

build() {
_build 2
_build 3
}

package_python-gobject2() {
depends=("pygobject2-devel=$pkgver" python)

cd build-py3
make DESTDIR="$pkgdir" install
rm -r "$pkgdir"/usr/{include,lib/pkgconfig,share/pygobject/xsl}
rm -r "$pkgdir"/usr/share/gtk-doc
}

package_python2-gobject2() {
pkgdesc="${pkgdesc/Python/Python2}"
depends=("pygobject2-devel=$pkgver" python2)

cd build-py2
make DESTDIR="$pkgdir" install
mv "$pkgdir"/usr/{include,lib/pkgconfig,share/pygobject/xsl} "$srcdir/devel"
rm -r "$pkgdir"/usr/share/gtk-doc
}

package_pygobject2-devel() {
pkgdesc="Common development files for pygobject2"

cd devel
mkdir -p "$pkgdir"/usr/{lib,share/pygobject}
mv include "$pkgdir/usr/"
mv pkgconfig "$pkgdir/usr/lib/"
mv xsl "$pkgdir/usr/share/pygobject/"
}
49 changes: 49 additions & 0 deletions python/pygtk/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Sarah Hay <sarahhay@mb.sympatico.ca>
pkgname=pygtk
pkgver=2.24.0
pkgrel=8
pkgdesc="Python bindings for the GTK widget set"
url="http://www.pygtk.org/"
arch=('x86_64' 'powerpc64le')
license=('LGPL')
depends=('libglade' 'python2-cairo' 'python2-gobject2')
makedepends=('python2-numpy' 'pygobject2-devel')
optdepends=('python2-numpy')
source=(https://download.gnome.org/sources/${pkgname}/${pkgver%.*}/${pkgname}-${pkgver}.tar.bz2
python27.patch
fix-leaks-of-pango-objects.patch)
sha256sums=('cd1c1ea265bd63ff669e92a2d3c2a88eb26bcd9e5363e0f82c896e649f206912'
'39a30456cba055a452bb55c74ef1ff2f5f7bfaad22855b4dd569ab009b56b682'
'0ca9e910e9bb88897089dd19752a419aa78de15463df766cb19a1d0c2dd45bcb')

prepare() {
cd "${srcdir}/${pkgname}-${pkgver}"

# https://bugzilla.gnome.org/show_bug.cgi?id=623965
patch -Np1 -i "${srcdir}/python27.patch"

# https://bugzilla.gnome.org/show_bug.cgi?id=660216
patch -Np1 -i "${srcdir}/fix-leaks-of-pango-objects.patch"

# Python 2
sed -i -e 's#env python$#env python2#' examples/pygtk-demo/{,demos/}*.py

# No docs
sed -i '/^SUBDIRS =/s/docs//' Makefile.in
}

build() {
cd "${srcdir}/${pkgname}-${pkgver}"

PYTHON=/usr/bin/python2 ./configure --build=$CHOST --prefix=/usr --disable-docs
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
}

package() {
cd "${srcdir}/${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
install -m644 gtk/gtk-extrafuncs.defs "${pkgdir}/usr/share/pygtk/2.0/defs/"
}
59 changes: 59 additions & 0 deletions python/pygtk/fix-leaks-of-pango-objects.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From eca72baa5616fbe4dbebea43c7e5940847dc5ab8 Mon Sep 17 00:00:00 2001
From: "Owen W. Taylor" <otaylor@fishsoup.net>
Date: Tue, 27 Sep 2011 00:17:52 -0400
Subject: Fix leaks of Pango objects

Gtk.PrintContext.create_pango_context()
Gtk.PrintContext.create_pango_layout()
pangocairo.CairoContext.create_layout()

were leaking the objects they returned.

https://bugzilla.gnome.org/show_bug.cgi?id=660216

diff --git a/gtk/gtk-2.10.defs b/gtk/gtk-2.10.defs
index 69c7e0c..faa45e1 100644
--- a/gtk/gtk-2.10.defs
+++ b/gtk/gtk-2.10.defs
@@ -1388,12 +1388,14 @@
(define-method create_pango_context
(of-object "GtkPrintContext")
(c-name "gtk_print_context_create_pango_context")
+ (caller-owns-return #t)
(return-type "PangoContext*")
)

(define-method create_pango_layout
(of-object "GtkPrintContext")
(c-name "gtk_print_context_create_pango_layout")
+ (caller-owns-return #t)
(return-type "PangoLayout*")
)

diff --git a/pangocairo.override b/pangocairo.override
index bb923e6..5101107 100644
--- a/pangocairo.override
+++ b/pangocairo.override
@@ -118,11 +118,16 @@ _wrap_pango_cairo_update_context(PyGObject *self, PyObject *args, PyObject *kwar
static PyObject *
_wrap_pango_cairo_create_layout(PyGObject *self)
{
- PangoLayout *ret;
+ PangoLayout *layout;
+ PyObject *ret;

- ret = pango_cairo_create_layout(PycairoContext_GET(self));
+ layout = pango_cairo_create_layout(PycairoContext_GET(self));
/* pygobject_new handles NULL checking */
- return pygobject_new((GObject *)ret);
+ ret = pygobject_new((GObject *)layout);
+ if (layout)
+ g_object_unref(layout);
+
+ return ret;
}

static PyObject *
--
cgit v0.10.2

50 changes: 50 additions & 0 deletions python/pygtk/python27.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c
index c0e1493..aa8cf10 100644
--- a/gtk/gtkmodule.c
+++ b/gtk/gtkmodule.c
@@ -227,8 +227,12 @@ init_gtk(void)
pygtk_add_stock_items(d);

/* extension API */
- PyDict_SetItemString(d, "_PyGtk_API",
- o=PyCObject_FromVoidPtr(&functions, NULL));
+#if PY_VERSION_HEX >= 0x02070000
+ o = PyCapsule_New(&functions, "gtk._gtk._PyGtk_API", NULL);
+#else
+ o = PyCObject_FromVoidPtr(&functions, NULL);
+#endif
+ PyDict_SetItemString(d, "_PyGtk_API", o);
Py_DECREF(o);

PyGtkDeprecationWarning = PyErr_NewException("gtk.GtkDeprecationWarning",
diff --git a/gtk/pygtk.h b/gtk/pygtk.h
index 573c3b9..e4c680f 100644
--- a/gtk/pygtk.h
+++ b/gtk/pygtk.h
@@ -60,6 +60,18 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;


/* a function to initialise the pygtk functions */
+
+/* Python 2.7 introduced the PyCapsule API and deprecated the CObject API */
+#if PY_VERSION_HEX >= 0x02070000
+#define init_pygtk() G_STMT_START { \
+ void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0); \
+ if (!capsule) { \
+ return; \
+ } \
+ _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule; \
+} G_STMT_END
+#else /* PY_VERSION_HEX */
+/* Python 2.6 and earlier use the CObject API */
#define init_pygtk() G_STMT_START { \
PyObject *pygtk = PyImport_ImportModule("gtk"); \
if (pygtk != NULL) { \
@@ -79,6 +91,7 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
return; \
} \
} G_STMT_END
+#endif /* PY_VERSION_HEX */

#endif

0 comments on commit bb65316

Please sign in to comment.