Skip to content

Commit c0522fe

Browse files
committed
Create nbstata/_version_helper.py
1 parent 9ab15fc commit c0522fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

nbstata/_version_helper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Version helpers that avoid distutils and runtime pkg_resources.
3+
"""
4+
from __future__ import annotations
5+
from packaging.version import Version, InvalidVersion
6+
7+
def version_at_least(v: str, minimum: str) -> bool:
8+
"""
9+
Return True if version string v >= minimum using robust PEP 440 parsing.
10+
Replaces pkg_resources.parse_version / distutils.LooseVersion.
11+
"""
12+
try:
13+
return Version(v) >= Version(minimum)
14+
except InvalidVersion:
15+
# Conservative fallback: treat unknown as not meeting the minimum
16+
return False

0 commit comments

Comments
 (0)