From b3fc63d63b13f16122a69e5b65bf2570e454263a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gr=C3=BCning?= Date: Fri, 25 Aug 2023 16:12:17 +1000 Subject: [PATCH] start of fixing the packaging version --- tpv/core/helpers.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tpv/core/helpers.py b/tpv/core/helpers.py index f4e67c9..898032e 100644 --- a/tpv/core/helpers.py +++ b/tpv/core/helpers.py @@ -1,4 +1,10 @@ -import packaging.version +try: + from galaxy.tool_util.version import parse_version +except ImportError: + # Fallback to an older `packaging` version when Galaxy < 23.1. + # If Galaxy is < 23.1 you need to have `packaging` in <= 21.3 + from packaging.version import parse as parse_version + import random from functools import reduce from galaxy import model @@ -89,20 +95,20 @@ def tag_values_match(entity, match_tag_values=[], exclude_tag_values=[]): def tool_version_eq(tool, version): - return packaging.version.parse(tool.version) == packaging.version.parse(version) + return parse_version(tool.version) == parse_version(version) def tool_version_lte(tool, version): - return packaging.version.parse(tool.version) <= packaging.version.parse(version) + return parse_version(tool.version) <= parse_version(version) def tool_version_lt(tool, version): - return packaging.version.parse(tool.version) < packaging.version.parse(version) + return parse_version(tool.version) < parse_version(version) def tool_version_gte(tool, version): - return packaging.version.parse(tool.version) >= packaging.version.parse(version) + return parse_version(tool.version) >= parse_version(version) def tool_version_gt(tool, version): - return packaging.version.parse(tool.version) > packaging.version.parse(version) + return parse_version(tool.version) > parse_version(version)