Blob Blame History Raw
%global srcname twisted

%global common_description %{expand:
Twisted is a networking engine written in Python, supporting numerous protocols.
It contains a web server, numerous chat clients, chat servers, mail servers
and more.}

Name:           python-%{srcname}
Version:        22.10.0
Release:        %autorelease
Summary:        Twisted is a networking engine written in Python

License:        MIT
URL:            http://twistedmatrix.com/
VCS:            https://github.com/twisted/twisted
Source0:        %vcs/archive/%{srcname}-%{version}/%{srcname}-%{version}.tar.gz
# Import gobject from gi.repository for Python 3
# https://twistedmatrix.com/trac/ticket/9642
Patch1:         0001-Import-gobject-from-gi.repository-in-Python-3.patch
# https://github.com/twisted/twisted/issues/11839
Patch2:         0002-Use-old-import-path-for-attrs-classes-and-functions.patch
# https://github.com/twisted/twisted/pull/11734
Patch3:         0003-Fix-tests-for-Python-3.11.patch
# https://github.com/twisted/twisted/pull/11787
Patch4:         0004-11786-fix-misuse-of-mktime-in-tests.patch
# https://github.com/twisted/twisted/pull/11733
Patch5:         0005-fix-sendmail-tests-for-python-3.11.patch
# downstream-only patch for skipping tests that fail during a mock build
Patch6:         0006-Skip-failing-tests.patch
# downstream-only patch to skip tests affected by cryptography policies
Patch7:         0007-22.10.0-disable-conch-tests-affected-by-crypto-policy.patch
# https://github.com/twisted/twisted/security/advisories/GHSA-xc8x-vp79-p3wm
# https://build.opensuse.org/package/view_file/openSUSE:Factory/python-Twisted/CVE-2023-46137-HTTP-pipeline-response.patch?expand=1&rev=177e11e657250072c4246369fdf6003c
Patch8:         0008-CVE-2023-46137-HTTP-pipeline-response.patch

BuildArch:      noarch

%description %{common_description}

%package -n python3-%{srcname}
Summary:        %{summary}

BuildRequires:  git-core
BuildRequires:  python3-devel >= 3.3
BuildRequires:  python3-pyasn1-modules, python3-cryptography, python3-pynacl
BuildRequires:  python3-service-identity, python3-pyOpenSSL, python3-h2
BuildRequires:  python3-bcrypt, python3-subunit
BuildRequires:  python3-hamcrest, python3-hypothesis

Recommends:  python3-%{srcname}+tls

%description -n python3-%{srcname} %{common_description}

%pyproject_extras_subpkg -n python3-%{srcname} tls


%prep
%autosetup -p1 -n %{srcname}-%{srcname}-%{version}
# cython-test-exception-raiser isn't packaged yet
sed -e '/cython-test-exception-raiser/d' -i setup.cfg

%generate_buildrequires
%pyproject_buildrequires -x test

%build
%pyproject_wheel


%install
%pyproject_install

# no-manual-page-for-binary
mkdir -p %{buildroot}%{_mandir}/man1/
for s in conch core mail; do
cp -a docs/$s/man/*.1 %{buildroot}%{_mandir}/man1/
done

# Packages that install arch-independent twisted plugins install here.
# https:# bugzilla.redhat.com/show_bug.cgi?id=1252140
mkdir -p %{buildroot}%{python3_sitelib}/twisted/plugins

# Move and symlink python3 scripts
ln -s ./trial %{buildroot}%{_bindir}/trial-3
ln -s ./twistd %{buildroot}%{_bindir}/twistd-3

%pyproject_save_files %{srcname}
echo "%ghost %{python3_sitelib}/twisted/plugins/dropin.cache" >> %{pyproject_files}


%check
# avoid "unsupported locale setting" error
export LC_ALL=C
PATH=%{buildroot}%{_bindir}:$PATH PYTHONPATH=$PWD/build/lib %{buildroot}%{_bindir}/trial twisted

%files -n python3-twisted  -f %{pyproject_files}
%doc NEWS.rst README.rst
%license LICENSE
%{_bindir}/cftp
%{_bindir}/ckeygen
%{_bindir}/conch
%{_bindir}/mailmail
%{_bindir}/pyhtmlizer
%{_bindir}/tkconch
%{_bindir}/trial
%{_bindir}/twist
%{_bindir}/twistd
%{_bindir}/trial-3
%{_bindir}/twistd-3
%{_mandir}/man1/cftp.1*
%{_mandir}/man1/ckeygen.1*
%{_mandir}/man1/conch.1*
%{_mandir}/man1/mailmail.1*
%{_mandir}/man1/pyhtmlizer.1*
%{_mandir}/man1/tkconch.1*
%{_mandir}/man1/trial.1*
%{_mandir}/man1/twistd.1*


%changelog
%autochangelog