churchyard / rpms / pyproj

Forked from rpms/pyproj 5 years ago
Clone
Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} > 7
%global with_python3 1
%endif

# avoid providing the private libs:
%if 0%{?fedora} || 0%{?rhel} >= 7
%if 0%{?with_python3}
%global __provides_exclude_from ^(%{python2_sitearch}|%{python3_sitearch})/.*\\.so.*$
%else
%global __provides_exclude_from ^%{python2_sitearch}/.*\\.so.*$
%endif
%else
%{?filter_setup:
%filter_provides_in %{python2_sitearch}.*\.so$
%filter_setup
}
%endif


Name:           pyproj
Version:        1.9.5.1
Release:        15%{?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
# 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

# remove the test on the inverse hammer patch, since that depends on a function
# in proj.4 that has not yet been released (it was written by the pyproj
# author and contributed to the proj.4 project, but is only expected in the
# upcoming 4.9.3 release, which is not yet available)
# see: https://github.com/jswhit/pyproj/issues/19
# The problem has been reported here:
# https://github.com/jswhit/pyproj/issues/43
# A pull request to allow runtime checking for this problem was submitted here:
# https://github.com/jswhit/pyproj/pull/44
# and was merged 19-Jan-2016 but no new version has been released yet.
Patch0: %{name}-%{version}-no_inv_hammer_test.patch

BuildRequires:  gcc
BuildRequires:  proj-devel

# needed to remove the hardcoded path '/usr/lib' from the _proj.so file
BuildRequires: chrpath

# these 2 are needed during the tests run in the check section
BuildRequires:  proj-nad
BuildRequires:  proj-epsg

%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

# explicitly prepend python2 to the name of the binary package 
%package -n python2-%{name}

Summary: %summary

BuildRequires:  python2-devel
BuildRequires:  python2-numpy
BuildRequires:  python2-Cython

# these 2 packages are arch independent and contain only data files
Requires:  proj-nad
Requires:  proj-epsg

# ensure python provides are provided as long as python2 is the default runtime
%{?python_provide:%python_provide python2-%{name}}

# define provides/obsoletes following the package name change that
# prepends python2 to the python2 version of the module
Provides:   %{name} = %{version}-%{release}
Obsoletes:  %{name} < 1.9.5.1-6

%description -n python2-%{name} %_description

%if 0%{?with_python3}
%package -n python3-%{name}

Summary: %summary

BuildRequires:  python3-devel
BuildRequires:  python3-numpy
BuildRequires:  python3-Cython

# these 2 packages are arch independent and contain only data files
Requires:  proj-nad
Requires:  proj-epsg

# ensure python provides are provided when python3 becomes the default runtime
%{?python_provide:%python_provide python3-%{name}}

%description -n python3-%{name} %_description

%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

# Generate Cython C code
cython _proj.pyx

# 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

%build
export PROJ_DIR="%{_usr}/"
CFLAGS="%{optflags}" %{__python2} setup.py build

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

%install
export PROJ_DIR="%{_usr}/"
%{__python2} setup.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.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 I could not yet figure out
# how to do this in this spec file, so just manually call the test() function.

# run old tests
PYTHONPATH="%{buildroot}%{python2_sitearch}" %{__python2} -c 'import pyproj;pyproj.test()'
#run new tests (see README.md)
PYTHONPATH="%{buildroot}%{python2_sitearch}" %{__python2} unittest/test.py
%if 0%{?with_python3}
pushd %{py3dir}
# run old tests
PYTHONPATH="%{buildroot}%{python3_sitearch}" %{__python3} -c 'import pyproj;pyproj.test()'
# run new tests (see README.md)
PYTHONPATH="%{buildroot}%{python3_sitearch}" %{__python3} unittest/test.py
popd
%endif # if with_python3

%files -n python2-%{name}
%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 git, 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
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.5.1-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 1.9.5.1-14
- Rebuilt for Python 3.7

* Sat Feb 24 2018 Jos de Kloe <josdekloe@gmail.com> 1.9.5.1-13
- Add explicit BuildRequires for gcc

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.5.1-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.5.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.5.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Jul 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.9.5.1-9
- Rebuild due to bug in RPM (RHBZ #1468476)

* Thu Jul 06 2017 Björn Esser <besser82@fedoraproject.org> - 1.9.5.1-8
- move package specific (Build)Requires in the correspondig sub-packages

* Thu Jul 06 2017 Björn Esser <besser82@fedoraproject.org> - 1.9.5.1-7
- setup filtering for private libs correctly

* Fri Jun 30 2017 Jos de Kloe <josdekloe@gmail.com> 1.9.5.1-6
- rename pyproj to python2-pyproj following the new package naming scheme

* Wed Feb 01 2017 Jos de Kloe <josdekloe@gmail.com> 1.9.5.1-5
- force rebuild after libproj soname jump

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 1.9.5.1-4
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.5.1-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jan 14 2016 Jos de Kloe <josdekloe@gmail.com> 1.9.5.1-1
- update to new upstream version
- remove the inverse hammer test

* Thu Nov 12 2015 Jos de Kloe <josdekloe@gmail.com> 1.9.4-4
- 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

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.4-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* 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