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

Problem in setup.py get_version() - packaging.version object is missing .major and .minor attributes in earlier module versions under Python 3.6 #338

Open
mvpel opened this issue Feb 14, 2024 · 0 comments

Comments

@mvpel
Copy link

mvpel commented Feb 14, 2024

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.

@mvpel mvpel changed the title Problem in setup.py get_version() - version object is missing .major and .minor attributes Problem in setup.py get_version() - packaging.version object is missing .major and .minor attributes in earlier versions under Python 3.6 Feb 14, 2024
@mvpel mvpel changed the title Problem in setup.py get_version() - packaging.version object is missing .major and .minor attributes in earlier versions under Python 3.6 Problem in setup.py get_version() - packaging.version object is missing .major and .minor attributes in earlier module versions under Python 3.6 Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant