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

Regression: get_version works for 1.10.1 and 1.11.1, but not 1.13.1 #134

Closed
reece opened this issue Nov 25, 2016 · 20 comments
Closed

Regression: get_version works for 1.10.1 and 1.11.1, but not 1.13.1 #134

reece opened this issue Nov 25, 2016 · 20 comments

Comments

@reece
Copy link
Contributor

reece commented Nov 25, 2016

Summary

setuptools_scm 1.13.1 fails for several of my projects. 1.10.1 and 1.11.1 worked fine. The ultimate error is (full traceback below):

  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/version.py", line 86, in meta
    assert tag is not None, 'cant parse version %s' % tag
AssertionError: cant parse version None

Python 3.5.2, Ubuntu 16.04, various versions of setuptools_scm (see below).

This error appears to occur only for head revisions on several repos. Affected repos use hg-git, although I have no evidence that that's related.

Reproduction

snafu$ hg clone git@github.com:biocommons/bioutils.git
destination directory: bioutils
importing git objects into hg
updating to branch default
41 files updated, 0 files merged, 0 files removed, 0 files unresolved

snafu$ cd bioutils/

snafu$ pyvenv venv

snafu$ source venv/bin/activate

(venv) snafu$ pip install --upgrade pip setuptools
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached setuptools-28.8.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
  Found existing installation: setuptools 20.7.0
    Uninstalling setuptools-20.7.0:
      Successfully uninstalled setuptools-20.7.0
Successfully installed pip-9.0.1 setuptools-28.8.0

# recent commits, with any tags
(venv) snafu$ hg log -l 7 -G -T '{rev} {node|short} {tags}'
@  59 4aac87427260 default/default/master default/master tip
|
o  58 f9ca4a4c9c1c 0.2.0a2
|
o  57 f7d97e9493ae
|
o  56 57709bd798a4
|
o  55 019f38efb5c2
|
o  54 12c36903cb55 0.2.0a1
|
o  53 6bf205dc9ec0

# generate a table of get_version results for the above commits and setuptools_scm 1.10.1, 1.11.1, 1.13.1
(venv) snafu$ for r in 4aac f9ca f7d9 5770 019f 12c3 6bf2; do hg up -q $r; echo -n $(hg id -it); for v in 1.10.1 1.11.1 1.13.1; do pip install setuptools_scm==$v 1>/dev/null 2>&1; echo -n ,$(python -c 'from setuptools_scm import get_version; print(get_version())' 2>/dev/null | tail -1); done; echo; done >|data

(venv) snafu$ column -ts, <data
4aac87427260 default/default/master default/master tip  0.2.0a2                     0.2.0a2
f9ca4a4c9c1c 0.2.0a2                                    0.2.0a2                     0.2.0a2                     0.2.0a2
f7d97e9493ae                                            0.2.0a2.dev3+nf7d97e9493ae  0.2.0a2.dev3+nf7d97e9493ae  0.2.0a2.dev3+nf7d97e9493ae
57709bd798a4                                            0.2.0a2.dev2+n57709bd798a4  0.2.0a2.dev2+n57709bd798a4  0.2.0a2.dev2+n57709bd798a4
019f38efb5c2                                            0.2.0a1                     0.2.0a1                     0.2.0a1
12c36903cb55 0.2.0a1                                    0.2.0a1                     0.2.0a1                     0.2.0a1
6bf205dc9ec0                                            0.1.4.dev4+n6bf205dc9ec0    0.1.4.dev4+n6bf205dc9ec0    0.1.4.dev4+n6bf205dc9ec0


Columns are 1) changeset + tags, 2) 1.10.1 get_version, 3) 1.11.1 get_version, 4) 1.13.1 get_version

Example Tracebacks

These are all collected for the same bioutils commit (changeset 4aac87427260).

1.13.1

(venv) snafu$ pip install setuptools_scm==1.13.1; python -c 'from setuptools_scm import get_version; print(get_version())'
Collecting setuptools_scm==1.13.1
  Using cached setuptools_scm-1.13.1-py2.py3-none-any.whl
Installing collected packages: setuptools-scm
Successfully installed setuptools-scm-1.13.1
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 117, in get_version
    parsed_version = _do_parse(root, parse)
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 82, in _do_parse
    version = version_from_scm(root)
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 31, in version_from_scm
    return _version_from_entrypoint(root, 'setuptools_scm.parse_scm')
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 37, in _version_from_entrypoint
    return ep.load()(root)
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/hg.py", line 43, in parse
    return _hg_tagdist_normalize_tagcommit(root, tag, dist, node)
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/hg.py", line 17, in _hg_tagdist_normalize_tagcommit
    return meta(tag, distance=dist, node=node, dirty=dirty)
  File "/home/reece/projects/biocommons/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/version.py", line 86, in meta
    assert tag is not None, 'cant parse version %s' % tag
AssertionError: cant parse version None

1.11.1

(venv) snafu$ pip install setuptools_scm==1.11.1; python -c 'from setuptools_scm import get_version; print(get_version())'
Collecting setuptools_scm==1.11.1
  Using cached setuptools_scm-1.11.1-py2.py3-none-any.whl
Installing collected packages: setuptools-scm
  Found existing installation: setuptools-scm 1.13.1
    Uninstalling setuptools-scm-1.13.1:
      Successfully uninstalled setuptools-scm-1.13.1
Successfully installed setuptools-scm-1.11.1
0.2.0a3.dev2+n932c0cfb2774

1.10.1

(venv) snafu$ pip install setuptools_scm==1.10.1; python -c 'from setuptools_scm import get_version; print(get_version())'
Collecting setuptools_scm==1.10.1
  Using cached setuptools_scm-1.10.1-py2.py3-none-any.whl
Installing collected packages: setuptools-scm
  Found existing installation: setuptools-scm 1.11.1
    Uninstalling setuptools-scm-1.11.1:
      Successfully uninstalled setuptools-scm-1.11.1
Successfully installed setuptools-scm-1.10.1
0.2.0a3.dev2+n932c0cfb2774

@RonnyPfannschmidt
Copy link
Contributor

please run with SETUPTOOLS_SCM_DEBUG=1 in the environment

@reece
Copy link
Contributor Author

reece commented Nov 26, 2016

(venv) snafu$ SETUPTOOLS_SCM_DEBUG=1 python -c 'from setuptools_scm import get_version; print(get_version())'
root '/tmp/bug/bioutils'
looking for ep setuptools_scm.parse_scm /tmp/bug/bioutils
found ep .hg = setuptools_scm.hg:parse
cmd 'hg id -i -t'
out b'4aac87427260 default/default/master default/master tip\n'
tag default/default/master
version <LegacyVersion('default/default/master')>
tag default/master
version <LegacyVersion('default/master')>
tag tip
version <LegacyVersion('tip')>
cmd 'hg parents --template "{latesttag} {latesttagdistance}\n"'
out b'default/default/master:default/master 0\n'
cmd 'hg st --no-status --change 4aac87427260'
out b'.hgtags\n'
normalize {'st': '.hgtags', 'dist': '0', 'tag': 'default/default/master:default/master', 'root': '/tmp/bug/bioutils', 'dirty': False, 'node': '4aac87427260'}
tag default/default/master:default/master
version <LegacyVersion('default/default/master:default/master')>
version None
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 117, in get_version
    parsed_version = _do_parse(root, parse)
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 82, in _do_parse
    version = version_from_scm(root)
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 31, in version_from_scm
    return _version_from_entrypoint(root, 'setuptools_scm.parse_scm')
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/__init__.py", line 37, in _version_from_entrypoint
    return ep.load()(root)
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/hg.py", line 43, in parse
    return _hg_tagdist_normalize_tagcommit(root, tag, dist, node)
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/hg.py", line 17, in _hg_tagdist_normalize_tagcommit
    return meta(tag, distance=dist, node=node, dirty=dirty)
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm/version.py", line 86, in meta
    assert tag is not None, 'cant parse version %s' % tag
AssertionError: cant parse version None

I don't know why there's a default/default/master tag, but I'd guess it's user (ie. my) error when setting the master bookmark for hg-git.

@RonnyPfannschmidt
Copy link
Contributor

Is the repo public? ID like to try and reproduce locally

@reece
Copy link
Contributor Author

reece commented Nov 27, 2016

Yep. It's public. Thanks for investigating.
I had demonstrated to myself on a fresh checkout prior to posting, so my expectation is that you'll be able to reproduce it fairly easily.

@RonnyPfannschmidt
Copy link
Contributor

Please link

@RonnyPfannschmidt
Copy link
Contributor

oh, wait there is a link

@RonnyPfannschmidt
Copy link
Contributor

@reece what versions of mercurial/hg_git are you using?

RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Nov 27, 2016
@RonnyPfannschmidt
Copy link
Contributor

@reece can you also test against master, it may be possible that i accidentally fixed with one of the mercurial related fixes

@reece
Copy link
Contributor Author

reece commented Nov 27, 2016

I'm using Ubuntu 16.04, python 3.5.2, mercurial 3.7.3, and have tried hg-git head and 0.8.5.

master has the same issue.

test script at https://gist.github.com/reece/6d26c0b3a45ced81e50fa073f2b25e6b

(venv) snafu$ ./setuptools_scm-issue-134.py 
setuptools_scm = setuptools-scm 1.15.1.dev17+ngb0d17f1
root '/tmp/bug/bioutils'
looking for ep setuptools_scm.parse_scm /tmp/bug/bioutils
found ep .hg = setuptools_scm.hg:parse
cmd 'hg id -i -t'
out b'4aac87427260 default/default/master default/master tip\n'
tag default/default/master
version <LegacyVersion('default/default/master')>
tag default/master
version <LegacyVersion('default/master')>
tag tip
version <LegacyVersion('tip')>
cmd 'hg parents --template "{latesttag} {latesttagdistance}\n"'
out b'default/default/master:default/master 0\n'
cmd ['hg', 'log', '-r', "(branch(.) and tag('default/master')::. and file('re:^(?!\\.hgtags).*$') - tag('default/master'))", '--template', '{node|short}']
normalize {'dist': '0', 'revset': "(branch(.) and tag('default/master')::. and file('re:^(?!\\.hgtags).*$') - tag('default/master'))", 'node': '4aac87427260', 'dirty': False, 'root': '/tmp/bug/bioutils', 'tag': 'default/master', 'commits': ''}
tag default/master
version <LegacyVersion('default/master')>
version None
Traceback (most recent call last):
  File "./setuptools_scm-issue-134.py", line 10, in <module>
    print(setuptools_scm.get_version())
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/__init__.py", line 117, in get_version
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/__init__.py", line 82, in _do_parse
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/__init__.py", line 31, in version_from_scm
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/__init__.py", line 37, in _version_from_entrypoint
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/hg.py", line 54, in parse
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/hg.py", line 22, in _hg_tagdist_normalize_tagcommit
  File "/tmp/bug/bioutils/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev17+ngb0d17f1-py3.5.egg/setuptools_scm/version.py", line 86, in meta
AssertionError: cant parse version None

@reece
Copy link
Contributor Author

reece commented Nov 27, 2016

The setuptools_scm repo exhibits the same behavior when cloned with hg-git but not git. Compare these:

With hg-git

snafu$ hg clone git@github.com:reece/setuptools_scm.git setuptools_scm-hg
snafu$ cd setuptools_scm-hg/
snafu$ pyvenv venv
snafu$ source venv/bin/activate
(venv) snafu$ python setup.py egg_info
(venv) snafu$ python setup.py install
...
AssertionError: cant parse version None

With git

(venv) snafu$ git clone git@github.com:reece/setuptools_scm.git setuptools_scm-git
(venv) snafu$ cd setuptools_scm-git
(venv) snafu$ pyvenv venv
(venv) snafu$ source venv/bin/activate
(venv) snafu$ python setup.py egg_info
(venv) snafu$ python setup.py install
...
Installed /tmp/bug/setuptools_scm-git/venv/lib/python3.5/site-packages/setuptools_scm-1.15.1.dev16+ng5338d77-py3.5.egg
Processing dependencies for setuptools-scm==1.15.1.dev16+ng5338d77
Finished processing dependencies for setuptools-scm==1.15.1.dev16+ng5338d77

@RonnyPfannschmidt
Copy link
Contributor

I'm on hg 3.8 and things seem to be just fine
I'll bisect with different versions

@RonnyPfannschmidt
Copy link
Contributor

i haven't managed to follow up
i still believe the main cause of the issue is old mercurial on ubuntu

@reece
Copy link
Contributor Author

reece commented Dec 31, 2016

Thanks for updating.

I don't think it's quite as simple as "old mercurial on ubuntu". As the tracebacks in the original report show, setuptools_scm 1.13.1 fails, whereas 1.11.1 and 1.10.1 succeed, for otherwise identical configurations.

@RonnyPfannschmidt
Copy link
Contributor

I can't replicate on nicos with more recent versions, it will be a while before I can set up a VM and test on the same distro/version

@RonnyPfannschmidt
Copy link
Contributor

@reece to speed things up, please get me the output with SETUPTOOLS_SCM_DEBUG=True

@reece
Copy link
Contributor Author

reece commented Jan 31, 2017

Ronny- please see the comment much earlier in the thread with debug output. Or are you asking for something not covered there?

@RonnyPfannschmidt
Copy link
Contributor

@reece indeed, i missed it while revisiting the issue, i hope i can set up older hg + hg-git versions later this week

@RonnyPfannschmidt
Copy link
Contributor

@reece can you take a look if this still this the case with the recent versions of setuptools_scm

some hg related fixes came in

@reece
Copy link
Contributor Author

reece commented Apr 16, 2018

@RonnyPfannschmidt Thanks for continuing to investigate.

This appears to be fixed. Here's what I see in hg 4.3.1 using w/hg-git master from https://bitbucket.org/durin42/hg-git:

snafu$ for r in 4aac f9ca f7d9 5770 019f 12c3 6bf2; do hg up -q $r; echo -n $(hg id -it); for v in 1.10.1 1.11.1 1.13.1 2.0.0; do pip install setuptools_scm==$v 1>/dev/null 2>&1; echo -n ,$(python -c 'from setuptools_scm import get_version; print(get_version())' 2>&1 | tail -1 | cut -c1-20); done; echo; done | column -ts,
4aac87427260 default/default/master  0.2.0a2               0.2.0a2               AssertionError: cant  0.2.0a2
f9ca4a4c9c1c 0.2.0a2                 0.2.0a2               0.2.0a2               0.2.0a2               0.2.0a2
f7d97e9493ae                         0.2.0a2.dev3+nf7d97e  0.2.0a2.dev3+nf7d97e  0.2.0a2.dev3+nf7d97e  0.2.0a2.dev3+hf7d97e
57709bd798a4                         0.2.0a2.dev2+n57709b  0.2.0a2.dev2+n57709b  0.2.0a2.dev2+n57709b  0.2.0a2.dev2+h57709b
019f38efb5c2                         0.2.0a1               0.2.0a1               0.2.0a1               0.2.0a1
12c36903cb55 0.2.0a1                 0.2.0a1               0.2.0a1               0.2.0a1               0.2.0a1
6bf205dc9ec0                         0.1.4.dev4+n6bf205dc  0.1.4.dev4+n6bf205dc  0.1.4.dev4+n6bf205dc  0.1.4.dev4+h6bf205dc

Columns are hg and the get_version() result for setuptools_scm versions 1.10.1, 1.11.1, 1.13.1, and 2.0.0.

The bit to notice there is that the anomalous "AssertionError" in column 5 from 1.13.1 is gone in setuptools_scm 2.0.0 (and it agrees with setuptools_scm 1.10.1 and 1.11.1. Again, these are all for the same version of hg (4.3.1).

I'll close now.

I appreciate your effort!

@reece reece closed this as completed Apr 16, 2018
@RonnyPfannschmidt
Copy link
Contributor

@avirshup deserves the credit for making a much better and more reliable hg integration

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

No branches or pull requests

2 participants