Repository: pypa/setuptools_scm

Issue:
AttributeError: 'str' object has no attribute 'match' in _parse_version_tag
Just upgraded to `setuptools_scm` 8 and am running into the following issue with a `setup.py` file that has something similar to this (the project also has a `pyproject.toml` file):

```python
from setuptools import setup

setup(
    setup_requires=["setuptools_scm"],
    ...
    use_scm_version={
       ...
        "tag_regex": r"^(?P<prefix>.+/)?(?P<version>[^\+]+)(?P<suffix>.*)?$",
    },
)
```

when executing the `setup.py` file the following error is raised:

```
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    setup(
  File "~/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
  File "~/venv/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
  File "~/venv/lib/python3.8/site-packages/setuptools/dist.py", line 303, in __init__
    _Distribution.__init__(self, dist_attrs)
  File "~/venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "~/venv/lib/python3.8/site-packages/setuptools/dist.py", line 680, in finalize_options
    ep(self)
  File "~/venv/lib/python3.8/site-packages/setuptools/dist.py", line 700, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_integration/setuptools.py", line 98, in version_keyword
    _assign_version(dist, config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_integration/setuptools.py", line 54, in _assign_version
    maybe_version = _get_version(config, force_write_version_files=True)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_get_version_impl.py", line 89, in _get_version
    parsed_version = parse_version(config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_get_version_impl.py", line 52, in parse_version
    or parse_scm_version(config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_get_version_impl.py", line 37, in parse_scm_version
    return _entrypoints.version_from_entrypoint(config, entrypoint, root)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_entrypoints.py", line 38, in version_from_entrypoint
    maybe_version: version.ScmVersion | None = fn(root, config=config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/git.py", line 201, in parse
    return _git_parse_inner(
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/git.py", line 245, in _git_parse_inner
    version = version_from_describe(wd, config, describe_command)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/git.py", line 233, in version_from_describe
    return describe_res.parse_success(parse=parse_describe)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/_run_cmd.py", line 71, in parse_success
    return parse(self.stdout)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/git.py", line 231, in parse_describe
    return meta(tag=tag, distance=distance, dirty=dirty, node=node, config=config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/version.py", line 210, in meta
    parsed_version = _parse_tag(tag, preformatted, config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/version.py", line 192, in _parse_tag
    version = tag_to_version(tag, config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/version.py", line 93, in tag_to_version
    tag_dict = _parse_version_tag(tag, config)
  File "~/venv/lib/python3.8/site-packages/setuptools_scm/version.py", line 49, in _parse_version_tag
    match = config.tag_regex.match(str(tag))
AttributeError: 'str' object has no attribute 'match'
``` 

I can work around this by compiling the `tag_regex` in `setup.py`, is that intended? 

Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 9731a30..72f4606 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,6 +6,7 @@ bugfix
 ------
 
 * update version file template to work on older python versions by using type comments
+* ensure tag regex from setup.py is parsed into regex
 
 v8.0.0
 ======
diff --git a/src/setuptools_scm/_integration/setuptools.py b/src/setuptools_scm/_integration/setuptools.py
index 23f5c22..259b2d4 100644
--- a/src/setuptools_scm/_integration/setuptools.py
+++ b/src/setuptools_scm/_integration/setuptools.py
@@ -91,9 +91,13 @@ def version_keyword(
         dist_name = read_dist_name_from_setup_cfg()
     version_cls = value.pop("version_cls", None)
     normalize = value.pop("normalize", True)
+    tag_regex = _config._check_tag_regex(
+        value.pop("tag_regex", _config.DEFAULT_TAG_REGEX)
+    )
     final_version = _validate_version_cls(version_cls, normalize)
+
     config = _config.Configuration(
-        dist_name=dist_name, version_cls=final_version, **value
+        dist_name=dist_name, version_cls=final_version, tag_regex=tag_regex, **value
     )
     _assign_version(dist, config)
 


Test patch:
diff --git a/testing/test_integration.py b/testing/test_integration.py
index 40372b5..24ed88e 100644
--- a/testing/test_integration.py
+++ b/testing/test_integration.py
@@ -169,3 +169,17 @@ def test_unicode_in_setup_cfg(tmp_path: Path) -> None:
     )
     name = setuptools_scm._integration.setuptools.read_dist_name_from_setup_cfg(cfg)
     assert name == "configparser"
+
+
+def test_setuptools_version_keyword_ensures_regex(
+    wd: WorkDir,
+    monkeypatch: pytest.MonkeyPatch,
+) -> None:
+    wd.commit_testfile("test")
+    wd("git tag 1.0")
+    monkeypatch.chdir(wd.cwd)
+    from setuptools_scm._integration.setuptools import version_keyword
+    import setuptools
+
+    dist = setuptools.Distribution({"name": "test"})
+    version_keyword(dist, "use_scm_version", {"tag_regex": "(1.0)"})