Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} > 6
%global with_python3 1
%endif

Name:           pyproj
Version:        1.9.4
Release:        2%{?dist}
Summary:        Cython wrapper to provide python interfaces to Proj

Group:          Development/Libraries
License:        MIT
URL:            https://github.com/jswhit/%{name}
Source0:        https://pypi.python.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz

# patch to fix bug in _proj.pyx file
# reported 12-Nov-2015 as pull request #28 in github
Patch0: %{name}-%{version}-cython.patch

BuildRequires:  python2-devel
#to test if this can be removed, it seems obsolete/unneccessary
#BuildRequires:  python-setuptools
BuildRequires:  numpy
BuildRequires:  Cython
BuildRequires:  proj-devel
%if 0%{?with_python3}
BuildRequires:  python3-devel
#to test if this can be removed, it seems obsolete/unneccessary
#BuildRequires:  python3-setuptools
BuildRequires:  python3-numpy
%endif # if with_python3
# needed to remove the rpmlint error binary-or-shlib-defines-rpath 
# which detects the rpath '/usr/lib' in the _proj.so file
# (seems only to work for rawhide at the moment, not for fedora-23)
BuildRequires: chrpath

Requires:  proj-nad
Requires:  proj-epsg

# avoid providing the private libs:
%{?filter_setup:
%filter_provides_in %{python2_sitearch}.*\.so$
%filter_setup
}

%if 0%{?with_python3}
%{?filter_setup:
%filter_provides_in %{python3_sitearch}.*\.so$
%filter_setup
}
%endif # if with_python3

%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.

%if 0%{?with_python3}
%package -n python3-%{name}
Summary:        Cython wrapper to provide python 3 interfaces to Proj

%description -n python3-%{name}
Cython wrapper to provide python 3 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.

%endif # if with_python3

%prep
%setup -q
%patch0 -p0 -b .orig

# Delete proj sources, Cython generated file and proj data
rm -rf src
rm -f nad2bin.c
rm -f _proj.c
rm -rf lib/%{name}/data

# copy sources to py3dir to not interfere with py2 build
# and if needed modify #! lines of *.py files
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif # if with_python3

# Generate Cython C code
cython _proj.pyx

%if 0%{?with_python3}
pushd %{py3dir}
cython -3 _proj.pyx
popd
%endif # if with_python3

%build
export PROJ_DIR="%{_usr}/"
CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup-proj.py build

%if 0%{?with_python3}
pushd %{py3dir}
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup-proj.py build
popd
%endif # if with_python3

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

# correct wrong write permission for group
chmod 755  %{buildroot}/%{python2_sitearch}/%{name}/*.so

# remove the rpath setting from _proj.so
chrpath -d %{buildroot}/%{python2_sitearch}/%{name}/*.so

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup-proj.py install --skip-build --root %{buildroot}

# 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

popd
%endif # if with_python3

%check

# note1: the test() function is automatically called if the
# __init__.py file is run as main script, but Icould not yet figure out
# how to do this in this spec file, so just manually call the test() function.

# note2: the current version shows a fair number of failures in the test suite.
# Out of 73 tests the overall score was 54 passed and 19 failed.
# This has been reported upstream here:
#    https://github.com/jswhit/pyproj/issues/6

#%%{__python2} -c 'import pyproj;pyproj.test()'
PYTHONPATH="%{buildroot}%{python2_sitearch}" %{__python2} -c 'import pyproj;pyproj.test()'
%if 0%{?with_python3}
pushd %{py3dir}
PYTHONPATH="%{buildroot}%{python3_sitearch}" %{__python3} -c 'import pyproj;pyproj.test()'
popd
%endif # if with_python3

%files
%doc Changelog docs README.md
%{python2_sitearch}/%{name}
%{python2_sitearch}/%{name}-*-py*.egg-info

# note: the provided create_docs.sh script would suggest that
# epydoc is needed to build the docs in subdir docs. However
# the upstream author has already run this tool and has added
# the resulting files to svn, so this is not needed during
# rpm creation after all.

%if 0%{?with_python3}
%files -n python3-%{name}
%doc Changelog docs README.md
%{python3_sitearch}/%{name}
%{python3_sitearch}/%{name}-*-py*.egg-info
%endif # with_python3

%changelog
* Thu Nov 12 2015 Jos de Kloe <josdekloe@gmail.com> 1.9.4-2
- apply patch to fix a bug in _proj.pyx that surfaced in cython 0.23
- apply chrpath to fix binary-or-shlib-defines-rpath error reported by rpmlint

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Thu Mar 12 2015 Jos de Kloe <josdekloe@gmail.com> 1.9.4-1
- update to version 1.9.4
- replace python_sitearch macro with python2_sitearch
- replace the deprecated macro __python by __python3
- activate the check section

* Sat Jan 11 2014 Jos de Kloe <josdekloe@gmail.com> 1.9.2-8.20120712svn300
- replace the deprecated macro __python by __python2
- require proj-epsg to solve bug #1022238

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.2-7.20120712svn300
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.2-6.20120712svn300
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Jul 12 2012 Jos de Kloe <josdekloe@gmail.com> 1.9.2-5.20120712svn300
- adapted version number format to comply to the Snapshot packages 
  guidelines, and move to svn revision 300.

* Wed Jun 20 2012 Jos de Kloe <josdekloe@gmail.com> 1.9.2-4.r298
- Added proj-nad as explicit Requirement since it contains data files needed
  to run the module, and bumped the version number to the one mentioned in 
  the setup-proj.py script

* Fri Jun 15 2012 Jos de Kloe <josdekloe@gmail.com> 1.9.0-3.r298
- Adapted to build with python3

* Thu May 31 2012 Jos de Kloe <josdekloe@gmail.com> 1.9.0-2.r298
- Adapted to svn revision r298 which has some modifications
  to allow building without using the included proj sources

* Mon Apr 23 2012 Volker Fröhlich <volker27@gmx.at> - 1.9.0-1
- Initial package for Fedora