-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Details
- Slurm Version: 23.2.2
- Python Version: 3.6.8
- Cython Version:
- PySlurm Branch: latest
- Linux Distribution: Red Hat Enterprise Linux 8
Issue
Under certain conditions, the import of packaging.version or setuptools._vendor.packaging.version works fine, and the call to the Version() function within them works fine to return a valid Version() object, but for a stock RHEL8 install using the /usr/bin/python3 default provided by the python36 RPM, the returned object does not include the .major or .minor attributes, leading to an AttributeError being thrown in setup.py when defining the SLURM_VERSION string.
It looks like the root cause is the version of the packaging module - on the faulty instances it's version 16.8 bundled with the python36-3.6.8 RPM, but with version 21.0 in an Anaconda instance I have, and when using the RHEL8 python39 RPM's /usr/bin/python3.9 executable in which packaging is version 20.4, delivers a working result that includes the major, minor, and micro attributes.
Even the python3-packaging RPM on RHEL8, which provides packaging.version, is also version 16.8, and exhibits the same behavior leading to the AttributeError.
Here's how I tweaked the setup.py to work around the problem:
def get_version():
with (TOPDIR / "pyslurm/__version__.py").open() as f:
for line in f.read().splitlines():
if line.startswith("__version__"):
V = Version(line.split('"')[1])
if not hasattr(V, "major") or not hasattr(V, "minor"):
(V.major, V.minor) = V._version.release[0:2]
return V
raise RuntimeError("Cannot get version string.")
Given the PYTHON_MIN_REQUIRED setting of 3.6, it may be worthwhile to modify setup.py accordingly to accommodate the shortcomings of the v16.8 packaging module.