Skip to content

Commit

Permalink
Fix/slurm compatibility (#30)
Browse files Browse the repository at this point in the history
Fix small incompatibilities with slurm-uenv v0.9

* handle empty `UENV_MOUNT_LIST` variable by ignoring it
* user proper semantic versioning when checking the version of
  squashfs-mount for compatibility
* bump version
  • Loading branch information
bcumming authored May 29, 2024
1 parent a41ad6e commit a18d226
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1
4.1.0
22 changes: 11 additions & 11 deletions uenv-impl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import pathlib
import sys
import subprocess
import textwrap
from packaging.version import Version

prefix = pathlib.Path(__file__).parent.resolve()
libpath = prefix / 'lib'
Expand Down Expand Up @@ -231,10 +232,7 @@ def get_uenv_version():
stdout=subprocess.PIPE,
check=True)
version = result.stdout.decode('utf-8')
# remove dev strings like `-dev`
version = version.split('-')[0]
digit = int(version.split('.')[1])
return digit
return Version(version)
except:
return None

Expand Down Expand Up @@ -264,12 +262,14 @@ class environment:
if "UENV_MOUNT_LIST" in os.environ:
# take care to strip white space and trailing commas
raw = os.environ.get("UENV_MOUNT_LIST").strip().strip(',')
mounts = raw.split(',')
for m in mounts:
# remove 'file://' prefix from string.
m = strip_image_prefix(m)
img, mnt = m.split(":")
self._uenvs.append(uenv(pathlib.Path(mnt)))
# if UENV_MOUNT_LIST is set and empty, ignore it
if len(raw)>0:
mounts = raw.split(',')
for m in mounts:
# remove 'file://' prefix from string.
m = strip_image_prefix(m)
img, mnt = m.split(":")
self._uenvs.append(uenv(pathlib.Path(mnt)))

# test for the original mount method
elif ("UENV_MOUNT_FILE" in os.environ) and ("UENV_MOUNT_POINT" in os.environ):
Expand Down Expand Up @@ -333,7 +333,7 @@ class environment:
# true if the squashfs-mount utility is too old for this version of uenv.
@property
def old_api(self):
return (not self.has_squashfs_mount) or (self._uenv_version < 5)
return (not self.has_squashfs_mount) or (self._uenv_version < Version("0.5"))

class uenv:
"""
Expand Down

0 comments on commit a18d226

Please sign in to comment.