diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9731a30b..72f46064 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 23f5c229..259b2d43 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) diff --git a/testing/test_integration.py b/testing/test_integration.py index 40372b52..24ed88e0 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)"})