diff options
| author | Jonathan Callen <abcd@gentoo.org> | 2011-07-07 05:23:14 -0400 |
|---|---|---|
| committer | Jonathan Callen <abcd@gentoo.org> | 2011-07-07 05:29:32 -0400 |
| commit | 2de5a5f5c64b20bdea5e315e76c099bef6d36a2c (patch) | |
| tree | 4785e201cce8522bc1871383f0db2abaacb8a876 /kde-base/pykde4/files | |
| parent | 503556a88131bc82fb921f26dbd5b2ac6fd10598 (diff) | |
| download | kde-2de5a5f5c64b20bdea5e315e76c099bef6d36a2c.tar.gz kde-2de5a5f5c64b20bdea5e315e76c099bef6d36a2c.tar.bz2 kde-2de5a5f5c64b20bdea5e315e76c099bef6d36a2c.zip | |
[kde-base/pykde4] Allow clean installation for multiple python versions
Diffstat (limited to 'kde-base/pykde4/files')
| -rw-r--r-- | kde-base/pykde4/files/kpythonpluginfactorywrapper.c | 52 | ||||
| -rw-r--r-- | kde-base/pykde4/files/pykde4-4.6.3-python-3.2.patch | 17 |
2 files changed, 69 insertions, 0 deletions
diff --git a/kde-base/pykde4/files/kpythonpluginfactorywrapper.c b/kde-base/pykde4/files/kpythonpluginfactorywrapper.c new file mode 100644 index 00000000000..3915a0d122b --- /dev/null +++ b/kde-base/pykde4/files/kpythonpluginfactorywrapper.c @@ -0,0 +1,52 @@ +#include <dlfcn.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define VERSION_LEN 10 + +#define FORMAT EPREFIX PLUGIN_DIR "/kpython%spluginfactory.so" + +static void *handle; +static void *(*wrapped_qt_plugin_instance)(); + +static void get_python_version(char* out) { + int pipefd[2]; + pipe(pipefd); + pid_t cpid = fork(); + if (cpid == 0) { + close(pipefd[1]); + read(pipefd[0], out, VERSION_LEN); + } else { + close(pipefd[0]); + close(1); + dup2(pipefd[1], 1); + close(pipefd[1]); + close(0); + char *args[] = { "eselect", "python", "show", "--ABI", "--python2", 0 }; + execv(EPREFIX "/usr/bin/eselect", args); + } +} + +__attribute__((constructor)) +static void init() { + char buf[VERSION_LEN + 1]; + memset(buf, 0, VERSION_LEN + 1); + get_python_version(buf); + int length = strlen(FORMAT) + strlen(buf) + 1; + char *name = malloc(length + 1); + snprintf(name, length, FORMAT, buf); + void *handle = dlopen(name, RTLD_NOW); + free(name); + wrapped_qt_plugin_instance = dlsym(handle, "qt_plugin_instance"); +} + +__attribute__((destructor)) +static void fini() { + dlclose(handle); +} + +void *qt_plugin_instance() { + return wrapped_qt_plugin_instance(); +} diff --git a/kde-base/pykde4/files/pykde4-4.6.3-python-3.2.patch b/kde-base/pykde4/files/pykde4-4.6.3-python-3.2.patch new file mode 100644 index 00000000000..62abdf0a1ba --- /dev/null +++ b/kde-base/pykde4/files/pykde4-4.6.3-python-3.2.patch @@ -0,0 +1,17 @@ +--- python/pykde4/sip/kio/kfileitem.sip ++++ python/pykde4/sip/kio/kfileitem.sip +@@ -236,7 +236,13 @@ + + len = sipCpp->count(); + +- if (PySlice_GetIndicesEx((PySliceObject *)a0, len, &start, &stop, &step, &slicelength) < 0) ++ if (PySlice_GetIndicesEx( ++#if PY_VERSION_HEX >= 0x03020000 ++ a0, ++#else ++ (PySliceObject *)a0, ++#endif ++ len, &start, &stop, &step, &slicelength) < 0) + sipIsErr = 1; + else + { |
