Skip to content

Commit

Permalink
Fix flake8 complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
Caspar van Leeuwen committed Sep 24, 2024
1 parent 5dc180d commit ed1d1bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
8 changes: 4 additions & 4 deletions eessi/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
24 changes: 9 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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],
)

0 comments on commit ed1d1bd

Please sign in to comment.