Blob Blame History Raw
%global with_python3 1

Name:           python-PyPDF2
Version:        1.25.1
Release:        2%{?dist}
License:        BSD
Summary:        Python PDF toolkit and library
Group:          Development/Libraries
Source:         https://pypi.python.org/packages/source/P/PyPDF2/PyPDF2-%{version}.tar.gz
URL:            https://github.com/mstamy2/PyPDF2

BuildRequires:  python2-devel
BuildRequires:  python-libs
BuildArch:      noarch

%if 0%{?with_python3}
BuildRequires:    python3-devel
BuildRequires:    python3-libs
%endif

%description
A pure Python library built as a PDF toolkit.  It is capable of:
    
- extracting document information (title, author, ...),
- splitting documents page by page,
- merging documents page by page,
- cropping pages,
- merging multiple pages into a single page,
- encryption and decryption of PDF files.

By being pure Python, it should run on any Python platform without any
dependencies on external libraries.  It can also work entirely on StringIO
objects rather than file streams, allowing for PDF manipulation in memory.
It is therefore a useful tool for websites that manage or manipulate PDFs.

%if 0%{?with_python3}
%package -n python3-PyPDF2
Summary:        Python PDF toolkit and library

%description  -n python3-PyPDF2
A pure Python library built as a PDF toolkit.  It is capable of:
    
- extracting document information (title, author, ...),
- splitting documents page by page,
- merging documents page by page,
- cropping pages,
- merging multiple pages into a single page,
- encryption and decryption of PDF files.

By being pure Python, it should run on any Python platform without any
dependencies on external libraries.  It can also work entirely on StringIO
objects rather than file streams, allowing for PDF manipulation in memory.
It is therefore a useful tool for websites that manage or manipulate PDFs.
%endif

%package -n python-PyPDF2-doc
Summary:    Documentation for python-PyPDF2

%description -n python-PyPDF2-doc
python-PyPDF2 contains documentation and examples for the python-PyPDF package

%prep
%setup -q -n PyPDF2-%{version}


%build
# Build for Python 3
%if 0%{?with_python3}
%{__python3} setup.py build
mv build build3
%endif

# Build for Python 2
%{__python2} setup.py build
mv build build2


%install
mv build2 build
%{__python2} setup.py install --skip-build --root %{buildroot}

# non-executable script
sed -i -e '/^#!\//, 1d' %{buildroot}%{python2_sitelib}/PyPDF2/pagerange.py

# Lots of things in the repo shouldn't be executable
chmod a-x Scripts/* Sample_Code/* LICENSE README.md CHANGELOG

rm -rf build

%if 0%{?with_python3}
mv build3 build
%{__python3} setup.py install --skip-build --root %{buildroot}

# non-executable script
sed -i -e '/^#!\//, 1d' %{buildroot}%{python3_sitelib}/PyPDF2/pagerange.py

# Lots of things in the repo shouldn't be executable
chmod a-x Scripts/* Sample_Code/* LICENSE README.md CHANGELOG

%endif


%check
# NOTE: Upstream has some testing bugs
#python -m unittest Tests.tests


%files
%defattr(-,root,root,-)
%{python2_sitelib}/*
%license LICENSE

%if 0%{?with_python3}
%files -n python3-PyPDF2
%{python3_sitelib}/*
%license LICENSE
%endif

%files -n python-PyPDF2-doc
%doc README.md CHANGELOG Scripts/ Sample_Code/
%license LICENSE

%changelog
* Wed Sep 23 2015 Major Hayden <major@mhtx.net> - 1.25.1-2
- Additional package review fixes

* Fri Sep 11 2015 Major Hayden <major@mhtx.net> - 1.25.1-1
- Initial package