Skip to content

Commit

Permalink
Make things conditional on version of setuptools_scm directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Caspar van Leeuwen committed Sep 20, 2024
1 parent 536a444 commit 84178cd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import sys
import setuptools
import pkg_resources

# write_to got replaced by version_file starting from setuptools_scm v8.
# This version is only supported for python 3.8 and above
def get_setuptools_scm_version():
try:
scm_version = pkg_resources.get_distribution("setuptools_scm").version
return tuple(map(int, scm_version.split(".")[:2])) # Convert version string to tuple, e.g., (8, 0)
except pkg_resources.DistributionNotFound:
return (0, 0) # If setuptools_scm is not found, assume version 0.0

scm_version = get_setuptools_scm_version()

python_version = sys.version_info
if python_version < (3, 8):
scm_arg_key = "write_to"
else:
if scm_version >= (8, 0):
scm_arg_key = "version_file"
else:
scm_arg_key = "write_to"

setuptools.setup(
use_scm_version={scm_arg_key: "eessi/testsuite/_version.py"},
Expand Down

0 comments on commit 84178cd

Please sign in to comment.