Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=42,<=81.0.0", "wheel"]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
33 changes: 25 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import setuptools
import re
import sys
import pkg_resources

import setuptools


def version_at_least(version, minimum):
def normalize(value):
return [
(0, int(part)) if part.isdigit() else (1, part.lower())
for part in re.split(r"[._+-]", value)
if part
]

version_parts = normalize(version)
minimum_parts = normalize(minimum)
length = max(len(version_parts), len(minimum_parts))
version_parts += [(0, 0)] * (length - len(version_parts))
minimum_parts += [(0, 0)] * (length - len(minimum_parts))
return version_parts >= minimum_parts


def get_version_by_import():
Expand All @@ -16,21 +33,21 @@ def get_version_by_import():
# Get setuptools version
# We control it when installing from pyproject.toml, but not when installing from setup.py / setup.cfg
# Check setuptools version
current_setuptools_version = pkg_resources.parse_version(pkg_resources.get_distribution("setuptools").version)
current_setuptools_version = setuptools.__version__

# Set the version requirement for setuptools_scm, depending on the combination of Python and setuptools version
version_file_path = 'eessi/testsuite/_version.py'
scm_dict = {'write_to': version_file_path}
if python_version >= (3, 8) and current_setuptools_version >= pkg_resources.parse_version("61.0.0"):
if python_version >= (3, 8) and version_at_least(current_setuptools_version, "61.0.0"):
setuptools_scm_requirement = 'setuptools_scm>8.0.0,<=8.1.0'
scm_dict = {'version_file': version_file_path}
elif python_version >= (3, 7) and current_setuptools_version >= pkg_resources.parse_version("45.0.0"):
elif python_version >= (3, 7) and version_at_least(current_setuptools_version, "45.0.0"):
setuptools_scm_requirement = 'setuptools_scm>7.0.0,<=7.1.0'
elif python_version >= (3, 6) and current_setuptools_version >= pkg_resources.parse_version("45.0.0"):
elif python_version >= (3, 6) and version_at_least(current_setuptools_version, "45.0.0"):
setuptools_scm_requirement = 'setuptools_scm>=6.0.0,<=6.4.2'
elif python_version >= (3, 6) and current_setuptools_version >= pkg_resources.parse_version("42.0.0"):
elif python_version >= (3, 6) and version_at_least(current_setuptools_version, "42.0.0"):
setuptools_scm_requirement = 'setuptools_scm>=5.0.0,<=5.0.2'
elif python_version >= (3, 6) and current_setuptools_version >= pkg_resources.parse_version("34.4.0"):
elif python_version >= (3, 6) and version_at_least(current_setuptools_version, "34.4.0"):
setuptools_scm_requirement = 'setuptools_scm>=4.0.0,<=4.1.2'

# Set the fallback_version for scm based on what eessi.testsuite.__version__ returns
Expand Down