File python-bleach.spec of Package python-bleach
%global modname bleach
Name: python-%{modname}
Version: 6.0.0
Release: 1%{?dist}
Summary: An easy whitelist-based HTML-sanitizing tool
License: ASL 2.0
URL: https://github.com/mozilla/bleach
Source0: https://files.pythonhosted.org/packages/source/b/%{modname}/%{modname}-%{version}.tar.gz
BuildArch: noarch
%global _description \
Bleach is an HTML sanitizing library that escapes or strips markup and\
attributes based on a white list.
%description %{_description}
%package -n python3-%{modname}
Summary: An easy whitelist-based HTML-sanitizing tool
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
BuildRequires: python3-pytest
BuildRequires: python3-html5lib
Requires: python3-html5lib
%description -n python3-%{modname}
%{_description}
Python 3 version.
%pyproject_extras_subpkg -n python3-%{modname} css
%prep
%autosetup -n %{modname}-%{version} -p1
# Remove pregenerated egg-info
rm -rf bleach.egg-info
# Remove vendored libraries which were added for https://github.com/mozilla/bleach/issues/386
rm -r bleach/_vendor/
# Bleach has a shim layer that references the vendored html5lib and urllib.parse we just deleted.
# Let's patch up the imports to use the real html5lib and urllib.parse.
sed -i "s/bleach._vendor.html5lib/html5lib/g" bleach/html5lib_shim.py tests/test_clean.py
sed -i "s/bleach._vendor.parse/urllib.parse/g" bleach/parse_shim.py
# Don't require upper bound version for tinycss2
sed -i 's/"tinycss2>=1\.1\.0,<1\.2"/"tinycss2>=1.1.0"/' setup.py
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files %{modname}
%check
! find %{buildroot}%{python3_sitelib}/bleach/ -type d | grep vendor
if [ $? -ne 0 ]; then
echo "Detected vendored libraries; please remove them."
/usr/bin/false
fi;
%pytest -k 'not test_uri_value_allowed_protocols and not test_css_parsing_gauntlet_regex_backtracking'
%files -n python3-%{modname} -f %{pyproject_files}
%license LICENSE
%doc README.rst