Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cothread version parsing to handle suffixes #31

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/python/epicscorelibs/path/cothread.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ def check_cothread_order():
if "cothread" not in sys.modules:
return
cothread = sys.modules.get("cothread")

ver = ()
for c in cothread.__version__.split("."):
try:
ver = ver + (int(c), )
except ValueError:
# Ignore setuptools_scm auto-generated trailing parts of a version number e.g. "2.20.1.dev1+g82e2778.d20241105"
pass

# >= 2.16 will attempt to import this module
ver = tuple(int(c) for c in cothread.__version__.split("."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the first two (or three?) pieces will always be integers, maybe some slicing would be simpler?

ver = tuple(int(c) for c in cothread.__version__.split(".")[:2])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed much cleaner. Implemented in 811a856.

if ver < (2, 16):
warnings.warn("epicscorelibs.path.cothread must be imported before cothread.catools to have effect")

Expand Down
Loading