Skip to content

Commit ffc9e37

Browse files
committed
Make geomet an optional dependency at runtime
1 parent 932b535 commit ffc9e37

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
======
33
Not released
44

5+
Features
6+
--------
7+
* Make geomet an optional dependency at runtime (PYTHON-1237)
8+
59
Bug Fixes
610
---------
711
* Unable to connect to a cloud cluster using Ubuntu 20.04 (PYTHON-1238)
812

13+
Others
14+
------
15+
* Bump geomet dependency version to 0.2 (PYTHON-1243)
16+
917
3.23.0
1018
======
1119
April 6, 2020

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ pipeline {
552552
}
553553

554554
triggers {
555-
parameterizedCron((branchPatternCron.matcher(env.BRANCH_NAME).matches() && !riptanoPatternCron.matcher(env.GIT_URL).find()) ? """
555+
parameterizedCron((branchPatternCron.matcher(env.BRANCH_NAME).matches() && !riptanoPatternCron.matcher(GIT_URL).find()) ? """
556556
# Every weeknight (Monday - Friday) around 4:00 AM
557557
# These schedules will run with and without Cython enabled for Python v2.7.14 and v3.5.6
558558
H 4 * * 1-5 %CI_SCHEDULE=WEEKNIGHTS;EVENT_LOOP_MANAGER=LIBEV;CI_SCHEDULE_PYTHON_VERSION=2.7.14;CI_SCHEDULE_SERVER_VERSION=2.2 3.11 dse-5.1 dse-6.0 dse-6.7
@@ -600,7 +600,7 @@ pipeline {
600600
EVENT_LOOP_MANAGER = "${params.EVENT_LOOP_MANAGER.toLowerCase()}"
601601
EXECUTE_LONG_TESTS = "${params.EXECUTE_LONG_TESTS ? 'True' : 'False'}"
602602
CCM_ENVIRONMENT_SHELL = '/usr/local/bin/ccm_environment.sh'
603-
CCM_MAX_HEAP_SIZE = '1024M'
603+
CCM_MAX_HEAP_SIZE = '1536M'
604604
}
605605

606606
stages {

cassandra/util.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@
1717
import datetime
1818
from functools import total_ordering
1919
import logging
20-
from geomet import wkt
2120
from itertools import chain
2221
import random
2322
import re
2423
import six
2524
import uuid
2625
import sys
2726

27+
_HAS_GEOMET = True
28+
try:
29+
from geomet import wkt
30+
except:
31+
_HAS_GEOMET = False
32+
33+
34+
from cassandra import DriverException
35+
2836
DATETIME_EPOC = datetime.datetime(1970, 1, 1)
2937
UTC_DATETIME_EPOC = datetime.datetime.utcfromtimestamp(0)
3038

@@ -35,6 +43,7 @@
3543
assert sys.byteorder in ('little', 'big')
3644
is_little_endian = sys.byteorder == 'little'
3745

46+
3847
def datetime_from_timestamp(timestamp):
3948
"""
4049
Creates a timezone-agnostic datetime from timestamp (in seconds) in a consistent manner.
@@ -1308,6 +1317,9 @@ def from_wkt(s):
13081317
"""
13091318
Parse a Point geometry from a wkt string and return a new Point object.
13101319
"""
1320+
if not _HAS_GEOMET:
1321+
raise DriverException("Geomet is required to deserialize a wkt geometry.")
1322+
13111323
try:
13121324
geom = wkt.loads(s)
13131325
except ValueError:
@@ -1363,6 +1375,9 @@ def from_wkt(s):
13631375
"""
13641376
Parse a LineString geometry from a wkt string and return a new LineString object.
13651377
"""
1378+
if not _HAS_GEOMET:
1379+
raise DriverException("Geomet is required to deserialize a wkt geometry.")
1380+
13661381
try:
13671382
geom = wkt.loads(s)
13681383
except ValueError:
@@ -1444,6 +1459,9 @@ def from_wkt(s):
14441459
"""
14451460
Parse a Polygon geometry from a wkt string and return a new Polygon object.
14461461
"""
1462+
if not _HAS_GEOMET:
1463+
raise DriverException("Geomet is required to deserialize a wkt geometry.")
1464+
14471465
try:
14481466
geom = wkt.loads(s)
14491467
except ValueError:

tests/unit/advanced/test_geometry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from cassandra.cqltypes import lookup_casstype
2323
from cassandra.protocol import ProtocolVersion
2424
from cassandra.cqltypes import PointType, LineStringType, PolygonType, WKBGeometryType
25-
from cassandra.util import Point, LineString, Polygon, _LinearRing, Distance
25+
from cassandra.util import Point, LineString, Polygon, _LinearRing, Distance, _HAS_GEOMET
2626

2727
wkb_be = 0
2828
wkb_le = 1
@@ -104,7 +104,7 @@ def test_eq(self):
104104
# specifically use assertFalse(eq) to make sure we're using the geo __eq__ operator
105105
self.assertFalse(geo == object())
106106

107-
107+
@unittest.skipUnless(_HAS_GEOMET, "Skip wkt geometry tests when geomet is not installed")
108108
class WKTTest(unittest.TestCase):
109109

110110
def test_line_parse(self):

0 commit comments

Comments
 (0)