diff --git a/eessi/testsuite/__init__.py b/eessi/testsuite/__init__.py index 17ab1996..84336a41 100644 --- a/eessi/testsuite/__init__.py +++ b/eessi/testsuite/__init__.py @@ -38,14 +38,14 @@ with file: for line in file: stripped_line = line.strip() - + # Check if we're entering the [tool.setuptools_scm] section if stripped_line == "[tool.setuptools_scm]": in_setuptools_scm_section = True elif stripped_line.startswith("[") and in_setuptools_scm_section: # We've reached a new section, so stop searching break - + # If we're in the right section, look for the fallback_version key if in_setuptools_scm_section and stripped_line.startswith("fallback_version"): # Extract the value after the '=' sign and strip any surrounding quotes or whitespace @@ -62,8 +62,8 @@ print(msg) except FileNotFoundError: msg = "File %s not found when trying to extract the EESSI test suite version from" % pyproject_toml - msg += " pyproject.toml. This should never happen. Please report an issue on GitHub, including information on how you" - msg += " installed the EESSI test suite." + msg += " pyproject.toml. This should never happen. Please report an issue on GitHub," + msg += " including information on how you installed the EESSI test suite." print(msg) except Exception as e: print("When trying to open file %s, an exception was raised: %s." % (pyproject_toml, e)) diff --git a/setup.py b/setup.py index 5b2d1b83..4abac759 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,13 @@ import sys import pkg_resources +def get_version_by_import(): + # Add the fallback version to whatever was set for scm_dict + sys.path.append('.') + from eessi.testsuite import __version__ + return __version__ + + # Get python version python_version = sys.version_info @@ -26,23 +33,10 @@ setuptools_scm_requirement = 'setuptools_scm>=4.0.0,<=4.1.2' scm_dict = {'write_to': version_file_path, 'write_to_template': '__version__ = "{version}"'} - -# if python_version < (3, 8): -# scm_dict = {'write_to': 'eessi/testsuite/_version.py'} -# scm_require = ['packaging<=21.3', 'setuptools_scm<7'] -# scm_arg_key = "write_to" -# else: -# scm_dict = {'version_file': 'eessi/testsuite/_version.py', 'fallback_version': '80.0.0'} -# scm_require = ['setuptools>=61', 'setuptools_scm>=8'] -# scm_arg_key = "version_file" - -# Add the fallback version to whatever was set for scm_dict -sys.path.append('.') -from eessi.testsuite import __version__ -scm_dict['fallback_version'] = __version__ +# Set the fallback_version for scm based on what eessi.testsuite.__version__ returns +scm_dict['fallback_version'] = get_version_by_import() setuptools.setup( -# use_scm_version={scm_arg_key: 'eessi/testsuite/_version.py', 'fallback_version': __version__}, use_scm_version=scm_dict, setup_requires=[setuptools_scm_requirement], )