Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable installing with PROJ 6.0.0 #1289

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@
# along with cartopy. If not, see <https://www.gnu.org/licenses/>.
from __future__ import print_function

"""
Distribution definition for Cartopy.

"""

import setuptools
from setuptools import setup, Extension
from setuptools import Command
from setuptools import convert_path
from distutils.spawn import find_executable
from distutils.sysconfig import get_config_var
import fnmatch
import os
import subprocess
import sys
import warnings
from collections import defaultdict
from distutils.spawn import find_executable
from distutils.sysconfig import get_config_var

from setuptools import Command, Extension, convert_path, setup

import versioneer

"""
Distribution definition for Cartopy.

"""




# The existence of a PKG-INFO directory is enough to tell us whether this is a
# source installation or not (sdist).
Expand Down Expand Up @@ -235,6 +236,18 @@ def find_proj_version_by_program(conda=None):
return proj_version


def get_proj_libraries():
snowman2 marked this conversation as resolved.
Show resolved Hide resolved
"""
This function gets the PROJ libraries to cythonize with
"""
proj_libraries = ["proj"]
if os.name == "nt" and proj_version >= (6, 0, 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
Expand All @@ -250,7 +263,7 @@ def find_proj_version_by_program(conda=None):
exit(1)

proj_includes = []
proj_libraries = ['proj']
proj_libraries = get_proj_libraries()
proj_library_dirs = []

else:
Expand All @@ -273,7 +286,7 @@ def find_proj_version_by_program(conda=None):
exit(1)

proj_includes = []
proj_libraries = ['proj']
proj_libraries = get_proj_libraries()
proj_library_dirs = []
else:
if proj_version < PROJ_MIN_VERSION:
Expand Down Expand Up @@ -322,11 +335,11 @@ def get_config_var(name):
return '.'
include_dir = get_config_var('INCLUDEDIR')
library_dir = get_config_var('LIBDIR')
if sys.platform.startswith('win'):
extra_extension_args = {}
else:
extra_extension_args = dict(
runtime_library_dirs=[get_config_var('LIBDIR')])
extra_extension_args = defaultdict(list)
if not sys.platform.startswith('win'):
extra_extension_args["runtime_library_dirs"].append(
get_config_var('LIBDIR')
)

# Description
# ===========
Expand All @@ -335,10 +348,14 @@ def get_config_var(name):


cython_coverage_enabled = os.environ.get('CYTHON_COVERAGE', None)
if proj_version >= (6, 0, 0):
extra_extension_args["define_macros"].append(
('ACCEPT_USE_OF_DEPRECATED_PROJ_API_H', '1')
)
if cython_coverage_enabled:
extra_cython_args = {'define_macros': [('CYTHON_TRACE_NOGIL', '1')]}
extra_extension_args.update(extra_cython_args)

extra_extension_args["define_macros"].append(
('CYTHON_TRACE_NOGIL', '1')
)

extensions = [
Extension(
Expand Down