diff --git a/Werkzeug-2.0.3.tar.gz b/Werkzeug-2.0.3.tar.gz deleted file mode 100644 index 207ede1acfc4f3a96ded10e04fad12bb93e48880..0000000000000000000000000000000000000000 Binary files a/Werkzeug-2.0.3.tar.gz and /dev/null differ diff --git a/Werkzeug-2.2.2.tar.gz b/Werkzeug-2.2.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..5fe8032666367b3cb69ead22c8ad2673d0ed7f1f Binary files /dev/null and b/Werkzeug-2.2.2.tar.gz differ diff --git a/ephemeral_port_reserve.py b/ephemeral_port_reserve.py new file mode 100755 index 0000000000000000000000000000000000000000..5124b438ae27cf2daf860ccdddf20a9fc012ccdf --- /dev/null +++ b/ephemeral_port_reserve.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +from __future__ import absolute_import +from __future__ import unicode_literals + +import contextlib +import errno +from socket import error as SocketError +from socket import SO_REUSEADDR +from socket import socket +from socket import SOL_SOCKET + +LOCALHOST = '127.0.0.1' + + +def reserve(ip=LOCALHOST, port=0): + """Bind to an ephemeral port, force it into the TIME_WAIT state, and unbind it. + + This means that further ephemeral port alloctions won't pick this "reserved" port, + but subprocesses can still bind to it explicitly, given that they use SO_REUSEADDR. + By default on linux you have a grace period of 60 seconds to reuse this port. + To check your own particular value: + $ cat /proc/sys/net/ipv4/tcp_fin_timeout + 60 + + By default, the port will be reserved for localhost (aka 127.0.0.1). + To reserve a port for a different ip, provide the ip as the first argument. + Note that IP 0.0.0.0 is interpreted as localhost. + """ + port = int(port) + with contextlib.closing(socket()) as s: + s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) + try: + s.bind((ip, port)) + except SocketError as e: + # socket.error: EADDRINUSE Address already in use + if e.errno == errno.EADDRINUSE and port != 0: + s.bind((ip, 0)) + else: + raise + + # the connect below deadlocks on kernel >= 4.4.0 unless this arg is greater than zero + s.listen(1) + + sockname = s.getsockname() + + # these three are necessary just to get the port into a TIME_WAIT state + with contextlib.closing(socket()) as s2: + s2.connect(sockname) + sock, _ = s.accept() + with contextlib.closing(sock): + return sockname[1] + + +def main(): # pragma: no cover + from sys import argv + port = reserve(*argv[1:]) + print(port) + + +if __name__ == '__main__': + exit(main()) diff --git a/python-werkzeug.spec b/python-werkzeug.spec index ae581847e1d892deb802cd9c6412a929c44fcfa2..ee52f82a31290c96818443541ccaf2560e05e609 100644 --- a/python-werkzeug.spec +++ b/python-werkzeug.spec @@ -1,13 +1,16 @@ %global _empty_manifest_terminate_build 0 Name: python-werkzeug -Version: 2.0.3 +Version: 2.2.2 Release: 1 Summary: The comprehensive WSGI web application library. License: BSD-3-Clause URL: https://palletsprojects.com/p/werkzeug/ -Source0: https://files.pythonhosted.org/packages/6c/a8/60514fade2318e277453c9588545d0c335ea3ea6440ce5cdabfca7f73117/Werkzeug-2.0.3.tar.gz +Source0: https://files.pythonhosted.org/packages/source/W/Werkzeug/Werkzeug-2.2.2.tar.gz +# for test +Source1: https://github.com/Yelp/ephemeral-port-reserve/blob/master/ephemeral_port_reserve.py + BuildArch: noarch -BuildRequires: python3-werkzeug +BuildRequires: python3-werkzeug python3-markupsafe Requires: python3-pytest Requires: python3-pytest-xprocess @@ -124,7 +127,8 @@ providing more structure and patterns for defining powerful applications. %prep -%autosetup -n Werkzeug-2.0.3 +%autosetup -n Werkzeug-%{version} -p1 +cp %{SOURCE1} %{_builddir}/Werkzeug-%{version}/tests/ %build %py3_build @@ -158,7 +162,7 @@ mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %check -PYTHONPATH=%{buildroot}%{python3_sitelib} pytest -k "not (test_reloader_sys_path)" +PYTHONPATH=%{buildroot}%{python3_sitelib} pytest -k 'not (test_serving)' %files -n python3-werkzeug -f filelist.lst %dir %{python3_sitelib}/* @@ -167,6 +171,10 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} pytest -k "not (test_reloader_sys_path %{_docdir}/* %changelog +* Wed Apr 17 2024 wangjing - 2.2.2-1 +- update package of version 2.2.2 +- fix typo and grammar mistake + * Fri Jun 17 2022 jiangpengju - 2.0.3-1 - Upgrade python-werkzeug version to 2.0.3