diff --git a/Changed-functions-to-pre-post-actions-when-forking.patch b/Changed-functions-to-pre-post-actions-when-forking.patch deleted file mode 100644 index 91c47fc6974c2740a0daaa2d0e2c0379cc862be4..0000000000000000000000000000000000000000 --- a/Changed-functions-to-pre-post-actions-when-forking.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0f34844009075391c55419a3afb90e469facf35e Mon Sep 17 00:00:00 2001 -From: Graham Dumpleton -Date: Tue, 14 May 2019 16:14:07 +1000 -Subject: [PATCH] Changed functions to pre/post actions when forking. - ---- - src/server/mod_wsgi.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c -index 2e4bb24d..bf55945a 100644 ---- a/src/server/mod_wsgi.c -+++ b/src/server/mod_wsgi.c -@@ -4345,8 +4345,13 @@ static void wsgi_python_child_init(apr_pool_t *p) - * do it if Python was initialised in parent process. - */ - -- if (wsgi_python_initialized && !wsgi_python_after_fork) -+ if (wsgi_python_initialized && !wsgi_python_after_fork) { -+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) -+ PyOS_AfterFork_Child(); -+#else - PyOS_AfterFork(); -+#endif -+ } - - /* Finalise any Python objects required by child process. */ - -@@ -10422,6 +10427,12 @@ static int wsgi_start_process(apr_pool_t *p, WSGIDaemonProcess *daemon) - wsgi_exit_daemon_process(0); - } - -+ if (wsgi_python_initialized) { -+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) -+ PyOS_AfterFork_Parent(); -+#endif -+ } -+ - apr_pool_note_subprocess(p, &daemon->process, APR_KILL_AFTER_TIMEOUT); - apr_proc_other_child_register(&daemon->process, wsgi_manage_process, - daemon, NULL, p); diff --git a/Use-official-APIs-for-accessing-interpreter-list.patch b/Use-official-APIs-for-accessing-interpreter-list.patch deleted file mode 100644 index c2c99910d4056c030d52a97312e05f044c9372a8..0000000000000000000000000000000000000000 --- a/Use-official-APIs-for-accessing-interpreter-list.patch +++ /dev/null @@ -1,55 +0,0 @@ -From b03b02df6318afe26052db5b0365732152cacea2 Mon Sep 17 00:00:00 2001 -From: Graham Dumpleton -Date: Tue, 14 May 2019 16:14:42 +1000 -Subject: [PATCH] Use official APIs for accessing interpreter list. - ---- - src/server/wsgi_interp.c | 18 ++++++++++++------ - 1 file changed, 12 insertions(+), 6 deletions(-) - -diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c -index 4a948509..3fbca04b 100644 ---- a/src/server/wsgi_interp.c -+++ b/src/server/wsgi_interp.c -@@ -338,9 +338,10 @@ static PyObject *ShutdownInterpreter_call( - - PyThreadState_Swap(NULL); - -- tstate = tstate->interp->tstate_head; -+ tstate = PyInterpreterState_ThreadHead(tstate->interp); -+ - while (tstate) { -- tstate_next = tstate->next; -+ tstate_next = PyThreadState_Next(tstate); - if (tstate != tstate_save) { - PyThreadState_Swap(tstate); - PyThreadState_Clear(tstate); -@@ -436,9 +437,13 @@ InterpreterObject *newInterpreterObject(const char *name) - */ - - if (!name) { -+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) -+ interp = PyInterpreterState_Main(); -+#else - interp = PyInterpreterState_Head(); -- while (interp->next) -- interp = interp->next; -+ while (PyInterpreterState_Next(interp)) -+ interp = PyInterpreterState_Next(interp); -+#endif - - name = ""; - } -@@ -1883,9 +1888,10 @@ static void Interpreter_dealloc(InterpreterObject *self) - - PyThreadState_Swap(NULL); - -- tstate = tstate->interp->tstate_head; -+ tstate = PyInterpreterState_ThreadHead(tstate->interp); -+ - while (tstate) { -- tstate_next = tstate->next; -+ tstate_next = PyThreadState_Next(tstate); - if (tstate != tstate_save) { - PyThreadState_Swap(tstate); - PyThreadState_Clear(tstate); diff --git a/mod_wsgi-4.5.20-exports.patch b/mod_wsgi-4.5.20-exports.patch index 276772eebfb6931bbf67daae57eef2a45dda7535..97e56714ee6bd05ac6e8fe011ca25f3c2f5d9078 100644 --- a/mod_wsgi-4.5.20-exports.patch +++ b/mod_wsgi-4.5.20-exports.patch @@ -1,4 +1,4 @@ ---- mod_wsgi-4.5.20/Makefile.in +--- mod_wsgi-4.5.20/Makefile.in.exports +++ mod_wsgi-4.5.20/Makefile.in @@ -28,7 +28,7 @@ all : src/server/mod_wsgi.la diff --git a/mod_wsgi-4.6.4-warnings.patch b/mod_wsgi-4.6.4-warnings.patch new file mode 100644 index 0000000000000000000000000000000000000000..46bb40fb9ea1e686eb03e4b2c163b1fab5f479d2 --- /dev/null +++ b/mod_wsgi-4.6.4-warnings.patch @@ -0,0 +1,131 @@ + +https://github.com/GrahamDumpleton/mod_wsgi/pull/364 + +https://bugzilla.redhat.com/show_bug.cgi?id=1602620 + +--- mod_wsgi-4.6.4/src/server/__init__.py.warnings ++++ mod_wsgi-4.6.4/src/server/__init__.py +@@ -103,7 +103,6 @@ + for name in mimetypes.knownfiles: + if os.path.exists(name): + return name +- break + else: + return name + +--- mod_wsgi-4.6.4/src/server/mod_wsgi.c.warnings ++++ mod_wsgi-4.6.4/src/server/mod_wsgi.c +@@ -2108,9 +2108,11 @@ + /* Publish event for the start of the response. */ + + if (wsgi_event_subscribers()) { ++#if 0 + WSGIThreadInfo *thread_info; + + thread_info = wsgi_thread_info(0, 0); ++#endif + + event = PyDict_New(); + +@@ -6349,10 +6351,7 @@ + + /* Need to cast const away. */ + +- if (r) +- id = &((request_rec *)r)->log_id; +- else +- id = &((conn_rec *)c)->log_id; ++ id = &((request_rec *)r)->log_id; + + ap_run_generate_log_id(c, r, id); + } +@@ -8510,6 +8509,7 @@ + ap_log_error(APLOG_MARK, APLOG_ALERT, errno, wsgi_server, + "mod_wsgi (pid=%d): Couldn't bind unix domain " + "socket '%s'.", getpid(), process->socket_path); ++ close(sockfd); + return -1; + } + +@@ -8521,6 +8521,7 @@ + ap_log_error(APLOG_MARK, APLOG_ALERT, errno, wsgi_server, + "mod_wsgi (pid=%d): Couldn't listen on unix domain " + "socket.", getpid()); ++ close(sockfd); + return -1; + } + +@@ -8555,6 +8556,7 @@ + "mod_wsgi (pid=%d): Couldn't change owner of unix " + "domain socket '%s' to uid=%ld.", getpid(), + process->socket_path, (long)socket_uid); ++ close(sockfd); + return -1; + } + } +@@ -13338,8 +13340,10 @@ + for (i = 0; i < wsgi_daemon_list->nelts; ++i) { + entry = &entries[i]; + +- close(entry->listener_fd); +- entry->listener_fd = -1; ++ if (entry->listener_fd != -1) { ++ close(entry->listener_fd); ++ entry->listener_fd = -1; ++ } + } + } + #endif +@@ -13751,8 +13755,8 @@ + + if (trusted_proxy) { + for (i=0; inelts; i++) { +- const char *name = NULL; +- const char *value = NULL; ++ const char *name; ++ const char *value; + + name = ((const char**)trusted_proxy_headers->elts)[i]; + value = apr_table_get(r->subprocess_env, name); +@@ -13879,11 +13883,9 @@ + */ + + for (i=0; inelts; i++) { +- const char *name = NULL; +- const char *value = NULL; ++ const char *name; + + name = ((const char**)trusted_proxy_headers->elts)[i]; +- value = apr_table_get(r->subprocess_env, name); + + if (!strcmp(name, "HTTP_X_FORWARDED_FOR") || + !strcmp(name, "HTTP_X_REAL_IP")) { +--- mod_wsgi-4.6.4/src/server/wsgi_logger.c.warnings ++++ mod_wsgi-4.6.4/src/server/wsgi_logger.c +@@ -694,9 +694,11 @@ + PyObject *object = NULL; + + if (wsgi_event_subscribers()) { ++#if 0 + WSGIThreadInfo *thread_info; + + thread_info = wsgi_thread_info(0, 0); ++#endif + + event = PyDict_New(); + +--- mod_wsgi-4.6.4/src/server/wsgi_python.h.warnings ++++ mod_wsgi-4.6.4/src/server/wsgi_python.h +@@ -21,6 +21,12 @@ + + /* ------------------------------------------------------------------------- */ + ++#ifdef _POSIX_C_SOURCE ++#undef _POSIX_C_SOURCE ++#endif ++#ifdef _XOPEN_SOURCE ++#undef _XOPEN_SOURCE ++#endif + #include + + #if !defined(PY_VERSION_HEX) diff --git a/mod_wsgi.spec b/mod_wsgi.spec index dcc6f06cc8a93545cdb1f85af91fde5c8b04e6c5..3fedd3e27ba54873f055adfc32174f6d2c1fbb9d 100644 --- a/mod_wsgi.spec +++ b/mod_wsgi.spec @@ -1,71 +1,142 @@ -%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}} %{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn 2>/dev/null || echo 0-0)}} -%{!?_httpd_confdir: %{expand: %%global _httpd_confdir %%{_sysconfdir}/httpd/conf.d}} -%{!?_httpd_modconfdir: %{expand: %%global _httpd_modconfdir %%{_sysconfdir}/httpd/conf.d}} -%{!?_httpd_moddir: %{expand: %%global _httpd_moddir %%{_libdir}/httpd/modules}} -%global sphinxbin %{_bindir}/sphinx-build-3 -Name: mod_wsgi -Version: 4.6.4 -Release: 2 -Summary: A WSGI interface for Python web applications in Apache -License: ASL 2.0 -URL: https://modwsgi.readthedocs.io/ -Source0: https://github.com/GrahamDumpleton/mod_wsgi/archive/%{version}.tar.gz#/mod_wsgi-%{version}.tar.gz -Source1: wsgi-python3.conf -Patch1: mod_wsgi-4.5.20-exports.patch -Patch2: Use-official-APIs-for-accessing-interpreter-list.patch -Patch3: Changed-functions-to-pre-post-actions-when-forking.patch -BuildRequires: httpd-devel gcc + +%global with_python2 1 +%global with_python3 0 + +%if %{with_python3} && !%{with_python2} +%global py3dir . +%endif + +Name: mod_wsgi +Version: 4.6.4 +Release: 1 +Summary: A WSGI interface for Python web applications in Apache +Group: System Environment/Libraries +License: Apache-2.0 +URL: https://modwsgi.readthedocs.io/ +Source0: https://github.com/GrahamDumpleton/mod_wsgi/archive/%{version}.tar.gz#/mod_wsgi-%{version}.tar.gz +Source1: wsgi.conf +Source2: wsgi-python3.conf +Patch1: mod_wsgi-4.5.20-exports.patch +Patch2: mod_wsgi-4.6.4-warnings.patch +BuildRequires: httpd-devel +BuildRequires: python3-sphinx +BuildRequires: gcc + %{?filter_provides_in: %filter_provides_in %{_httpd_moddir}/.*\.so$} %{?filter_setup} -%description -The mod_wsgi 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. + + +%global _description\ +The mod_wsgi 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.\ + + +%description %_description + +%if %{with_python2} +%package -n python2-%{name} +Summary: %summary +Requires: httpd-mmn = %{_httpd_mmn} +BuildRequires: python2-devel +BuildRequires: python2-pip +%{?python_provide:%python_provide python2-%{name}} +Provides: mod_wsgi = %{version}-%{release} +Provides: mod_wsgi%{?_isa} = %{version}-%{release} +Obsoletes: mod_wsgi < %{version}-%{release} + +%description -n python2-%{name} %_description + +%endif + +%if %{with_python3} %package -n python3-%{name} -Summary: %summary -Requires: httpd-mmn = %{_httpd_mmn} -BuildRequires: python3-devel, python3-sphinx -Provides: mod_wsgi = %{version}-%{release} -Provides: mod_wsgi%{?_isa} = %{version}-%{release} -Obsoletes: mod_wsgi < %{version}-%{release} -%description -n python3-%{name} -The mod_wsgi 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. +Summary: %summary +Requires: httpd-mmn = %{_httpd_mmn} +BuildRequires: python3-devel +%if %{without python2} +Provides: mod_wsgi = %{version}-%{release} +Provides: mod_wsgi%{?_isa} = %{version}-%{release} +Obsoletes: mod_wsgi < %{version}-%{release} +%endif +%description -n python3-%{name} %_description + +%endif %prep -%autosetup n %{name}-%{version} -p1 +%setup -qn %{name}-%{version} +%patch1 -p1 -b .exports +%patch2 -p1 -b .warnings + +%if "%{py3dir}" != "." +cp -a . %{py3dir} +%endif %build -make -C docs html SPHINXBUILD=%{sphinxbin} +make -C docs html + export LDFLAGS="$RPM_LD_FLAGS -L%{_libdir}" export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" -mkdir py3build/ -cp -R * py3build/ || : -pushd py3build + +%if %{with_python2} +%configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python2 +make %{?_smp_mflags} +%py2_build +%endif + +%if %{with_python3} +pushd %{py3dir} %configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python3 make %{?_smp_mflags} %py3_build popd +%endif %install -pushd py3build +%if %{with_python3} + +pushd %{py3dir} make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir} mv $RPM_BUILD_ROOT%{_httpd_moddir}/mod_wsgi{,_python3}.so + install -d -m 755 $RPM_BUILD_ROOT%{_httpd_modconfdir} -install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_httpd_modconfdir}/10-wsgi-python3.conf +install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_httpd_modconfdir}/10-wsgi-python3.conf %py3_install mv $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express{,-3} popd +%endif + +%if %{with_python2} +make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir} + +install -d -m 755 $RPM_BUILD_ROOT%{_httpd_modconfdir} +install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_httpd_modconfdir}/10-wsgi.conf + +%py2_install +mv $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express{,-2} +ln -s %{_bindir}/mod_wsgi-express-2 $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express +%endif + +%if %{with_python2} +%files -n python2-%{name} +%license LICENSE +%doc CREDITS.rst README.rst +%config(noreplace) %{_httpd_modconfdir}/*wsgi.conf +%{_httpd_moddir}/mod_wsgi.so +%{python2_sitearch}/mod_wsgi-*.egg-info +%{python2_sitearch}/mod_wsgi +%{_bindir}/mod_wsgi-express-2 +%{_bindir}/mod_wsgi-express +%endif + +%if %{with_python3} %files -n python3-%{name} %license LICENSE %doc CREDITS.rst README.rst @@ -74,10 +145,8 @@ popd %{python3_sitearch}/mod_wsgi-*.egg-info %{python3_sitearch}/mod_wsgi %{_bindir}/mod_wsgi-express-3 +%endif %changelog -* Sat Feb 27 2021 zhaorenhai - 4.6.4-2 -- Add configure file - -* Thu Nov 19 2020 huanghaitao - 4.6.4-1 -- package init +* Thu Apr 29 2021 openstack-sig +- Package Spec generated diff --git a/mod_wsgi.yaml b/mod_wsgi.yaml deleted file mode 100644 index 7a2481d3c8f6e789158430d4799f9f4809b5715d..0000000000000000000000000000000000000000 --- a/mod_wsgi.yaml +++ /dev/null @@ -1,4 +0,0 @@ -version_control: github -src_repo: GrahamDumpleton/mod_wsgi -tag_prefix: "" -separator: "." diff --git a/wsgi-python3.conf b/wsgi-python3.conf index fcf1d271e66249467551f31df806965a829a0560..eb2c5e518f5b9b3d83437838d9b1e6ed20536a10 100644 --- a/wsgi-python3.conf +++ b/wsgi-python3.conf @@ -4,4 +4,3 @@ LoadModule wsgi_module modules/mod_wsgi_python3.so - diff --git a/wsgi.conf b/wsgi.conf new file mode 100644 index 0000000000000000000000000000000000000000..0797bcef59f4a5d53cae3b5fdb769ad5c662738e --- /dev/null +++ b/wsgi.conf @@ -0,0 +1,7 @@ +# NOTE: mod_wsgi can not coexist in the same apache process as +# mod_wsgi_python3. Only load if mod_wsgi_python3 is not +# already loaded. + + +LoadModule wsgi_module modules/mod_wsgi.so +