Bundle proj7

This commit is contained in:
Sandro Mani 2021-03-23 01:43:39 +01:00
commit c1911066e5
4 changed files with 211 additions and 3 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@
/Cartopy-0.18.0rc1.tar.gz
/Cartopy-0.18.0.tar.gz
/Cartopy-0.19.0rc1.tar.gz
/proj-7.2.1.tar.gz

167
cartopy_bundle-proj.patch Normal file
View file

@ -0,0 +1,167 @@
diff -rupN Cartopy-0.19.0rc1/lib/cartopy/_proj4.pxd Cartopy-0.19.0rc1-new/lib/cartopy/_proj4.pxd
--- Cartopy-0.19.0rc1/lib/cartopy/_proj4.pxd 2021-03-12 16:14:24.000000000 +0100
+++ Cartopy-0.19.0rc1-new/lib/cartopy/_proj4.pxd 2021-03-23 01:17:48.195109606 +0100
@@ -23,6 +23,6 @@ cdef extern from "proj_api.h":
int pj_is_latlong(projPJ) nogil
char *pj_strerrno(int) nogil
int *pj_get_errno_ref() nogil
- char *pj_get_release() nogil
+ const char *pj_get_release() nogil
cdef double DEG_TO_RAD
cdef double RAD_TO_DEG
diff -rupN Cartopy-0.19.0rc1/setup.py Cartopy-0.19.0rc1-new/setup.py
--- Cartopy-0.19.0rc1/setup.py 2021-03-12 16:14:24.000000000 +0100
+++ Cartopy-0.19.0rc1-new/setup.py 2021-03-23 01:29:31.342127777 +0100
@@ -141,109 +141,11 @@ else:
# Proj
-def find_proj_version_by_program(conda=None):
- proj = find_executable('proj')
- if proj is None:
- print(
- 'Proj {} must be installed.'.format(
- '.'.join(str(v) for v in PROJ_MIN_VERSION)),
- file=sys.stderr)
- exit(1)
-
- if conda is not None and conda not in proj:
- print(
- 'Proj {} must be installed in Conda environment "{}".'.format(
- '.'.join(str(v) for v in PROJ_MIN_VERSION), conda),
- file=sys.stderr)
- exit(1)
-
- try:
- proj_version = subprocess.check_output([proj],
- stderr=subprocess.STDOUT)
- proj_version = proj_version.split()[1].split(b'.')
- proj_version = tuple(int(v.strip(b',')) for v in proj_version)
- except (OSError, IndexError, ValueError, subprocess.CalledProcessError):
- warnings.warn(
- 'Unable to determine Proj version. Ensure you have %s or later '
- 'installed, or installation may fail.' % (
- '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
- proj_version = (0, 0, 0)
-
- return proj_version
-
-
-def get_proj_libraries():
- """
- This function gets the PROJ libraries to cythonize with
- """
- proj_libraries = ["proj"]
- if os.name == "nt" and (6, 0, 0) <= proj_version < (6, 3, 0):
- proj_libraries = [
- "proj_{}_{}".format(proj_version[0], proj_version[1])
- ]
- return proj_libraries
-
-
-conda = os.getenv('CONDA_DEFAULT_ENV')
-if conda is not None and conda in sys.prefix:
- # Conda does not provide pkg-config compatibility, but the search paths
- # should be set up so that nothing extra is required. We'll still check
- # the version, though.
- proj_version = find_proj_version_by_program(conda)
- if proj_version < PROJ_MIN_VERSION:
- print(
- 'Proj version %s is installed, but cartopy requires at least '
- 'version %s.' % ('.'.join(str(v) for v in proj_version),
- '.'.join(str(v) for v in PROJ_MIN_VERSION)),
- file=sys.stderr)
- exit(1)
-
- proj_includes = []
- proj_libraries = get_proj_libraries()
- proj_library_dirs = []
-
-else:
- try:
- proj_version = subprocess.check_output(['pkg-config', '--modversion',
- 'proj'],
- stderr=subprocess.STDOUT)
- proj_version = tuple(int(v) for v in proj_version.split(b'.'))
- proj_includes = subprocess.check_output(['pkg-config', '--cflags',
- 'proj'])
- proj_clibs = subprocess.check_output(['pkg-config', '--libs', 'proj'])
- except (OSError, ValueError, subprocess.CalledProcessError):
- proj_version = find_proj_version_by_program()
- if proj_version < PROJ_MIN_VERSION:
- print(
- 'Proj version %s is installed, but cartopy requires at least '
- 'version %s.' % ('.'.join(str(v) for v in proj_version),
- '.'.join(str(v) for v in PROJ_MIN_VERSION)),
- file=sys.stderr)
- exit(1)
-
- proj_includes = []
- proj_libraries = get_proj_libraries()
- proj_library_dirs = []
- else:
- if proj_version < PROJ_MIN_VERSION:
- print(
- 'Proj version %s is installed, but cartopy requires at least '
- 'version %s.' % ('.'.join(str(v) for v in proj_version),
- '.'.join(str(v) for v in PROJ_MIN_VERSION)),
- file=sys.stderr)
- exit(1)
-
- proj_includes = [
- proj_include[2:] if proj_include.startswith('-I') else
- proj_include for proj_include in proj_includes.decode().split()]
-
- proj_libraries = []
- proj_library_dirs = []
- for entry in proj_clibs.decode().split():
- if entry.startswith('-L'):
- proj_library_dirs.append(entry[2:])
- elif entry.startswith('-l'):
- proj_libraries.append(entry[2:])
+proj_version = tuple(map(int, os.getenv("PROJ_VERSION").split(".")) )
+proj_includes = [os.getenv("PROJ_INCLUDE_DIRS")]
+proj_libraries = [os.getenv("PROJ_LIBRARIES")]
+proj_library_dirs = []
+
# Python dependencies
extras_require = {}
@@ -295,24 +197,31 @@ extensions = [
['lib/cartopy/trace.pyx'],
include_dirs=([include_dir, './lib/cartopy', np.get_include()] +
proj_includes + geos_includes),
- libraries=proj_libraries + geos_libraries,
- library_dirs=[library_dir] + proj_library_dirs + geos_library_dirs,
+ libraries=geos_libraries + ["curl", "sqlite3", "tiff"],
+ extra_objects=proj_libraries,
+ extra_link_args=["-fPIC"],
+ library_dirs=[library_dir] + geos_library_dirs,
language='c++',
**extra_extension_args),
Extension(
'cartopy._crs',
['lib/cartopy/_crs.pyx'],
include_dirs=[include_dir, np.get_include()] + proj_includes,
- libraries=proj_libraries,
- library_dirs=[library_dir] + proj_library_dirs,
+ libraries=["curl", "sqlite3", "tiff"],
+ library_dirs=[library_dir],
+ extra_objects=proj_libraries,
+ extra_link_args=["-fPIC"],
+ language='c++',
**extra_extension_args),
# Requires proj v4.9
Extension(
'cartopy.geodesic._geodesic',
['lib/cartopy/geodesic/_geodesic.pyx'],
include_dirs=[include_dir, np.get_include()] + proj_includes,
- libraries=proj_libraries,
- library_dirs=[library_dir] + proj_library_dirs,
+ libraries=["curl", "sqlite3", "tiff"],
+ library_dirs=[library_dir],
+ extra_objects=proj_libraries,
+ extra_link_args=["-fPIC"],
**extra_extension_args),
]

View file

@ -7,7 +7,7 @@
Name: python-%{srcname}
Version: 0.19.0~rc1
%global Version 0.19.0rc1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Cartographic Python library with Matplotlib visualisations
License: LGPLv3
@ -15,12 +15,31 @@ URL: http://scitools.org.uk/cartopy/docs/latest/
Source0: %pypi_source %{Srcname} %{Version}
# Set location of Fedora-provided pre-existing data.
Source1: siteconfig.py
# Bundle proj 7, it does not build against proj-8 which dropped the deprecated API
%global proj_version 7.2.1
Source2: https://download.osgeo.org/proj/proj-%{proj_version}.tar.gz
Patch0: cartopy_bundle-proj.patch
# Might not go upstream in current form.
Patch0004: 0001-Increase-tolerance-for-new-FreeType.patch
BuildRequires: gcc-c++
BuildRequires: geos-devel >= 3.3.3
BuildRequires: proj-devel >= 4.9.0
#BuildRequires: proj-devel >= 4.9.0
# For bundled proj
BuildRequires: cmake
BuildRequires: curl-devel
BuildRequires: gmock-devel
BuildRequires: gtest-devel >= 1.8.0
BuildRequires: make
BuildRequires: libtiff-devel
BuildRequires: sqlite-devel
Provides: bundled(proj) = %{proj_version}
%global _description %{expand:
Cartopy is a Python package designed to make drawing maps for data analysis
@ -90,7 +109,7 @@ Data files for %{srcname}.
%prep
%autosetup -n %{Srcname}-%{Version} -p1
%autosetup -n %{Srcname}-%{Version} -p1 -a2
cp -a %SOURCE1 lib/cartopy/
# Remove bundled egg-info
@ -98,10 +117,27 @@ rm -rf %{srcname}.egg-info
%build
pushd proj-%{proj_version}
%cmake \
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF \
-DBUILD_PROJINFO=OFF -DBUILD_PROJSYNC=OFF \
-DBUILD_GIE=OFF -DBUILD_GEOD=OFF \
-DBUILD_CS2CS=OFF -DBUILD_CCT=OFF \
-DBUILD_PROJ=OFF
%cmake_build
make -C %{_vpath_builddir} DESTDIR=../dist install
popd
PROJ_VERSION="%{proj_version}" \
PROJ_INCLUDE_DIRS=$PWD/proj-%{proj_version}/dist/%{_includedir} \
PROJ_LIBRARIES=$PWD/proj-%{proj_version}/dist/%{_libdir}/libproj.a \
FORCE_CYTHON=1 %py3_build
%install
PROJ_VERSION="%{proj_version}" \
PROJ_INCLUDE_DIRS=$PWD/proj-%{proj_version}/dist/%{_includedir} \
PROJ_LIBRARIES=$PWD/proj-%{proj_version}/dist/%{_libdir}/libproj.a \
%py3_install
mkdir -p %{buildroot}%{_datadir}/cartopy/shapefiles/natural_earth/
@ -132,6 +168,9 @@ MPLBACKEND=Agg \
%changelog
* Tue Mar 23 2021 Sandro Mani <manisandro@gmail.com> - 0.19.0~rc1-2
- Bundle proj 7, as cartopy does not build against proj8
* Sat Mar 13 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.19.0~rc1-1
- Update to latest version (#1938248)

View file

@ -1 +1,2 @@
SHA512 (Cartopy-0.19.0rc1.tar.gz) = 5b9183b08d14a2e273405b94958387af45dbeb0deda98a50814bb01a65cdcc02e476efa24a99864006d9738574abeb9140c874c11a491d9ef5491109445a06d4
SHA512 (proj-7.2.1.tar.gz) = 59b9b31b0183e620a2f4a25a08620c170773fe4f99e8eca59e9ed6815f43bb379ea21ef71e8f759dbd747855b982657d7503bac3acc542218e0d862105f25324