summaryrefslogtreecommitdiff
path: root/django/libgeos.patch
diff options
context:
space:
mode:
authorJoseph Curtin <jcurtin@stsci.edu>2020-02-07 05:50:44 -0500
committerJoseph Curtin <jcurtin@stsci.edu>2020-02-07 05:50:44 -0500
commit4f9c218e26b61e04730fb8deae5d1e659f2dca82 (patch)
treee9c359cac0bb1814b4ce1f47b075cd9fdfa42e3c /django/libgeos.patch
parente3b50df58392e1a0281fe947e69870bc8cae6143 (diff)
downloadastroconda-etc-4f9c218e26b61e04730fb8deae5d1e659f2dca82.tar.gz
Updated Django to version 2.2.9
Diffstat (limited to 'django/libgeos.patch')
-rw-r--r--django/libgeos.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/django/libgeos.patch b/django/libgeos.patch
new file mode 100644
index 0000000..6c8c8d6
--- /dev/null
+++ b/django/libgeos.patch
@@ -0,0 +1,77 @@
+--- Django-2.0.orig/django/contrib/gis/geos/libgeos.py 2017-12-02 12:36:16.000000000 -0200
++++ Django-2.0/django/contrib/gis/geos/libgeos.py 2017-12-06 08:12:35.806014360 -0200
+@@ -8,8 +8,8 @@
+ """
+ import logging
+ import os
++import sys
+ from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p
+-from ctypes.util import find_library
+
+ from django.core.exceptions import ImproperlyConfigured
+ from django.utils.functional import SimpleLazyObject, cached_property
+@@ -19,47 +19,27 @@
+
+
+ def load_geos():
+- # Custom library path set?
+- try:
+- from django.conf import settings
+- lib_path = settings.GEOS_LIBRARY_PATH
+- except (AttributeError, EnvironmentError,
+- ImportError, ImproperlyConfigured):
+- lib_path = None
+-
+- # Setting the appropriate names for the GEOS-C library.
+- if lib_path:
+- lib_names = None
+- elif os.name == 'nt':
+- # Windows NT libraries
+- lib_names = ['geos_c', 'libgeos_c-1']
+- elif os.name == 'posix':
+- # *NIX libraries
+- lib_names = ['geos_c', 'GEOS']
+- else:
+- raise ImportError('Unsupported OS "%s"' % os.name)
+-
+- # Using the ctypes `find_library` utility to find the path to the GEOS
+- # shared library. This is better than manually specifying each library name
+- # and extension (e.g., libgeos_c.[so|so.1|dylib].).
+- if lib_names:
+- for lib_name in lib_names:
+- lib_path = find_library(lib_name)
+- if lib_path is not None:
+- break
+-
+- # No GEOS library could be found.
+- if lib_path is None:
+- raise ImportError(
+- 'Could not find the GEOS library (tried "%s"). '
+- 'Try setting GEOS_LIBRARY_PATH in your settings.' %
+- '", "'.join(lib_names)
+- )
+ # Getting the GEOS C library. The C interface (CDLL) is used for
+ # both *NIX and Windows.
+ # See the GEOS C API source code for more details on the library function calls:
+ # http://geos.refractions.net/ro/doxygen_docs/html/geos__c_8h-source.html
+- _lgeos = CDLL(lib_path)
++ if os.name == 'posix':
++ platform = os.uname()[0]
++ if platform == 'Linux':
++ libname = 'libgeos_c.so'
++ elif platform == 'Darwin':
++ libname = 'libgeos_c.dylib'
++ _lgeos = CDLL(os.path.join(sys.prefix, 'lib', libname))
++ elif os.name == 'nt':
++ # On Windows, the GDAL binaries have some OSR routines exported with
++ # STDCALL, while others are not. Thus, the library will also need to
++ # be loaded up as WinDLL for said OSR functions that require the
++ # different calling convention.
++ libname = os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll')
++ _lgeos = CDLL(libname)
++ else:
++ raise Exception('No valid platform name. Found {}'.format(os.name))
++
+ # Here we set up the prototypes for the initGEOS_r and finishGEOS_r
+ # routines. These functions aren't actually called until they are
+ # attached to a GEOS context handle -- this actually occurs in