pypa / setuptools-scm

the blessed package to manage your versions by scm tags
https://setuptools-scm.readthedocs.io/en/latest/
MIT License
854 stars 212 forks source link

"AssertionError: cant parse version" Exception at setuptools_scm-4.0.0-py3.7.egg\setuptools_scm\version.py", line 208 #449

Open ashy-cypress opened 4 years ago

ashy-cypress commented 4 years ago

Hi,

Get "AssertionError: cant parse version P64_512K_ES100_RC1" error when executing "pip install git+http://git-ore.aus.cypress.com/repo/pyocd.git@P64_512K_ES100_RC1" command, log attached. This issue is reproducable with 4.0.0 and 4.1.0, and no issue with 3.5.0. Also this is some how connected with tag string, since if i use tag "v0.14.0" it works ok. log.txt

davidjlloyd commented 4 years ago

This is happening because the default Git describe command is returning tags that are not parseable by the tag regex that you are using. You can get around this by overriding the describe command as well to only match appropriate tags, but this should really be fixed in the library. Matching literally any tag with numerical characters in has caused a lot of issues for me, the only practical course of action is to downgrade.

leandron commented 4 years ago

I'm also seeing this. Doing some troubleshooting, it looks like it will only happen if you have a non-version related tag that contains numbers. I also came up with this steps to reproduce the issue from scratch:

Create an empty git repository:

mkdir test
cd test
git init .

Then write a vanilla setup.py with setuptools_scm dependency and commit it locally:

cat >> setup.py << EOF
from setuptools import setup

setup(name='placeholdername',
  use_scm_version=True,
  setup_requires=['setuptools_scm'],
)
EOF

git add setup.py
git commit -a -m "foo"

Now, the tags. Create one or more well behaved version tags, and one non-version-related tag:

git tag v0.1.0
git tag v0.1.1
git tag dev/patch-42

Typing python setup.py --version will cause the following (as of setuptools_scm 4.1.0):

$ python setup.py --version
/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/version.py:86: UserWarning: tag 'dev/patch-42' no version found
  warnings.warn("tag {!r} no version found".format(tag))
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    setup_requires=['setuptools_scm'],
  File "/tmp/v/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/tmp/v/lib/python3.6/site-packages/setuptools/dist.py", line 426, in __init__
    k: v for k, v in attrs.items()
  File "/usr/lib/python3.6/distutils/dist.py", line 281, in __init__
    self.finalize_options()
  File "/tmp/v/lib/python3.6/site-packages/setuptools/dist.py", line 717, in finalize_options
    ep(self)
  File "/tmp/v/lib/python3.6/site-packages/setuptools/dist.py", line 724, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/integration.py", line 17, in version_keyword
    dist.metadata.version = _get_version(config)
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/__init__.py", line 148, in _get_version
    parsed_version = _do_parse(config)
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/__init__.py", line 103, in _do_parse
    version = _version_from_entrypoints(config) or _version_from_entrypoints(
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/__init__.py", line 63, in _version_from_entrypoints
    version = _call_entrypoint_fn(root, config, ep.load())
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/__init__.py", line 44, in _call_entrypoint_fn
    return fn(root, config=config)
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/git.py", line 138, in parse
    return meta(tag, config=config, node=node, dirty=dirty, branch=branch)
  File "/home/leandron/Projects/test/.eggs/setuptools_scm-4.1.0-py3.6.egg/setuptools_scm/version.py", line 208, in meta
    assert parsed_version is not None, "cant parse version %s" % tag
AssertionError: cant parse version dev/patch-42

If you change setup.py to point to version 3.5.0 by modifying it to be setup_requires=['setuptools_scm==3.5.0'],, then it works.

RonnyPfannschmidt commented 4 years ago

this is a side-effect of being more lenient with versions introduced in #412

CC @Flameeyes

as far as i can tell i'll have to disallow single digit versions again the testsuite has to be extended with tags/branches that should not match

Flameeyes commented 4 years ago

Yeah sounds like that needs to still be disallowed :( I'm not able to send pull requests this week (new company, still need paperwork done), but I'll send one to at least add the requirement to not be single-digit somewhere (and maybe remind people that SemVer is the way).

As far as I can tell only the DEFAULT_DESCRIBE should be reverted, while the regex should be fine as is?

RonnyPfannschmidt commented 4 years ago

Correct

RonnyPfannschmidt commented 4 years ago

not includin this in 4.1.1 since it takes a bit of time to create the tests - will take a look tommorow

VitaSokhatska commented 4 years ago

Is there any forecast available when this issue can be addressed?

RonnyPfannschmidt commented 4 years ago

with #453 a bugfix will be released very soon, the issue will stay open until regression tests are added (which may take a bit as i'm in the middle of a move) i'd appreciate a pr

RonnyPfannschmidt commented 4 years ago

a bugfix has been released, keeping tihs open

TheTechRobo commented 4 years ago

I use tags like v.0.10-beta.1, and v.0.3-stable. Even by adding that line (setup_requires=['setuptools_scm==3.5.0'] rather than setup_requires=['setuptools_scm']) I still get the error AssertionError: cant parse version v.0.2.6-stable

(PS you might want to change cant to can't :D)

RonnyPfannschmidt commented 4 years ago

@TheTechRobo as those versions are not valid python versions, a changed tag regex is required as well

yes, that typo has to go ^^

TheTechRobo commented 4 years ago

For my setup.py I use versions like 0.2.6. I was looking for something to replace MANIFEST.in as MANIFEST.in wasn't working.

TheTechRobo commented 4 years ago

This gives me an idea: what about having an option NOT to get the version number from the tag, and just use the manual version parameter in setup()?

RonnyPfannschmidt commented 4 years ago

The version checking is always opt in, if you only want the file finder, just don't enable the version determination

MatPoliquin commented 3 years ago

There is the same problem with this repo: https://github.com/openai/retro

pip3 install -e .

Error log:

File "/home/tu106/github/stable-retro/.eggs/setuptools_scm-6.0.1-py3.8.egg/setuptools_scm/version.py", line 195, in meta
        assert parsed_version is not None, "Can't parse version %s" % tag
    AssertionError: Can't parse version f347d7e
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
RonnyPfannschmidt commented 3 years ago

@MatPoliquin https://github.com/openai/retro/releases/tag/f347d7e is a completely invalid tag, i suspect it was added by mistake

extra helpers will have to be added to prevent setuptools_scm from stumbling over those

RonnyPfannschmidt commented 3 years ago

@MatPoliquin a local workaround can be to drop that particular tag