diff options
author | bms <bms@FreeBSD.org> | 2009-03-14 17:33:40 +0800 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2009-03-14 17:33:40 +0800 |
commit | 164441601b62a5b67db7b4da1ffd35d2a3999f6a (patch) | |
tree | 428739f8c2f7a028e8cab1c158243f8f8c025e00 /lang/python26 | |
parent | 6f96c56a02d6367454f71469fa83d4592c3ba4d7 (diff) | |
download | freebsd-ports-gnome-164441601b62a5b67db7b4da1ffd35d2a3999f6a.tar.gz freebsd-ports-gnome-164441601b62a5b67db7b4da1ffd35d2a3999f6a.tar.zst freebsd-ports-gnome-164441601b62a5b67db7b4da1ffd35d2a3999f6a.zip |
Add support for building Python against GNU Portable Threads (Pth),
and also add experimental support for POSIX semaphores in FreeBSD
7-STABLE and up. The option knobs PTH and SEM respectively are
added to enable this behaviour.
Python is able to use POSIX semaphores for thread synchronization
in threading, and prefers them.
The multiprocessing module in Python 2.6 requires POSIX semaphores,
however, the FreeBSD rtld and malloc need further work to allow
a process to call pthread_create() immediately after fork() as it is
not something allowed by a strict interpretation of the POSIX specs;
therefore allow GNU Pth to be used until the situation is resolved.
Approved by: miwi
Diffstat (limited to 'lang/python26')
-rw-r--r-- | lang/python26/Makefile | 31 | ||||
-rw-r--r-- | lang/python26/files/extra-patch-configure-pth | 12 | ||||
-rw-r--r-- | lang/python26/files/extra-patch-setup.py | 26 | ||||
-rw-r--r-- | lang/python26/files/patch-Lib_test_test_threading.py | 11 | ||||
-rw-r--r-- | lang/python26/files/patch-Python_thread__pthread.h | 41 | ||||
-rw-r--r-- | lang/python26/files/pkg-message.in | 18 | ||||
-rw-r--r-- | lang/python26/pkg-message | 11 |
7 files changed, 129 insertions, 21 deletions
diff --git a/lang/python26/Makefile b/lang/python26/Makefile index 994c6838c28a..f1c4fd4179c2 100644 --- a/lang/python26/Makefile +++ b/lang/python26/Makefile @@ -50,6 +50,8 @@ BINLINKS_SUB= -e 's,smtpd,smtpd${PYTHON_VER},' \ OPTIONS= THREADS "Enable thread support" on \ HUGE_STACK_SIZE "Use a larger thread stack" off \ + SEM "Use POSIX semaphores (experimental)" off \ + PTH "Use GNU Pth for threading/multiprocessing" off \ UCS4 "Use UCS4 for unicode support" on \ PYMALLOC "Use python's internal malloc" on \ IPV6 "Enable IPv6 support" on \ @@ -57,6 +59,21 @@ OPTIONS= THREADS "Enable thread support" on \ .include <bsd.port.pre.mk> +.if defined(WITH_SEM) +.if ${OSVERSION} >= 701106 +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-setup.py +SEM_MSG= "" +.else +IGNORE= POSIX semaphore support only works in FreeBSD 7-STABLE and later +. +.endif # ${OSVERSION} >= 701106 +.else # !defined(WITH_SEM) +SEM_MSG= "@comment " +.endif # defined(WITH_SEM) + +SUB_FILES= pkg-message +SUB_LIST= SEM=${SEM_MSG} + .if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION} MLINKS= ${PYTHON_VERSION}.1 python.1 PLIST_SUB+= IF_DEFAULT="" @@ -68,15 +85,25 @@ PLIST_SUB+= IF_DEFAULT="@comment " CFLAGS+= -D__wchar_t=wchar_t .if !defined(WITHOUT_THREADS) +.if defined(WITH_PTH) +CONFIGURE_ARGS+= --with-pth +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-configure-pth +LIB_DEPENDS+= pth:${PORTSDIR}/devel/pth +_PTH_CPPFLAGS= "-I${LOCALBASE}/include/pth" +_PTH_LDFLAGS= "-L${LOCALBASE}/lib/pth" +CONFIGURE_ENV+= CPPFLAGS="${_PTH_CPPFLAGS} ${CPPFLAGS}" +CONFIGURE_ENV+= LDFLAGS="${_PTH_LDFLAGS} ${LDFLAGS}" +.else # !defined(WITH_PTH) CONFIGURE_ARGS+= --with-threads CFLAGS+= ${PTHREAD_CFLAGS} +CONFIGURE_ENV+= LDFLAGS="${PTHREAD_LIBS} ${LDFLAGS}" +.endif # defined(WITH_PTH) .if defined(WITHOUT_HUGE_STACK_SIZE) CFLAGS+= -DTHREAD_STACK_SIZE=0x20000 .else CFLAGS+= -DTHREAD_STACK_SIZE=0x100000 .endif # defined(WITHOUT_HUGE_STACK_SIZE) -CONFIGURE_ENV+= LDFLAGS="${PTHREAD_LIBS} ${LDFLAGS}" -.else +.else # defined(WITHOUT_THREADS) CONFIGURE_ARGS+= --without-threads .if defined(LDFLAGS) CONFIGURE_ENV+= LDFLAGS="${LDFLAGS}" diff --git a/lang/python26/files/extra-patch-configure-pth b/lang/python26/files/extra-patch-configure-pth new file mode 100644 index 000000000000..dca00011cac4 --- /dev/null +++ b/lang/python26/files/extra-patch-configure-pth @@ -0,0 +1,12 @@ +--- configure.orig 2009-03-12 14:16:24.000000000 +0000 ++++ configure 2009-03-12 14:17:16.000000000 +0000 +@@ -5230,6 +5230,9 @@ + CC="$ac_save_cc" + fi + ++# XXX Explicitly disable system pthread libraries. ++ac_cv_pthread=no ++ + { echo "$as_me:$LINENO: result: $ac_cv_pthread" >&5 + echo "${ECHO_T}$ac_cv_pthread" >&6; } + fi diff --git a/lang/python26/files/extra-patch-setup.py b/lang/python26/files/extra-patch-setup.py new file mode 100644 index 000000000000..109f7841adfa --- /dev/null +++ b/lang/python26/files/extra-patch-setup.py @@ -0,0 +1,26 @@ +--- setup.py.1 2009-03-12 04:07:36.000000000 +0000 ++++ setup.py 2009-03-12 04:08:36.000000000 +0000 +@@ -1265,13 +1265,21 @@ + ) + libraries = [] + +- elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): ++ elif platform in ('freebsd4', 'freebsd5', 'freebsd6'): + # FreeBSD's P1003.1b semaphore support is very experimental + # and has many known problems. (as of June 2008) +- macros = dict( # FreeBSD ++ macros = dict( # FreeBSD 4-6 + HAVE_SEM_OPEN=0, + HAVE_SEM_TIMEDWAIT=0, + HAVE_FD_TRANSFER=1, ++ ) ++ libraries = [] ++ ++ elif platform in ('freebsd7', 'freebsd8'): ++ macros = dict( # FreeBSD 7+ ++ HAVE_SEM_OPEN=1, ++ HAVE_SEM_TIMEDWAIT=1, ++ HAVE_FD_TRANSFER=1, + ) + libraries = [] + diff --git a/lang/python26/files/patch-Lib_test_test_threading.py b/lang/python26/files/patch-Lib_test_test_threading.py new file mode 100644 index 000000000000..011ae85349a4 --- /dev/null +++ b/lang/python26/files/patch-Lib_test_test_threading.py @@ -0,0 +1,11 @@ +--- Lib/test/test_threading.py.bak 2009-03-12 07:59:17.000000000 +0000 ++++ Lib/test/test_threading.py 2009-03-12 10:48:04.000000000 +0000 +@@ -382,7 +382,7 @@ + return + # Skip platforms with known problems forking from a worker thread. + # See http://bugs.python.org/issue3863. +- if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'): ++ if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8', 'os2emx'): + print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread' + ' due to known OS bugs on'), sys.platform + return diff --git a/lang/python26/files/patch-Python_thread__pthread.h b/lang/python26/files/patch-Python_thread__pthread.h index 1f4478528024..cde868cd8826 100644 --- a/lang/python26/files/patch-Python_thread__pthread.h +++ b/lang/python26/files/patch-Python_thread__pthread.h @@ -1,9 +1,34 @@ - -$FreeBSD$ - ---- Python/thread_pthread.h -+++ Python/thread_pthread.h -@@ -149,6 +149,7 @@ +--- Python/thread_pthread.h.orig 2006-06-13 16:04:24.000000000 +0100 ++++ Python/thread_pthread.h 2009-03-12 10:55:49.000000000 +0000 +@@ -26,13 +26,18 @@ + #endif + #endif + ++#ifdef __FreeBSD__ ++#include <osreldate.h> ++#endif ++ + /* The POSIX spec says that implementations supporting the sem_* + family of functions must indicate this by defining + _POSIX_SEMAPHORES. */ + #ifdef _POSIX_SEMAPHORES + /* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so + we need to add 0 to make it work there as well. */ +-#if (_POSIX_SEMAPHORES+0) == -1 ++#if defined(__FreeBSD__) && __FreeBSD_version < 701104 && \ ++ (_POSIX_SEMAPHORES+0) == -1 + #define HAVE_BROKEN_POSIX_SEMAPHORES + #else + #include <semaphore.h> +@@ -44,7 +49,6 @@ + in default setting. So the process scope is preferred to get + enough number of threads to work. */ + #ifdef __FreeBSD__ +-#include <osreldate.h> + #if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101 + #undef PTHREAD_SYSTEM_SCHED_SUPPORTED + #endif +@@ -149,6 +153,7 @@ { pthread_t th; int status; @@ -11,7 +36,7 @@ $FreeBSD$ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_t attrs; #endif -@@ -177,6 +178,8 @@ +@@ -177,6 +182,8 @@ #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM); #endif @@ -20,7 +45,7 @@ $FreeBSD$ status = pthread_create(&th, #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) -@@ -188,6 +191,7 @@ +@@ -188,6 +195,7 @@ (void *)arg ); diff --git a/lang/python26/files/pkg-message.in b/lang/python26/files/pkg-message.in new file mode 100644 index 000000000000..7f65e4d4ea80 --- /dev/null +++ b/lang/python26/files/pkg-message.in @@ -0,0 +1,18 @@ +==== +Note that some of the standard modules are provided as separate +ports since they require extra dependencies: + +bsddb databases/py-bsddb +gdbm databases/py-gdbm +sqlite3 databases/py-sqlite3 +tkinter x11-toolkits/py-tkinter + +Install them as needed. +==== +%%SEM%%-------------------------------------------------------- +%%SEM%%This package was built with the experimental POSIX +%%SEM%%semaphore support. Please ensure that the kernel on the +%%SEM%%system where you deploy this package is either compiled +%%SEM%%with 'option P1003_1B_SEMAPHORES', or has the sem.ko +%%SEM%%kernel module loaded. +%%SEM%%-------------------------------------------------------- diff --git a/lang/python26/pkg-message b/lang/python26/pkg-message deleted file mode 100644 index a3ba9904996b..000000000000 --- a/lang/python26/pkg-message +++ /dev/null @@ -1,11 +0,0 @@ -==== -Note that some of the standard modules are provided as separate -ports since they require extra dependencies: - -bsddb databases/py-bsddb -gdbm databases/py-gdbm -sqlite3 databases/py-sqlite3 -tkinter x11-toolkits/py-tkinter - -Install them as needed. -==== |