Skip to content

Commit 6ccff7b

Browse files
committed
support python 3.14 - by disabling spherely functionality on this platform
1 parent 94d8e96 commit 6ccff7b

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ packages = find:
3434
package_dir =
3535
= src
3636
python_requires = >=3.10
37+
# Note: spherely currently does not support python 3.14.
3738
install_requires =
3839
cldfbench
3940
clldutils
4041
pycldf>=1.30.0
4142
pyglottolog
4243
shapely
43-
spherely
44+
spherely; python_version < '3.14'
4445
rasterio
4546
mako
4647
numpy
@@ -96,7 +97,7 @@ show_missing = true
9697
skip_covered = true
9798

9899
[tox:tox]
99-
envlist = py310, py311, py312, py313
100+
envlist = py310, py311, py312, py313, py314
100101
isolated_build = true
101102
skip_missing_interpreter = true
102103

src/cldfgeojson/geometry.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
from shapely.geometry import (
1616
shape, Polygon, MultiPolygon, GeometryCollection, LineString, MultiLineString, MultiPoint)
1717
from shapely.ops import unary_union
18-
import spherely
1918
import numpy as np
2019
import antimeridian
2120

21+
try:
22+
import spherely
23+
except ImportError:
24+
spherely = None
25+
2226
from cldfgeojson import geojson
2327

2428

@@ -107,6 +111,8 @@ def fixer(shp: Geometry) -> Geometry:
107111
class SpherelyChecker:
108112
@staticmethod
109113
def is_valid(shp) -> typing.Tuple[bool, str]:
114+
if spherely is None: # pragma: no cover
115+
return True, ''
110116
try:
111117
spherely.from_wkt(shp.wkt)
112118
return True, ''
@@ -115,6 +121,8 @@ def is_valid(shp) -> typing.Tuple[bool, str]:
115121

116122
@staticmethod
117123
def fixer(shp: Geometry) -> Geometry:
124+
if spherely is None: # pragma: no cover
125+
return shp
118126
if not ShapelyChecker.is_valid(shp)[0]:
119127
raise ValueError('Cannot fix (shapely) invalid geometry')
120128
try:

tests/test_geometry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def test_fixed_geometry(recwarn):
178178

179179

180180
def test_SpherelyChecker(fixtures_dir):
181+
if spherely is None:
182+
return
181183
f = load(fixtures_dir / 'irish.geojson')
182184
_ = SpherelyChecker.fixer(shape(f['geometry']))
183185

0 commit comments

Comments
 (0)