From ea36f8dd1615a5e331746158c3da2d0471b34c85 Mon Sep 17 00:00:00 2001 From: Alexander Wells <79699091+AlexanderWells-diamond@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:02:08 +0000 Subject: [PATCH] Fix cothread version parsing to handle suffixes (#31) Fix cothread version parsing to handle suffixes These suffixes are auto-generated from setuptools_scm, and are not usually just integers --- src/python/epicscorelibs/path/cothread.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python/epicscorelibs/path/cothread.py b/src/python/epicscorelibs/path/cothread.py index fac53efa0..3888d8791 100644 --- a/src/python/epicscorelibs/path/cothread.py +++ b/src/python/epicscorelibs/path/cothread.py @@ -18,8 +18,14 @@ def check_cothread_order(): if "cothread" not in sys.modules: return cothread = sys.modules.get("cothread") + + # Slice to first two elements to avoid attempting to parse certain types + # of auto-generated version numbers that are generated from setuptools_scm + # inside of cothread. e.g. trying to install directly from Github yields a + # version like "2.20.1.dev1+g82e2778.d20241105". + ver = tuple(int(c) for c in cothread.__version__.split(".")[:2]) + # >= 2.16 will attempt to import this module - ver = tuple(int(c) for c in cothread.__version__.split(".")) if ver < (2, 16): warnings.warn("epicscorelibs.path.cothread must be imported before cothread.catools to have effect")