From c80879c326d12e5b96780f260aa02c080a74ee5a Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 17 Feb 2023 16:03:17 -0500 Subject: [PATCH 1/2] Disable shapely --- arcade/geometry/__init__.py | 18 +++++++++++++----- arcade/paths.py | 9 +++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/arcade/geometry/__init__.py b/arcade/geometry/__init__.py index 912790991..43c8eedb3 100644 --- a/arcade/geometry/__init__.py +++ b/arcade/geometry/__init__.py @@ -8,19 +8,27 @@ are_lines_intersecting, is_point_in_box, ) -try: + +# Shapely is disabled due to https://github.com/pythonarcade/arcade/pull/1535 +# We are leaving the code in-place to make it easier for someone to revisit +# in the future and improve shapely's performance. +use_shapely = False +# try: +# import shapely # noqa: F401 +# use_shapely = True +# except ImportError: +# use_shapely = False + +if use_shapely: from .geometry_shapely import ( are_polygons_intersecting, is_point_in_polygon, ) - shapely_installed = True -except ImportError: +else: from .geometry_python import ( are_polygons_intersecting, is_point_in_polygon, ) - shapely_installed = False - __all__ = [ "are_polygons_intersecting", diff --git a/arcade/paths.py b/arcade/paths.py index 2d7505b81..c3bfb1361 100644 --- a/arcade/paths.py +++ b/arcade/paths.py @@ -6,12 +6,17 @@ from arcade import check_for_collision_with_list, SpriteList, Sprite from typing import Union, List, Tuple, Set, Optional -if 'shapely' in sys.modules: +use_shapely = False +try: + import shapely # noqa: F401 + use_shapely = True +except ImportError: + use_shapely = False +if use_shapely: from .paths_shapely import has_line_of_sight # noqa: F401 else: from .paths_python import has_line_of_sight # noqa: F401 - def _spot_is_blocked(position: Point, moving_sprite: Sprite, blocking_sprites: SpriteList) -> bool: From 1c7784cf4608f76bc7e917114bb081748f12637b Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Mon, 6 Mar 2023 11:40:50 -0500 Subject: [PATCH 2/2] cleanup --- arcade/geometry/__init__.py | 1 - arcade/paths.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/arcade/geometry/__init__.py b/arcade/geometry/__init__.py index 43c8eedb3..7f7fca78c 100644 --- a/arcade/geometry/__init__.py +++ b/arcade/geometry/__init__.py @@ -18,7 +18,6 @@ # use_shapely = True # except ImportError: # use_shapely = False - if use_shapely: from .geometry_shapely import ( are_polygons_intersecting, diff --git a/arcade/paths.py b/arcade/paths.py index c3bfb1361..e441dba38 100644 --- a/arcade/paths.py +++ b/arcade/paths.py @@ -1,12 +1,10 @@ """ Classic A-star algorithm for path finding. """ -import sys from arcade.types import Point from arcade import check_for_collision_with_list, SpriteList, Sprite from typing import Union, List, Tuple, Set, Optional -use_shapely = False try: import shapely # noqa: F401 use_shapely = True