# ;-*-mode:rpm-spec-*-
# JK: the above line tells my emacs editor to use rpm-spec mode
# NOTE:
# pyproj 2.4.1 does not compile yet on epel8
# because it uses exceptions inside "nogil" blocks, and this Cython
# feature was added with cython 0.29
# while el8 currently only offers Cython 0.28
# (i.e. python3-Cython-0.28.1-3.el8.x86_64)
# see: https://cython.readthedocs.io/en/latest/src/changes.html
# so try a downgrade to 2.3.1
# upgrade requested here:
# https://bugzilla.redhat.com/show_bug.cgi?id=1770543
#
# 2.3.1 depends on shapely which is not (yet) available
# so try the older 2.2.1 version
#
# epem8 branch requested here:
# https://bugzilla.redhat.com/show_bug.cgi?id=1770541
#
# finally, this seems to work if I disable one test file for pytest....
# avoid providing the private libs:
%global __provides_exclude_from ^(%{python3_sitearch})/.*\\.so.*$
%global minimal_needed_proj_version 6.1.0
Name: pyproj
Version: 2.2.1
Release: 1%{?dist}
Summary: Cython wrapper to provide python interfaces to Proj
License: MIT
URL: https://github.com/jswhit/%{name}
Source0: https://pypi.python.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
# the old source url still works, but if need be it can be replaced
# with: https://files.pythonhosted.org/packages/source/p/%%{name}/%%{name}-%%{version}.tar.gz
BuildRequires: gcc
BuildRequires: proj-devel >= %{minimal_needed_proj_version}
BuildRequires: proj >= %{minimal_needed_proj_version}
BuildRequires: python3-devel
BuildRequires: python3-numpy
BuildRequires: python3-Cython
# needed to run the tests
BuildRequires: python3-pytest
BuildRequires: python3-mock
# this one is not yet available in epel8
# BuildRequires: python3-shapely
# needed to remove the hardcoded path '/usr/lib' from the _proj.so file
BuildRequires: chrpath
# needed to build the documentation
BuildRequires: python3-sphinx
BuildRequires: python3-sphinx_rtd_theme
%global _description \
Cython wrapper to provide python interfaces to Proj. \
Performs cartographic transformations between geographic (Lat/Lon) \
and map projection (x/y) coordinates. Can also transform directly \
from one map projection coordinate system to another. \
Coordinates can be given as numpy arrays, python arrays, lists or scalars. \
Optimized for numpy arrays.
%description %_description
%package -n python3-%{name}
Summary: %summary
Requires: proj >= %{minimal_needed_proj_version}
# ensure python provides are provided when python3 becomes the default runtime
%{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name} %_description
%package -n python3-%{name}-doc
Summary: Documentation and example code
BuildArch: noarch
%description -n python3-%{name}-doc
This package contains the html documentation for the pyproj module.
%prep
%setup -q
# Delete Cython generated files
rm -v $(grep -rl '/\* Generated by Cython')
# patch python version to point to python3 in docs/Makefile and docs/conf.py
# note: a patch to solve these issues upstream has been proposed and accepted
# see: https://github.com/pyproj4/pyproj/commit/7ede45b61e604a5619fdc16f1268b822ab6c3227
sed -i -e 's/= python /= python3 /g' docs/Makefile
sed -i -e 's/^#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/g' docs/conf.py
%build
export PROJ_DIR="%{_usr}/"
%py3_build
# generate documentation
cd docs
# Need to point to the build dir so sphinx can import the module
# before it is installed.
%global py_build_libdir lib.linux-%{_arch}-%{python3_version}
PYTHONPATH=%{_builddir}/%{name}-%{version}/build/%{py_build_libdir}/ make html
%install
export PROJ_DIR="%{_usr}/"
%py3_install
# ensure the autogenerated hidden .buildinfo file is not included
# since rpmlint does not like hidden files in the documentation
%{__rm} %{_builddir}/%{name}-%{version}/docs/_build/html/.buildinfo
# copy documentation
mkdir -p %{buildroot}%{_datadir}/doc/%{name}
cp -r %{_builddir}/%{name}-%{version}/docs/_build/html \
%{buildroot}%{_datadir}/doc/%{name}/html
# correct wrong write permission for group
%{__chmod} 755 %{buildroot}/%{python3_sitearch}/%{name}/*.so
# remove the rpath setting from _proj.so
chrpath -d %{buildroot}/%{python3_sitearch}/%{name}/*.so
%check
PYTHONPATH="%{buildroot}%{python3_sitearch}" \
py.test-3 --ignore test/test_transformer.py
# this --ignore is needed to disable this one testcase
# which fails for all architectures for pyproj version 2.2.1:
# test_equivalent_proj__disabled
%files -n python3-%{name}
%doc docs README.md
%{python3_sitearch}/%{name}/
%{python3_sitearch}/%{name}-*-py*.egg-info/
%files -n python3-%{name}-doc
%doc %{_datadir}/doc/%{name}/
%changelog
* Sat Nov 9 2019 Jos de Kloe <josdekloe@gmail.com> 2.2.1-1
- first epel8 version