diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 6b22b28..beb7168 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -23,6 +23,7 @@ TEMPLATES = {
 # file generated by setuptools_scm
 # don't change, don't track in version control
 version = {version!r}
+version_tuple = {version_tuple!r}
 """,
     ".txt": "{version}",
 }
@@ -80,8 +81,19 @@ def dump_version(root, version, write_to, template=None):
                 os.path.splitext(target)[1], target
             )
         )
+
+    # version_tuple: each field is converted to an int if possible or kept as string
+    fields = tuple(version.split("."))
+    version_fields = []
+    for field in fields:
+        try:
+            v = int(field)
+        except ValueError:
+            v = field
+        version_fields.append(v)
+
     with open(target, "w") as fp:
-        fp.write(template.format(version=version))
+        fp.write(template.format(version=version, version_tuple=tuple(version_fields)))
 
 
 def _do_parse(config):

enable version-tuples/lazy parsed versions in write_to contents
follow up to https://github.com/pytest-dev/pytest/pull/7605

a way to have easy static version tuples or a available layz parsed version to do version comparisation correctly is nice to have,
if only the string is there, users of a library are tempted into potentially hazardous solutions to compare versions too quick and too error prone
diff --git a/testing/test_basic_api.py b/testing/test_basic_api.py
index c5104f5..5111542 100644
--- a/testing/test_basic_api.py
+++ b/testing/test_basic_api.py
@@ -101,9 +101,13 @@ def test_dump_version(tmpdir):
 
     dump_version(sp, "1.0", "first.txt")
     assert tmpdir.join("first.txt").read() == "1.0"
-    dump_version(sp, "1.0", "first.py")
+
+    dump_version(sp, "1.0.dev42", "first.py")
     content = tmpdir.join("first.py").read()
-    assert repr("1.0") in content
+    lines = content.splitlines()
+    assert "version = '1.0.dev42'" in lines
+    assert "version_tuple = (1, 0, 'dev42')" in lines
+
     import ast
 
     ast.parse(content)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest setuptools>=42 toml six
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
-e git+https://github.com/pypa/setuptools_scm.git@1c8bb50e90520a39279f213706ad69b4f180fea1#egg=setuptools_scm
six==1.17.0
toml==0.10.2
tomli==2.2.1

name: setuptools_scm
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - setuptools-scm==4.1.3.dev4+g1c8bb50
      - six==1.17.0
      - toml==0.10.2
      - tomli==2.2.1
prefix: /opt/conda/envs/setuptools_scm

testing/test_basic_api.py::test_dump_version
testing/test_basic_api.py::test_do[ls] testing/test_basic_api.py::test_do[dir] testing/test_basic_api.py::test_data_from_mime testing/test_basic_api.py::test_version_from_pkginfo testing/test_basic_api.py::test_root_parameter_creation testing/test_basic_api.py::test_version_from_scm testing/test_basic_api.py::test_root_parameter_pass_by testing/test_basic_api.py::test_parentdir_prefix testing/test_basic_api.py::test_fallback testing/test_basic_api.py::test_pretended[1.0] testing/test_basic_api.py::test_pretended[1.2.3.dev1+ge871260] testing/test_basic_api.py::test_pretended[1.2.3.dev15+ge871260.d20180625] testing/test_basic_api.py::test_pretended[2345] testing/test_basic_api.py::test_root_relative_to testing/test_basic_api.py::test_parse_plain_fails
src/setuptools_scm/__init__.py
src/setuptools_scm/__init__.py