git: 0121f370d86d - main - www/mod_wsgi4: a port for mod_wsgi 4.9.4 for python 2.7

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Tue, 27 Oct 2026 00:57:00 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0121f370d86ddea8411bacfb72961eecedbd163a

commit 0121f370d86ddea8411bacfb72961eecedbd163a
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2026-10-23 14:46:16 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-10-27 00:56:07 +0000

    www/mod_wsgi4: a port for mod_wsgi 4.9.4 for python 2.7
    
    This brings back mod_wsgi 4.9.4 which is the last supported
    version for python 2.7.
    
    This is specifically for clusteradm infrastructure and not
            as a port for normal users.
    
    Note this currently clashes with www/mod_wsgi as it also
    builds and installs the module as "mod_wsgi.so".
    
    Approved by: clusteradm
---
 www/Makefile                                    |  1 +
 www/mod_wsgi4/Makefile                          | 50 +++++++++++++++++++++++++
 www/mod_wsgi4/distinfo                          |  3 ++
 www/mod_wsgi4/files/270_mod_wsgi.conf.sample.in |  8 ++++
 www/mod_wsgi4/files/patch-configure.ac          | 30 +++++++++++++++
 www/mod_wsgi4/pkg-descr                         |  7 ++++
 www/mod_wsgi4/pkg-plist                         |  3 ++
 7 files changed, 102 insertions(+)

diff --git a/www/Makefile b/www/Makefile
index 5b3315639cd8..c8a4a03c4949 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -489,6 +489,7 @@
     SUBDIR += mod_webauth
     SUBDIR += mod_webkit
     SUBDIR += mod_wsgi
+    SUBDIR += mod_wsgi4
     SUBDIR += mod_xsendfile
     SUBDIR += mohawk
     SUBDIR += moin2
diff --git a/www/mod_wsgi4/Makefile b/www/mod_wsgi4/Makefile
new file mode 100644
index 000000000000..d5aad6c289d3
--- /dev/null
+++ b/www/mod_wsgi4/Makefile
@@ -0,0 +1,50 @@
+PORTNAME=	mod_wsgi4
+DISTVERSION=	4.9.4
+CATEGORIES=	www python
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${APACHE_PKGNAMEPREFIX}${PYTHON_PKGNAMEPREFIX}
+DISTNAME=	mod_wsgi-${DISTVERSION}
+
+MAINTAINER=	adrian@freebsd.org
+COMMENT=	Python WSGI 4.9.x adapter module for Apache
+WWW=		https://www.modwsgi.org/
+
+LICENSE=	APACHE20
+
+USES=		apache autoreconf cpe python:2.7
+USE_PYTHON=	flavors
+
+.if !defined(WITH_CLUSTER_ALLOW_TECHNICAL_DEBTS)
+IGNORE=		python 2.7 is EOL; set WITH_CLUSTER_ALLOW_TECHNICAL_DEBTS=yes in make.conf to build it
+.endif
+
+CPE_VENDOR=	modwsgi
+
+GNU_CONFIGURE=		yes
+CONFIGURE_ARGS+=	--with-apxs="${APXS}" \
+			--with-python="${PYTHON_CMD}"
+
+CONFLICTS_INSTALL=	mod_wsgi
+
+MOD_NAME=	mod_wsgi
+AP_MOD_NAME=	mod_wsgi.so
+
+SUB_FILES=	${APMOD_FILE}
+APMOD_FILE=	270_${MOD_NAME}.conf.sample
+PLIST_SUB+=	APMOD_FILE=${APMOD_FILE}
+PLIST_SUB+=	APMODNAME_FILE=${AP_MOD_NAME}
+
+pre-everything::
+	@${ECHO_MSG} "======================= ATTENTION! ======================"
+	@${ECHO_MSG}
+	@${ECHO_MSG} "If you want to use daemon mode you will need to make sure"
+	@${ECHO_MSG} "Apache and APR include thread support."
+	@${ECHO_MSG}
+	@${ECHO_MSG} "========================================================="
+
+post-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${APACHEETCDIR}/modules.d
+	${INSTALL_DATA} ${WRKDIR}/${APMOD_FILE} ${STAGEDIR}${PREFIX}/${APACHEETCDIR}/modules.d
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/${APACHEMODDIR}/${MOD_NAME}.so
+
+.include <bsd.port.mk>
diff --git a/www/mod_wsgi4/distinfo b/www/mod_wsgi4/distinfo
new file mode 100644
index 000000000000..5bf24fb4154a
--- /dev/null
+++ b/www/mod_wsgi4/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1792645325
+SHA256 (mod_wsgi-4.9.4.tar.gz) = 8e762662ea5b01afc386bbcfbaa079748eb6203ab1d6d3a3dac9237f5666cfc9
+SIZE (mod_wsgi-4.9.4.tar.gz) = 497531
diff --git a/www/mod_wsgi4/files/270_mod_wsgi.conf.sample.in b/www/mod_wsgi4/files/270_mod_wsgi.conf.sample.in
new file mode 100644
index 000000000000..0177f0a7f668
--- /dev/null
+++ b/www/mod_wsgi4/files/270_mod_wsgi.conf.sample.in
@@ -0,0 +1,8 @@
+## vim: set filetype=apache:
+##
+## module file for mod_wsgi
+##
+## PROVIDE: mod_wsgi
+## REQUIRE:
+
+#LoadModule wsgi_module        %%APACHEMODDIR%%/mod_wsgi.so
diff --git a/www/mod_wsgi4/files/patch-configure.ac b/www/mod_wsgi4/files/patch-configure.ac
new file mode 100644
index 000000000000..840bf9031d14
--- /dev/null
+++ b/www/mod_wsgi4/files/patch-configure.ac
@@ -0,0 +1,30 @@
+--- configure.ac.orig	2022-09-12 02:16:14 UTC
++++ configure.ac
+@@ -160,7 +160,11 @@ if test "${PYTHONFRAMEWORKDIR}" = "no-framework" -o \
+ 
+ if test "${PYTHONFRAMEWORKDIR}" = "no-framework" -o \
+         "${ENABLE_FRAMEWORK}" != "yes"; then
+-    if test "${PYTHONLIBDIR}" != "${APXS_LIBDIR}" ; then
++    # Make sure mod_wsgi.so is dynamically linked against
++    # the python 2.7 runtime - otherwise it will fail
++    # to load (missing some libc symbols, for example openpty)
++    # due to linking and symbol visibility rules.
++    if test "${PYTHONLIBDIR}" != "${APXS_LIBDIR}" || test -n "${PYTHONLIBDIR}" ; then
+         LDFLAGS1="-L${PYTHONLIBDIR}"
+     fi
+     if test "${PYTHONCFGDIR}" != "${APXS_LIBDIR}" ; then
+@@ -180,12 +184,8 @@ if test "${PYTHONFRAMEWORKDIR}" = "no-framework" -o \
+         LDLIBS1="-lpython${PYTHON_VERSION}"
+     fi
+ 
+-    LDLIBS2=`${PYTHON} -c 'from sys import stdout; \
+-        import sysconfig; \
+-        stdout.write(sysconfig.get_config_var("LIBS"))'`
+-    LDLIBS3=`${PYTHON} -c 'from sys import stdout; \
+-        import sysconfig; \
+-        stdout.write(sysconfig.get_config_var("SYSLIBS"))'`
++    LDLIBS2=""
++    LDLIBS3=""
+ else
+     LDFLAGS1="-Wl,-F${PYTHONFRAMEWORKPREFIX} -framework ${PYTHONFRAMEWORK}"
+ 
diff --git a/www/mod_wsgi4/pkg-descr b/www/mod_wsgi4/pkg-descr
new file mode 100644
index 000000000000..93ccba96ce0d
--- /dev/null
+++ b/www/mod_wsgi4/pkg-descr
@@ -0,0 +1,7 @@
+The mod_wsgi4 adapter is an Apache module that provides a WSGI compliant
+interface for hosting Python based web applications within Apache. The
+adapter is written completely in C code against the Apache C runtime and
+for hosting WSGI applications within Apache has a lower overhead than using
+existing WSGI adapters for mod_python or CGI.
+
+This is the 4.x version that still supports Python 2.7.
diff --git a/www/mod_wsgi4/pkg-plist b/www/mod_wsgi4/pkg-plist
new file mode 100644
index 000000000000..19628ddce366
--- /dev/null
+++ b/www/mod_wsgi4/pkg-plist
@@ -0,0 +1,3 @@
+@sample %%APACHEETCDIR%%/modules.d/%%APMOD_FILE%%
+%%APACHEMODDIR%%/%%APMODNAME_FILE%%
+@postunexec echo "Don't forget to remove all mod_wsgi-related directives in your httpd.conf"