Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'match' in _parse_version_tag #906

Closed
jaap3 opened this issue Sep 20, 2023 · 2 comments · Fixed by #909
Closed

AttributeError: 'str' object has no attribute 'match' in _parse_version_tag #906

jaap3 opened this issue Sep 20, 2023 · 2 comments · Fixed by #909
Labels

Comments

@jaap3
Copy link
Contributor

jaap3 commented Sep 20, 2023

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):

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?

@RonnyPfannschmidt
Copy link
Contributor

thats the workaround, that its not done in the integration is a bug

note that setup_requires should no longer be used

@jaap3
Copy link
Contributor Author

jaap3 commented Sep 20, 2023

Thanks for the quick follow up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants