[python-shapely] 01/04: Imported Upstream version 1.6~a2
Bas Couwenberg
sebastic at debian.org
Wed Nov 9 18:16:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository python-shapely.
commit adaf670d86b76471e47db78dd6e0e1fb2fc5a229
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Wed Nov 9 18:59:25 2016 +0100
Imported Upstream version 1.6~a2
---
CHANGES.txt | 21 ++++++++++++++-
setup.py | 29 +++++++++++++++------
shapely/__init__.py | 2 +-
shapely/ctypes_declarations.py | 5 +++-
shapely/errors.py | 33 ++++++++++++++++++++++++
shapely/geometry/base.py | 7 ++---
shapely/geometry/point.py | 3 ++-
shapely/geos.py | 58 +++++++++++++++++-------------------------
tests/test_dlls.py | 3 +++
tests/test_geos_err_handler.py | 2 +-
tests/test_point.py | 2 +-
11 files changed, 113 insertions(+), 52 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 737d30c..922c051 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,25 @@
Changes
=======
+1.6a2 (2016-11-09)
+------------------
+
+Bug fixes:
+
+- Shapely no longer configures logging in ``geos.py`` (#415).
+
+Refactoring:
+
+- Consolidation of exceptions in ``shapely.errors``.
+- ``UnsupportedGEOSVersionError`` is raised when GEOS < 3.3.0 (#407).
+
+Packaging:
+
+- Added new library search paths to assist Anaconda (#413).
+- geos-config will now be bypassed when NO_GEOS_CONFIG env var is set. This
+ allows configuration of Shapely builds on Linux systems that for whatever
+ reasons do not include the geos-config program (#322).
+
1.6a1 (2016-09-14)
------------------
@@ -27,7 +46,7 @@ Refactoring:
- Switch from ``SingleSidedBuffer()`` to ``OffsetCurve()`` for GEOS >= 3.3
(#270).
-- Cython speedups are now enabled by defualt (#252).
+- Cython speedups are now enabled by default (#252).
Packaging:
diff --git a/setup.py b/setup.py
index 1e12ada..814c22b 100755
--- a/setup.py
+++ b/setup.py
@@ -116,8 +116,7 @@ class GEOSConfig(object):
match = re.match(r'(\d+)\.(\d+)\.(\d+)', self.get('--version').strip())
return tuple(map(int, match.groups()))
-
-# Get the version from the shapely module
+# Get the version from the shapely module.
shapely_version = None
with open('shapely/__init__.py', 'r') as fp:
for line in fp:
@@ -129,14 +128,18 @@ with open('shapely/__init__.py', 'r') as fp:
if not shapely_version:
raise ValueError("Could not determine Shapely's version")
+# Allow GEOS_CONFIG to be bypassed in favor of CFLAGS and LDFLAGS
+# vars set by build environment.
+if os.environ.get('NO_GEOS_CONFIG'):
+ geos_config = None
+else:
+ geos_config = GEOSConfig(os.environ.get('GEOS_CONFIG', 'geos-config'))
+
# Fail installation if the GEOS shared library does not meet the minimum
# version. We ship it with Shapely for Windows, so no need to check on
# that platform.
-
geos_version = None
-geos_config = GEOSConfig(os.environ.get('GEOS_CONFIG', 'geos-config'))
-
-if not os.environ.get('NO_GEOS_CHECK') or sys.platform == 'win32':
+if geos_config and not os.environ.get('NO_GEOS_CHECK') or sys.platform == 'win32':
try:
log.info(
"Shapely >= 1.3 requires GEOS >= 3.3. "
@@ -174,13 +177,13 @@ with open('CHANGES.txt', 'r', **open_kwds) as fp:
long_description = readme + '\n\n' + credits + '\n\n' + changes
-
extra_reqs = {
'test': ['pytest', 'pytest-cov', 'numpy>=1.4.1', 'packaging']
}
extra_reqs['all'] = list(it.chain.from_iterable(extra_reqs.values()))
-
+# Make a dict of setup arguments. Some items will be updated as
+# the script progresses.
setup_args = dict(
name = 'Shapely',
version = str(shapely_version),
@@ -244,6 +247,16 @@ library_dirs = []
libraries = []
extra_link_args = []
+# If NO_GEOS_CONFIG is set in the environment, geos-config will not
+# be called and CFLAGS and LDFLAGS environment variables must be set
+# instead like
+#
+# CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -lgeos_c"
+#
+# Or, equivalently:
+#
+# CFLAGS="$(geos-config --cflags)" LDFLAGS="$(geos-config --clibs)"
+
if geos_version and geos_config:
# Collect other options from GEOS configuration.
for item in geos_config.get('--cflags').split():
diff --git a/shapely/__init__.py b/shapely/__init__.py
index 5bb6d59..909cbfd 100644
--- a/shapely/__init__.py
+++ b/shapely/__init__.py
@@ -1 +1 @@
-__version__ = "1.6a1"
+__version__ = "1.6a2"
diff --git a/shapely/ctypes_declarations.py b/shapely/ctypes_declarations.py
index da7705a..6312ede 100644
--- a/shapely/ctypes_declarations.py
+++ b/shapely/ctypes_declarations.py
@@ -6,6 +6,8 @@ See header file: geos-x.y.z/capi/geos_c.h
from ctypes import CFUNCTYPE, POINTER, c_void_p, c_char_p, \
c_size_t, c_byte, c_uint, c_int, c_double, py_object
+from .errors import UnsupportedGEOSVersionError
+
EXCEPTION_HANDLER_FUNCTYPE = CFUNCTYPE(None, c_char_p, c_void_p)
@@ -25,7 +27,8 @@ def prototype(lgeos, geos_version):
"""
if not geos_version >= (3, 3, 0):
- raise RuntimeError("Shapely requires GEOS version 3.3.0 or newer.")
+ raise UnsupportedGEOSVersionError(
+ "Shapely requires GEOS version 3.3.0 or newer.")
# Initialization, cleanup, version.
diff --git a/shapely/errors.py b/shapely/errors.py
new file mode 100644
index 0000000..8166f5a
--- /dev/null
+++ b/shapely/errors.py
@@ -0,0 +1,33 @@
+"""Shapely errors."""
+
+
+class ShapelyError(Exception):
+ """Base error class."""
+
+
+class UnsupportedGEOSVersionError(ShapelyError):
+ """Raised when the system's GEOS library version is unsupported."""
+
+
+class ReadingError(ShapelyError):
+ """A WKT or WKB reading error."""
+
+
+class WKBReadingError(ReadingError):
+ """A WKB reading error."""
+
+
+class WKTReadingError(ReadingError):
+ """A WKT reading error."""
+
+
+class DimensionError(ShapelyError):
+ """An error in the number of coordinate dimensions."""
+
+
+class TopologicalError(ShapelyError):
+ """A geometry is invalid or topologically incorrect."""
+
+
+class PredicateError(ShapelyError):
+ """A geometric predicate has failed to return True/False."""
diff --git a/shapely/geometry/base.py b/shapely/geometry/base.py
index 6f8a3a0..7f64c78 100644
--- a/shapely/geometry/base.py
+++ b/shapely/geometry/base.py
@@ -15,9 +15,10 @@ from warnings import warn
from shapely.affinity import affine_transform
from shapely.coords import CoordinateSequence
+from shapely.errors import WKBReadingError, WKTReadingError
from shapely.ftools import wraps
from shapely.geos import WKBWriter, WKTWriter
-from shapely.geos import lgeos, ReadingError
+from shapely.geos import lgeos
from shapely.impl import DefaultImplementation, delegated
@@ -100,7 +101,7 @@ def geom_from_wkt(data):
data = data.encode('ascii')
geom = lgeos.GEOSGeomFromWKT(c_char_p(data))
if not geom:
- raise ReadingError(
+ raise WKTReadingError(
"Could not create geometry because of errors while reading input.")
return geom_factory(geom)
@@ -116,7 +117,7 @@ def geom_to_wkt(ob):
def deserialize_wkb(data):
geom = lgeos.GEOSGeomFromWKB_buf(c_char_p(data), c_size_t(len(data)))
if not geom:
- raise ReadingError(
+ raise WKBReadingError(
"Could not create geometry because of errors while reading input.")
return geom
diff --git a/shapely/geometry/point.py b/shapely/geometry/point.py
index e355839..0b8720b 100644
--- a/shapely/geometry/point.py
+++ b/shapely/geometry/point.py
@@ -5,7 +5,8 @@ from ctypes import c_double
from ctypes import cast, POINTER
from shapely.coords import required
-from shapely.geos import lgeos, DimensionError
+from shapely.errors import DimensionError
+from shapely.geos import lgeos
from shapely.geometry.base import BaseGeometry, geos_geom_from_py
from shapely.geometry.proxy import CachingGeometryProxy
diff --git a/shapely/geos.py b/shapely/geos.py
index 190f909..3cff7f1 100644
--- a/shapely/geos.py
+++ b/shapely/geos.py
@@ -14,18 +14,12 @@ import sys
import threading
from .ctypes_declarations import prototype, EXCEPTION_HANDLER_FUNCTYPE
+from .errors import WKBReadingError, WKTReadingError, TopologicalError, PredicateError
from . import ftools
# Add message handler to this module's logger
LOG = logging.getLogger(__name__)
-ch = logging.StreamHandler()
-LOG.addHandler(ch)
-
-if 'all' in sys.warnoptions:
- # show GEOS messages in console with: python -W all
- LOG.setLevel(logging.DEBUG)
-
# Find and load the GEOS and C libraries
# If this ever gets any longer, we'll break it into separate modules
@@ -72,8 +66,13 @@ if sys.platform.startswith('linux'):
_lgeos = CDLL(geos_whl_so[0])
LOG.debug("Found GEOS DLL: %r, using it.", _lgeos)
else:
- _lgeos = load_dll(
- 'geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
+ alt_paths = [
+ 'libgeos_c.so.1',
+ 'libgeos_c.so',
+ # anaconda
+ os.path.join(sys.prefix, "lib", "libgeos_c.so"),
+ ]
+ _lgeos = load_dll('geos_c', fallbacks=alt_paths)
free = load_dll('c').free
free.argtypes = [c_void_p]
free.restype = None
@@ -102,6 +101,8 @@ elif sys.platform == 'darwin':
os.path.join(sys._MEIPASS, 'libgeos_c.1.dylib'))
else:
alt_paths = [
+ # anaconda
+ os.path.join(sys.prefix, "lib", "libgeos_c.dylib"),
# The Framework build from Kyng Chaos
"/Library/Frameworks/GEOS.framework/Versions/Current/GEOS",
# macports
@@ -119,13 +120,15 @@ elif sys.platform == 'win32':
os.path.join(os.path.dirname(__file__), 'DLLs'))
if hasattr(sys, "frozen"):
wininst_dlls = os.path.normpath(
- os.path.abspath(sys.executable+'../../DLLS'))
+ os.path.abspath(sys.executable + '../../DLLS'))
else:
wininst_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
original_path = os.environ['PATH']
os.environ['PATH'] = "%s;%s;%s" % \
(egg_dlls, wininst_dlls, original_path)
- _lgeos = CDLL("geos_c.dll")
+ _lgeos = load_dll("geos_c.dll", fallbacks=[
+ os.path.join(sys.prefix, "Library", "lib", "geos_c.dll"),
+ ])
except (ImportError, WindowsError, OSError):
raise
@@ -199,24 +202,6 @@ if geos_version >= (3, 1, 0):
[EXCEPTION_HANDLER_FUNCTYPE, EXCEPTION_HANDLER_FUNCTYPE]
_lgeos.finishGEOS_r.argtypes = [c_void_p]
-# Exceptions
-
-
-class ReadingError(Exception):
- pass
-
-
-class DimensionError(Exception):
- pass
-
-
-class TopologicalError(Exception):
- pass
-
-
-class PredicateError(Exception):
- pass
-
def handler(level):
"""Error handler
@@ -275,8 +260,9 @@ class WKTReader(object):
text = text.encode('ascii')
geom = self._lgeos.GEOSWKTReader_read(self._reader, c_char_p(text))
if not geom:
- raise ReadingError("Could not create geometry because of errors "
- "while reading input.")
+ raise WKTReadingError(
+ "Could not create geometry because of errors "
+ "while reading input.")
# avoid circular import dependency
from shapely.geometry.base import geom_factory
return geom_factory(geom)
@@ -415,8 +401,9 @@ class WKBReader(object):
geom = self._lgeos.GEOSWKBReader_read(
self._reader, c_char_p(data), c_size_t(len(data)))
if not geom:
- raise ReadingError("Could not create geometry because of errors "
- "while reading input.")
+ raise WKBReadingError(
+ "Could not create geometry because of errors "
+ "while reading input.")
# avoid circular import dependency
from shapely import geometry
return geometry.base.geom_factory(geom)
@@ -428,8 +415,9 @@ class WKBReader(object):
geom = self._lgeos.GEOSWKBReader_readHEX(
self._reader, c_char_p(data), c_size_t(len(data)))
if not geom:
- raise ReadingError("Could not create geometry because of errors "
- "while reading input.")
+ raise WKBReadingError(
+ "Could not create geometry because of errors "
+ "while reading input.")
# avoid circular import dependency
from shapely import geometry
return geometry.base.geom_factory(geom)
diff --git a/tests/test_dlls.py b/tests/test_dlls.py
index 306e94f..35f9cc2 100644
--- a/tests/test_dlls.py
+++ b/tests/test_dlls.py
@@ -1,4 +1,5 @@
import sys
+import os
from . import unittest
from shapely.geos import load_dll
@@ -11,8 +12,10 @@ class LoadingTestCase(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "FIXME: adapt test for win32")
def test_fallbacks(self):
load_dll('geos_c', fallbacks=[
+ os.path.join(sys.prefix, "lib", "libgeos_c.dylib"), # anaconda (Mac OS X)
'/opt/local/lib/libgeos_c.dylib', # MacPorts
'/usr/local/lib/libgeos_c.dylib', # homebrew (Mac OS X)
+ os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux)
'libgeos_c.so.1',
'libgeos_c.so'])
diff --git a/tests/test_geos_err_handler.py b/tests/test_geos_err_handler.py
index 1ef79ae..b4b11ce 100644
--- a/tests/test_geos_err_handler.py
+++ b/tests/test_geos_err_handler.py
@@ -3,7 +3,7 @@ import logging
import pytest
from shapely.geometry import LineString
-from shapely.geos import ReadingError
+from shapely.errors import ReadingError
from shapely.wkt import loads
diff --git a/tests/test_point.py b/tests/test_point.py
index 01a091b..d481a3a 100644
--- a/tests/test_point.py
+++ b/tests/test_point.py
@@ -1,6 +1,6 @@
from . import unittest, numpy
from shapely.geometry import Point, asPoint
-from shapely.geos import DimensionError
+from shapely.errors import DimensionError
class LineStringTestCase(unittest.TestCase):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-shapely.git
More information about the Pkg-grass-devel
mailing list