Repository: pypa/setuptools_scm

Issue:
tag_regex not working with setuptools_scm 3.4.1
With setuptools_scm 3.4.1, custom tag_regex expressions are not working correctly.

My setup.py contains:

    ...
    setup_args["use_scm_version"] = {
        "tag_regex": r"^(?P<prefix>.*/)?(?P<version>\d+(?:\.\d+){1,2})$"
        }
    setup_args["setup_requires"] = ['setuptools_scm']

    setuptools.setup(**setup_args)

setuptools_scm 3.4.0 works:

    $ python3 setup.py --version
    0.4.1.dev7+gc2397c5'

With 3.4.1:

    $ python3 setup.py --version
    /home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/version.py:92: UserWarning: tag 'development/0.4.0' no version found
      warnings.warn("tag {!r} no version found".format(tag))
    Traceback (most recent call last):
    ...
      File "/home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/git.py", line 135, in parse
    branch=branch,
      File "/home/kolbus/.local/lib/python3.6/site-packages/setuptools_scm/version.py", line 205, in meta
        assert parsed_version is not None, "cant parse version %s" % tag
    AssertionError: cant parse version development/0.4.0



Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 8545f4f..5267e2b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,8 @@
+v3.4.2
+======
+
+* fix #395: correctly transfer tag regex in the Configuration constructor
+
 v3.4.1
 ======
 
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py
index 7dee1e4..139512d 100644
--- a/src/setuptools_scm/config.py
+++ b/src/setuptools_scm/config.py
@@ -66,7 +66,7 @@ class Configuration(object):
         self.fallback_version = fallback_version
         self.fallback_root = fallback_root
         self.parse = parse
-        self.tag_regex = DEFAULT_TAG_REGEX
+        self.tag_regex = tag_regex
         self.git_describe_command = git_describe_command
 
     @property


Test patch:
diff --git a/testing/test_config.py b/testing/test_config.py
index 38bc8f4..b8ea265 100644
--- a/testing/test_config.py
+++ b/testing/test_config.py
@@ -1,7 +1,7 @@
 from __future__ import unicode_literals
 
 from setuptools_scm.config import Configuration
-
+import re
 import pytest
 
 
@@ -26,3 +26,9 @@ def test_config_from_pyproject(tmpdir):
     fn = tmpdir / "pyproject.toml"
     fn.write_text("[tool.setuptools_scm]\n", encoding="utf-8")
     assert Configuration.from_file(str(fn))
+
+
+def test_config_regex_init():
+    tag_regex = re.compile(r"v(\d+)")
+    conf = Configuration(tag_regex=tag_regex)
+    assert conf.tag_regex is tag_regex