09fec3e
%global cmapdir %(echo `rpm -qls ghostscript | grep CMap | awk '{print $2}'`)
714668f
%global pypi_name reportlab
09fec3e
c9df95a
%bcond_without tests
c9df95a
714668f
Name:           python-%{pypi_name}
003b119
Version:        3.6.13
003b119
Release:        %autorelease
ccbfc81
Summary:        Library for generating PDFs and graphics
c9df95a
License:        BSD and GPLv2+
e6fc0de
URL:            https://www.reportlab.com/opensource/
714668f
Source0:        %pypi_source
ccbfc81
198d499
BuildRequires:  gcc
09fec3e
BuildRequires:  freetype-devel
09fec3e
BuildRequires:  ghostscript
fd8339f
BuildRequires:  libart_lgpl-devel
3dae6e0
c9df95a
Buildrequires:  fontpackages-devel
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
3799a00
CFLAGS="%{build_cflags} -Isrc/rl_addons/renderPM `pkg-config --cflags libart-2.0`" \
3799a00
 %py3_build -- --use-system-libart --no-download-t1-files
cvsextras 10e2495
cvsextras 10e2495
%install
3799a00
CFLAGS="%{build_cflags} -Isrc/rl_addons/renderPM `pkg-config --cflags libart-2.0`" \
3799a00
 %py3_install -- --use-system-libart --no-download-t1-files
ccbfc81
c9df95a
# Unbundled fonts
cc2e08d
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Regular") %{buildroot}%{python3_sitearch}/reportlab/fonts/Vera.ttf
cc2e08d
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Bold Oblique") %{buildroot}%{python3_sitearch}/reportlab/fonts/VeraBI.ttf
cc2e08d
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Bold") %{buildroot}%{python3_sitearch}/reportlab/fonts/VeraBd.ttf
cc2e08d
ln -sf $(fc-match -f "%{file}" "DejaVu Sans:style=Condensed Oblique") %{buildroot}%{python3_sitearch}/reportlab/fonts/VeraIt.ttf
3dae6e0
c9df95a
rm -f %{buildroot}%{python3_sitearch}/reportlab/fonts/bitstream-vera-license.txt
cvsextras 10e2495
c9df95a
cp -a demos %{buildroot}%{python3_sitearch}/reportlab/
c9df95a
cp -a tools %{buildroot}%{python3_sitearch}/reportlab/
c9df95a
c691f2b
# Fix shebang in individual files
437f3ca
%{__python3} %{_rpmconfigdir}/redhat/pathfix.py -pn -i "%{__python3}" %{buildroot}%{python3_sitearch}/reportlab/demos/tests/testdemos.py
437f3ca
%{__python3} %{_rpmconfigdir}/redhat/pathfix.py -pn -i "%{__python3}" %{buildroot}%{python3_sitearch}/reportlab/tools/docco/docpy.py
437f3ca
%{__python3} %{_rpmconfigdir}/redhat/pathfix.py -pn -i "%{__python3}" %{buildroot}%{python3_sitearch}/reportlab/tools/docco/graphdocpy.py
437f3ca
%{__python3} %{_rpmconfigdir}/redhat/pathfix.py -pn -i "%{__python3}" %{buildroot}%{python3_sitearch}/reportlab/tools/docco/rl_doc_utils.py
437f3ca
%{__python3} %{_rpmconfigdir}/redhat/pathfix.py -pn -i "%{__python3}" %{buildroot}%{python3_sitearch}/reportlab/tools/pythonpoint/pythonpoint.py
c691f2b
c691f2b
chmod 0755 %{buildroot}%{python3_sitearch}/reportlab/demos/tests/testdemos.py
c691f2b
chmod 0755 %{buildroot}%{python3_sitearch}/reportlab/tools/docco/docpy.py
c691f2b
chmod 0755 %{buildroot}%{python3_sitearch}/reportlab/tools/docco/graphdocpy.py
c691f2b
chmod 0755 %{buildroot}%{python3_sitearch}/reportlab/tools/docco/rl_doc_utils.py
c691f2b
chmod 0755 %{buildroot}%{python3_sitearch}/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
0ebae8b
cp -a build/lib.%{python3_platform}-cpython-%{python3_version_nodots}/reportlab tests/
0ebae8b
cp -a build/lib.%{python3_platform}-cpython-%{python3_version_nodots}/reportlab docs/
0ebae8b
cp -a build/lib.%{python3_platform}-cpython-%{python3_version_nodots}/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
ccbfc81
%license LICENSE.txt
09fec3e
%{python3_sitearch}/reportlab/
09fec3e
%{python3_sitearch}/reportlab-%{version}-py%{python3_version}.egg-info
cvsextras 10e2495
cvsextras 10e2495
%changelog
003b119
%autochangelog