09fec3e
%global cmapdir %(echo `rpm -qls ghostscript | grep CMap | awk '{print $2}'`)
714668f
%global pypi_name reportlab
09fec3e
de671aa
%global debug_package %{nil}
de671aa
c9df95a
%bcond_without tests
c9df95a
714668f
Name:           python-%{pypi_name}
0683e71
Version:        4.2.0
003b119
Release:        %autorelease
ccbfc81
Summary:        Library for generating PDFs and graphics
9d2f535
License:        BSD-3-Clause AND BSD-4-Clause AND MIT
e6fc0de
URL:            https://www.reportlab.com/opensource/
714668f
Source0:        %pypi_source
de671aa
BuildArch:      noarch
ccbfc81
198d499
BuildRequires:  gcc
09fec3e
BuildRequires:  freetype-devel
09fec3e
BuildRequires:  ghostscript
c9df95a
Buildrequires:  fontpackages-devel
a950f58
Buildrequires:  python3-html5lib+chardet
cc2e08d
%global fonts font(dejavusans)
3dae6e0
BuildRequires:  %{fonts}
c9df95a
c9df95a
Obsoletes:      %{name}-doc < 0:3.5.21-1
c9df95a
c9df95a
%description
c9df95a
This is the ReportLab PDF Toolkit. It allows rapid creation of rich PDF
c9df95a
documents, and also creation of charts in a variety of bitmap and vector
c9df95a
formats.
ccbfc81
714668f
%package -n     python3-%{pypi_name}
ccbfc81
Summary:        Library for generating PDFs and graphics
09fec3e
BuildRequires:  python3-devel
2a23e32
BuildRequires:  python3-setuptools
09fec3e
BuildRequires:  python3-pillow
3dae6e0
Requires:       %{fonts}
950633e
%py_provides python3-%{pypi_name}
9fe7803
Obsoletes: python2-reportlab < 0:%{version}-%{release}
09fec3e
714668f
%description -n python3-%{pypi_name}
09fec3e
This is the ReportLab PDF Toolkit. It allows rapid creation of rich PDF 
09fec3e
documents, and also creation of charts in a variety of bitmap and vector 
09fec3e
formats.
09fec3e
cvsextras 10e2495
%prep
3799a00
%autosetup -n %{pypi_name}-%{version}
9fe7803
c2a34e3
# clean up hashbangs from libraries
c2a34e3
find src -name '*.py' | xargs sed -i -e '/^#!\//d'
09fec3e
# patch the CMap path by adding Fedora ghostscript path before the match
09fec3e
sed -i '/\~\/\.local\/share\/fonts\/CMap/i''\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ '\'%{cmapdir}\''\,' src/reportlab/rl_settings.py
c9df95a
c9df95a
# Remove Upstream Egg
c9df95a
rm -rf src/reportlab.egg-info
c9df95a
c9df95a
# Remove bundled libart
c9df95a
rm -rf src/rl_addons/renderPM/libart_lgpl
c9df95a
cvsextras 10e2495
%build
de671aa
CFLAGS="%{build_cflags} -Isrc/rl_addons/renderPM" \
de671aa
 %py3_build -- --no-download-t1-files
cvsextras 10e2495
cvsextras 10e2495
%install
de671aa
CFLAGS="%{build_cflags} -Isrc/rl_addons/renderPM" \
de671aa
 %py3_install -- --no-download-t1-files
ccbfc81
c9df95a
# Unbundled fonts
de671aa
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Regular") %{buildroot}%{python3_sitelib}/reportlab/fonts/Vera.ttf
de671aa
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Bold Oblique") %{buildroot}%{python3_sitelib}/reportlab/fonts/VeraBI.ttf
de671aa
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Bold") %{buildroot}%{python3_sitelib}/reportlab/fonts/VeraBd.ttf
de671aa
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Condensed Oblique") %{buildroot}%{python3_sitelib}/reportlab/fonts/VeraIt.ttf
3dae6e0
de671aa
rm -f %{buildroot}%{python3_sitelib}/reportlab/fonts/bitstream-vera-license.txt
cvsextras 10e2495
de671aa
cp -a demos %{buildroot}%{python3_sitelib}/reportlab/
de671aa
cp -a tools %{buildroot}%{python3_sitelib}/reportlab/
c9df95a
c691f2b
# Fix shebang in individual files
de671aa
%py3_shebang_fix %{buildroot}%{python3_sitelib}/reportlab/demos/tests/testdemos.py
de671aa
%py3_shebang_fix %{buildroot}%{python3_sitelib}/reportlab/tools/docco/docpy.py
de671aa
%py3_shebang_fix %{buildroot}%{python3_sitelib}/reportlab/tools/docco/graphdocpy.py
de671aa
%py3_shebang_fix %{buildroot}%{python3_sitelib}/reportlab/tools/docco/rl_doc_utils.py
de671aa
%py3_shebang_fix %{buildroot}%{python3_sitelib}/reportlab/tools/pythonpoint/pythonpoint.py
de671aa
de671aa
chmod 0755 %{buildroot}%{python3_sitelib}/reportlab/demos/tests/testdemos.py
de671aa
chmod 0755 %{buildroot}%{python3_sitelib}/reportlab/tools/docco/docpy.py
de671aa
chmod 0755 %{buildroot}%{python3_sitelib}/reportlab/tools/docco/graphdocpy.py
de671aa
chmod 0755 %{buildroot}%{python3_sitelib}/reportlab/tools/docco/rl_doc_utils.py
de671aa
chmod 0755 %{buildroot}%{python3_sitelib}/reportlab/tools/pythonpoint/pythonpoint.py
c691f2b
c9df95a
%if %{with tests}
09fec3e
%check
Antonio Trande 450e868
# Tests need in-build compiled Python modules to be executed
Antonio Trande 450e868
# Tests pre-generate userguide PDF
de671aa
cp -a build/lib/reportlab tests/
de671aa
cp -a build/lib/reportlab docs/
de671aa
cp -a build/lib/reportlab docs/userguide/
c9df95a
%{__python3} setup.py tests
c9df95a
%endif
cvsextras 10e2495
714668f
%files -n python3-%{pypi_name}
c9df95a
%doc README.txt CHANGES.md docs/reportlab-userguide.pdf
de671aa
%license LICENSE
de671aa
%{python3_sitelib}/reportlab/
de671aa
%{python3_sitelib}/reportlab-%{version}-py%{python3_version}.egg-info
cvsextras 10e2495
cvsextras 10e2495
%changelog
003b119
%autochangelog