%define debug_package %{nil}
Name:           python-twisted
Version:        22.10.0
Release:        3
Summary:        An event-driven networking engine written in Python
License:        MIT
URL:            http://twistedmatrix.com/
Source0:        https://github.com/twisted/twisted/archive/twisted-%{version}/twisted-%{version}.tar.gz
# https://github.com/twisted/twisted/commit/1e6e9d23cac59689760558dcb6634285e694b04c
Patch0:         CVE-2023-46137.patch


%description
Twisted is an event-based framework for internet applications,
supporting Python 2.7 and Python 3.5+. It includes modules for many
different purposes, including the following:

  * twisted.web: HTTP clients and servers, HTML templating, and a WSGI server
  * twisted.conch: SSHv2 and Telnet clients and servers and terminal emulators
  * twisted.words: Clients and servers for IRC, XMPP, and other IM protocols
  * twisted.mail: IMAPv4, POP3, SMTP clients and servers
  * twisted.positioning: Tools for communicating with NMEA-compatible GPS receivers
  * twisted.names: DNS client and tools for making your own DNS servers
  * twisted.trial: A unit testing framework that integrates well with Twisted-based code.

Twisted supports all major system event loops -- select (all platforms),
poll (most POSIX platforms), epoll (Linux), kqueue (FreeBSD, macOS),
IOCP (Windows), and various GUI event loops (GTK+2/3, Qt, wxWidgets).
Third-party reactors can plug into Twisted, and provide support for
additional event loops.

%package -n python3-twisted
Summary:        An event-driven networking engine written in Python

%{?python_provide:%python_provide python3-twisted}

BuildRequires:  python3-devel >= 3.3 python3dist(appdirs) >= 1.4.0
BuildRequires:  python3dist(automat) >= 0.3.0 python3dist(constantly) >= 15.1
BuildRequires:  python3dist(cryptography) >= 1.5 python3-hyperlink >= 17.1.1
BuildRequires:  (python3dist(h2) >= 3.0 with python3dist(h2) < 5.0)
BuildRequires:  python3dist(idna) >= 0.6 python3dist(incremental) >= 16.10.1
BuildRequires:  (python3dist(priority) >= 1.1.0 with python3dist(priority) < 2.0)
BuildRequires:  python3dist(pyasn1) python3dist(pyopenssl) >= 16.0.0
BuildRequires:  python3dist(pyserial) >= 3.0 python3dist(service-identity)
BuildRequires:  python3dist(setuptools) python3dist(sphinx) >= 1.3.1
BuildRequires:  python3dist(zope.interface) >= 4.4.2 python3dist(pyhamcrest)

Recommends:     python3dist(service-identity)

%description -n python3-twisted
Twisted is an event-based framework for internet applications,
supporting Python 2.7 and Python 3.5+. It includes modules for many
different purposes, including the following:

  * twisted.web: HTTP clients and servers, HTML templating, and a WSGI server
  * twisted.conch: SSHv2 and Telnet clients and servers and terminal emulators
  * twisted.words: Clients and servers for IRC, XMPP, and other IM protocols
  * twisted.mail: IMAPv4, POP3, SMTP clients and servers
  * twisted.positioning: Tools for communicating with NMEA-compatible GPS receivers
  * twisted.names: DNS client and tools for making your own DNS servers
  * twisted.trial: A unit testing framework that integrates well with Twisted-based code.

Twisted supports all major system event loops -- select (all platforms),
poll (most POSIX platforms), epoll (Linux), kqueue (FreeBSD, macOS),
IOCP (Windows), and various GUI event loops (GTK+2/3, Qt, wxWidgets).
Third-party reactors can plug into Twisted, and provide support for
additional event loops.

%package help
Summary:        Documents for python-twisted
BuildArch:      noarch

%description help
The python-twisted-help package contains related documents.

%prep
%autosetup -n twisted-twisted-%{version} -p1

%build
%py3_build

%install
%py3_install
mv %{buildroot}%{_bindir}/trial %{buildroot}%{_bindir}/trial-%{python3_version}
mv %{buildroot}%{_bindir}/twistd %{buildroot}%{_bindir}/twistd-%{python3_version}
ln -s ./trial-%{python3_version} %{buildroot}%{_bindir}/trial-3
ln -s ./twistd-%{python3_version} %{buildroot}%{_bindir}/twistd-3
ln -s ./trial-%{python3_version} %{buildroot}%{_bindir}/trial
ln -s ./twistd-%{python3_version} %{buildroot}%{_bindir}/twistd
chmod +x %{buildroot}%{python3_sitelib}/twisted/mail/test/pop3testserver.py
chmod +x %{buildroot}%{python3_sitelib}/twisted/trial/test/scripttest.py

pathfix.py -pn -i %{__python3} %{buildroot}%{python3_sitelib}
install -d %{buildroot}%{_mandir}/man1/
cp -a docs/conch/man/*.1 %{buildroot}%{_mandir}/man1/
cp -a docs/core/man/*.1 %{buildroot}%{_mandir}/man1/
cp -a docs/mail/man/*.1 %{buildroot}%{_mandir}/man1/

%check
PATH=%{buildroot}%{_bindir}:$PATH PYTHONPATH=%{buildroot}%{python3_sitelib} %{buildroot}%{_bindir}/trial-3 twisted ||:

%files -n python3-twisted
%doc NEWS.rst README.rst LICENSE
%{_bindir}/{trial-3*,twistd-3*}
%{python3_sitelib}/twisted
%{python3_sitelib}/Twisted-%{version}-py%{python3_version}.egg-info
%{_bindir}/{cftp,ckeygen,conch,mailmail,pyhtmlizer,tkconch,trial,twist,twistd}

%files help
%{_mandir}/man1/{cftp.1*,ckeygen.1*,conch.1*,mailmail.1*,pyhtmlizer.1*,tkconch.1*,trial.1*,twistd.1*}

%changelog
* Fri Dec 29 2023 yaoxin <yao_xin001@hoperun.com> - 22.10.0-3
- Fix CVE-2023-46137

* Thu Jan 19 2023 caodongxia <caodongxia@h-partners.com> - 22.10.0-2
- Modify the version restriction of python-h2

* Wed Dec 07 2022 jiangxinyu <jiangxinyu@kylinos.cn> - 22.10.0-1
- Update package to version 22.10.0

* Wed Aug 03 2022 duyiwei <duyiwei@kylinos.cn> - 22.4.0-1
- upgrade version to 22.4.0

* Mon May 09 2022 xu_ping <xuping33@h-partners.com> - 18.9.0-7
- fix build error caused by python3.10 wildcard

* Tue Aug 17 2021 liwu <liwu13@huawei.com> - 18.9.0-6
- fix CVE-2019-12855

* Mon Aug 16 2021 liwu <liwu13@huawei.com> - 18.9.0-5
- fix CVE-2020-10109 CVE-2020-10108

* Mon Oct 12 2020 zhangjiapeng <zhangjiapeng9@huawei.com> - 18.9.0-4
- Drop python2 support

* Tue Feb 25 2020 Jiangping Hu <hujp1985@foxmail.com> - 18.9.0-3
- Package init
