PBR

pbr - 4-level version number

Bug #1734361 reported by Axel Huebl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Fix Released
Undecided
Unassigned

Bug Description

Hi,

I am using pbr 3.1.1 on Python 2.7.13 on Debian 9.2 "stretch" and have issues with version numbers with 4 levels.

My setup.cfg contains:

    [metadata]
    version = 1.2.3.4

and according to PEP-440 those should be valid.
I am not trying to do a development-release, alpha or similar but really want to use the 4th version level.

Unfortunately, pbr fails on `python setup.py install` with

ERROR:root:Error parsing
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pbr/core.py", line 111, in pbr
    attrs = util.cfg_to_args(path, dist.script_args)
  File "/usr/lib/python2.7/dist-packages/pbr/util.py", line 246, in cfg_to_args
    pbr.hooks.setup_hook(config)
  File "/usr/lib/python2.7/dist-packages/pbr/hooks/__init__.py", line 25, in setup_hook
    metadata_config.run()
  File "/usr/lib/python2.7/dist-packages/pbr/hooks/base.py", line 27, in run
    self.hook()
  File "/usr/lib/python2.7/dist-packages/pbr/hooks/metadata.py", line 26, in hook
    self.config['name'], self.config.get('version', None))
  File "/usr/lib/python2.7/dist-packages/pbr/packaging.py", line 716, in get_version
    version = _get_version_from_git(pre_version)
  File "/usr/lib/python2.7/dist-packages/pbr/packaging.py", line 652, in _get_version_from_git
    pre_version)
  File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 147, in from_pip_string
    return klass._from_pip_string_unsafe(version_string)
  File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 211, in _from_pip_string_unsafe
    prerelease_type, prerelease = _parse_type(remainder[0])
  File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 189, in _parse_type
    return prerelease_type, int(prerelease)
ValueError: invalid literal for int() with base 10: ''
error in setup command: Error parsing /home/axel/myproject/setup.cfg: ValueError: invalid literal for int() with base 10: ''

is this a bug in pbr?

-----------------------------------
Release: 3.1.2.dev36 on 2017-11-20 09:34
SHA: 73cc4189caa8b8eb73855025529e5f820fb76a30
Source: https://git.openstack.org/cgit/openstack/pbr/tree/doc/source/index.rst
URL: https://docs.openstack.org/pbr/latest/

Revision history for this message
Clark Boylan (cboylan) wrote :

PBR docs try to cover this but PBR explicitly uses a version of semver that is pep440 compatible. This means That versions should have three sets of numbers for major.minor.patch. Details are in the PBR docs at https://docs.openstack.org/pbr/latest/user/semver.html.

I think the bug here is that PBR should probably generate a better error message to describe this situation.

Revision history for this message
Ben Nemec (bnemec) wrote :

I think this is fixed (sort of) in current versions of pbr. I tested it out on one of our projects and set a 4 part version in setup.cfg. This worked and resulted in "Version: 4.2.3.dev2".

It should be noted that the version I had set was 4.2.3.4, so the final component is still being ignored, but that's expected behavior. pbr uses 3 part versions only, as documented in the link Clark posted.

So unfortunately I don't think pbr is going to be suitable if you need 4 part versions, but it isn't failing in a confusing way anymore either. I guess there's an argument that it should fail on 4 part versions instead of silently ignoring the last component. I think I'm going to close this bug though since it's now working as expected. Please feel free to open a new bug if you'd like that behavior changed. Thanks.

Changed in pbr:
status: New → Fix Released
Revision history for this message
Axel Huebl (axel-huebl) wrote :

Thank you for the updates, sounds good!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.