Cartopy-0.17.0_fix_setup.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. Patched setup.py file, replacing the original file.
  2. June 25th 2019 by PY Barriat (ELIC - UCL)
  3. --- Cartopy/cartopy-0.17.0/setup.py.orig 2018-11-17 08:25:32.000000000 +0100
  4. +++ Cartopy/cartopy-0.17.0/setup.py 2019-06-25 14:28:37.989843991 +0200
  5. @@ -1,4 +1,4 @@
  6. -# (C) British Crown Copyright 2011 - 2018, Met Office
  7. +# (C) British Crown Copyright 2011 - 2019, Met Office
  8. #
  9. # This file is part of cartopy.
  10. #
  11. @@ -16,30 +16,41 @@
  12. # along with cartopy. If not, see <https://www.gnu.org/licenses/>.
  13. from __future__ import print_function
  14. -"""
  15. -Distribution definition for Cartopy.
  16. -
  17. -"""
  18. -
  19. -import setuptools
  20. -from setuptools import setup, Extension
  21. -from setuptools import Command
  22. -from setuptools import convert_path
  23. -from distutils.spawn import find_executable
  24. -from distutils.sysconfig import get_config_var
  25. import fnmatch
  26. import os
  27. import subprocess
  28. import sys
  29. import warnings
  30. +from collections import defaultdict
  31. +from distutils.spawn import find_executable
  32. +from distutils.sysconfig import get_config_var
  33. +
  34. +from setuptools import Command, Extension, convert_path, setup
  35. import versioneer
  36. +"""
  37. +Distribution definition for Cartopy.
  38. +
  39. +"""
  40. +
  41. +
  42. +
  43. +
  44. +# The existence of a PKG-INFO directory is enough to tell us whether this is a
  45. +# source installation or not (sdist).
  46. +HERE = os.path.dirname(__file__)
  47. +IS_SDIST = os.path.exists(os.path.join(HERE, 'PKG-INFO'))
  48. +
  49. +if not IS_SDIST:
  50. + import Cython
  51. + if Cython.__version__ < '0.28':
  52. + raise ImportError(
  53. + "Cython 0.28+ is required to install cartopy from source.")
  54. +
  55. + from Cython.Distutils import build_ext as cy_build_ext
  56. +
  57. -try:
  58. - from Cython.Distutils import build_ext
  59. -except ImportError:
  60. - raise ImportError('Cython 0.15.1+ is required to install cartopy.')
  61. try:
  62. import numpy as np
  63. except ImportError:
  64. @@ -52,8 +63,6 @@
  65. GEOS_MIN_VERSION = (3, 3, 3)
  66. PROJ_MIN_VERSION = (4, 9, 0)
  67. -HERE = os.path.dirname(__file__)
  68. -
  69. def file_walk_relative(top, remove=''):
  70. """
  71. @@ -172,10 +181,7 @@
  72. geos_includes = []
  73. geos_library_dirs = []
  74. - if sys.platform.startswith('win'):
  75. - geos_libraries = ['geos']
  76. - else:
  77. - geos_libraries = ['geos_c']
  78. + geos_libraries = ['geos_c']
  79. else:
  80. if geos_version < GEOS_MIN_VERSION:
  81. print('GEOS version %s is installed, but cartopy requires at least '
  82. @@ -230,6 +236,18 @@
  83. return proj_version
  84. +def get_proj_libraries():
  85. + """
  86. + This function gets the PROJ libraries to cythonize with
  87. + """
  88. + proj_libraries = ["proj"]
  89. + if os.name == "nt" and proj_version >= (6, 0, 0):
  90. + proj_libraries = [
  91. + "proj_{}_{}".format(proj_version[0], proj_version[1])
  92. + ]
  93. + return proj_libraries
  94. +
  95. +
  96. conda = os.getenv('CONDA_DEFAULT_ENV')
  97. if conda is not None and conda in sys.prefix:
  98. # Conda does not provide pkg-config compatibility, but the search paths
  99. @@ -245,7 +263,7 @@
  100. exit(1)
  101. proj_includes = []
  102. - proj_libraries = ['proj']
  103. + proj_libraries = get_proj_libraries()
  104. proj_library_dirs = []
  105. else:
  106. @@ -268,7 +286,7 @@
  107. exit(1)
  108. proj_includes = []
  109. - proj_libraries = ['proj']
  110. + proj_libraries = get_proj_libraries()
  111. proj_library_dirs = []
  112. else:
  113. if proj_version < PROJ_MIN_VERSION:
  114. @@ -283,8 +301,9 @@
  115. proj_includes = proj_includes.decode()
  116. proj_clibs = proj_clibs.decode()
  117. - proj_includes = [proj_include[2:] if proj_include.startswith('-I') else
  118. - proj_include for proj_include in proj_includes.split()]
  119. + proj_includes = [
  120. + proj_include[2:] if proj_include.startswith('-I') else
  121. + proj_include for proj_include in proj_includes.split()]
  122. proj_libraries = []
  123. proj_library_dirs = []
  124. @@ -316,21 +335,90 @@
  125. return '.'
  126. include_dir = get_config_var('INCLUDEDIR')
  127. library_dir = get_config_var('LIBDIR')
  128. -if sys.platform.startswith('win'):
  129. - extra_extension_args = {}
  130. -else:
  131. - extra_extension_args = dict(
  132. - runtime_library_dirs=[get_config_var('LIBDIR')])
  133. +extra_extension_args = defaultdict(list)
  134. +if not sys.platform.startswith('win'):
  135. + extra_extension_args["runtime_library_dirs"].append(
  136. + get_config_var('LIBDIR')
  137. + )
  138. # Description
  139. # ===========
  140. -
  141. with open(os.path.join(HERE, 'README.md'), 'r') as fh:
  142. description = ''.join(fh.readlines())
  143. +cython_coverage_enabled = os.environ.get('CYTHON_COVERAGE', None)
  144. +if proj_version >= (6, 0, 0):
  145. + extra_extension_args["define_macros"].append(
  146. + ('ACCEPT_USE_OF_DEPRECATED_PROJ_API_H', '1')
  147. + )
  148. +if cython_coverage_enabled:
  149. + extra_extension_args["define_macros"].append(
  150. + ('CYTHON_TRACE_NOGIL', '1')
  151. + )
  152. +
  153. +extensions = [
  154. + Extension(
  155. + 'cartopy.trace',
  156. + ['lib/cartopy/trace.pyx'],
  157. + include_dirs=([include_dir, './lib/cartopy', np.get_include()] +
  158. + proj_includes + geos_includes),
  159. + libraries=proj_libraries + geos_libraries,
  160. + library_dirs=[library_dir] + proj_library_dirs + geos_library_dirs,
  161. + language='c++',
  162. + **extra_extension_args),
  163. + Extension(
  164. + 'cartopy._crs',
  165. + ['lib/cartopy/_crs.pyx'],
  166. + include_dirs=[include_dir, np.get_include()] + proj_includes,
  167. + libraries=proj_libraries,
  168. + library_dirs=[library_dir] + proj_library_dirs,
  169. + **extra_extension_args),
  170. + # Requires proj v4.9
  171. + Extension(
  172. + 'cartopy.geodesic._geodesic',
  173. + ['lib/cartopy/geodesic/_geodesic.pyx'],
  174. + include_dirs=[include_dir, np.get_include()] + proj_includes,
  175. + libraries=proj_libraries,
  176. + library_dirs=[library_dir] + proj_library_dirs,
  177. + **extra_extension_args),
  178. +]
  179. +
  180. +
  181. +if cython_coverage_enabled:
  182. + # We need to explicitly cythonize the extension in order
  183. + # to control the Cython compiler_directives.
  184. + from Cython.Build import cythonize
  185. +
  186. + directives = {'linetrace': True,
  187. + 'binding': True}
  188. + extensions = cythonize(extensions, compiler_directives=directives)
  189. +
  190. +
  191. +def decythonize(extensions, **_ignore):
  192. + # Remove pyx sources from extensions.
  193. + # Note: even if there are changes to the pyx files, they will be ignored.
  194. + for extension in extensions:
  195. + sources = []
  196. + for sfile in extension.sources:
  197. + path, ext = os.path.splitext(sfile)
  198. + if ext in ('.pyx',):
  199. + if extension.language == 'c++':
  200. + ext = '.cpp'
  201. + else:
  202. + ext = '.c'
  203. + sfile = path + ext
  204. + sources.append(sfile)
  205. + extension.sources[:] = sources
  206. + return extensions
  207. +
  208. +
  209. cmdclass = versioneer.get_cmdclass()
  210. -cmdclass.update({'build_ext': build_ext})
  211. +
  212. +if IS_SDIST:
  213. + extensions = decythonize(extensions)
  214. +else:
  215. + cmdclass.update({'build_ext': cy_build_ext})
  216. # Main setup
  217. @@ -371,37 +459,9 @@
  218. # requires proj headers
  219. - ext_modules=[
  220. - Extension(
  221. - 'cartopy.trace',
  222. - ['lib/cartopy/trace.pyx', 'lib/cartopy/_trace.cpp'],
  223. - include_dirs=[include_dir,
  224. - './lib/cartopy'] + proj_includes + geos_includes,
  225. - libraries=proj_libraries + geos_libraries,
  226. - library_dirs=[library_dir] + proj_library_dirs + geos_library_dirs,
  227. - language='c++',
  228. - **extra_extension_args
  229. - ),
  230. - Extension(
  231. - 'cartopy._crs',
  232. - ['lib/cartopy/_crs.pyx'],
  233. - include_dirs=[include_dir, np.get_include()] + proj_includes,
  234. - libraries=proj_libraries,
  235. - library_dirs=[library_dir] + proj_library_dirs,
  236. - **extra_extension_args
  237. - ),
  238. - # Requires proj v4.9
  239. - Extension(
  240. - 'cartopy.geodesic._geodesic',
  241. - ['lib/cartopy/geodesic/_geodesic.pyx'],
  242. - include_dirs=[include_dir, np.get_include()] + proj_includes,
  243. - libraries=proj_libraries,
  244. - library_dirs=[library_dir] + proj_library_dirs,
  245. - **extra_extension_args
  246. - ),
  247. - ],
  248. -
  249. + ext_modules=extensions,
  250. cmdclass=cmdclass,
  251. + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
  252. classifiers=[
  253. 'Development Status :: 4 - Beta',
  254. 'License :: OSI Approved :: GNU Lesser General Public License v3 '
  255. @@ -416,9 +476,9 @@
  256. 'Programming Language :: Python :: 2',
  257. 'Programming Language :: Python :: 2.7',
  258. 'Programming Language :: Python :: 3',
  259. - 'Programming Language :: Python :: 3.3',
  260. - 'Programming Language :: Python :: 3.4',
  261. 'Programming Language :: Python :: 3.5',
  262. + 'Programming Language :: Python :: 3.6',
  263. + 'Programming Language :: Python :: 3.7',
  264. 'Topic :: Scientific/Engineering',
  265. 'Topic :: Scientific/Engineering :: GIS',
  266. 'Topic :: Scientific/Engineering :: Visualization',