PBR

Comment 6 for bug 1379579

Revision history for this message
dave.dittrich@icloud.com (dave-dittrich) wrote :

Actually, the reported "fix" that many people suggest, like installing distutils, seems to in reality be a manifestation of my all-time favorite logical fallacy, "Post Hoc, Ergo, Propter Hoc", which means "after this, therefore, because of this."

I believe that PBR reports the version of the program to which you gave the --version flag to be whatever version Git reports for the repo of the current working directory, not the program you installed with setup.py. In other words, the runtime determination of version is relatively to the runtime current working directory, not the as-installed program code.

Here is how I determined this (should be easy to replicate if you have a couple Git repos handy.)

$ cd /path/to/dimscli_source_repo
$ dimscli --version
dimscli 0.2.1
$ python setup.py --version
0.2.1.dev2
$ git describe
0.2-2-gf368f27

OK, that is what is expected.

$ cd
$ dimscli --version
Traceback (most recent call last):
File "/path/to/envs/dimscli/bin/dimscli", line 6, in <module>
from dimscli.shell import main
File "/path/to/git/python-dimscli/dimscli/__init__.py", line 20, in <module>
__version__ = version_info.version_string()
File "/path/to/envs/dimscli/lib/python2.7/site-packages/pbr/version.py", line 457, in version_string
return self.semantic_version().brief_string()
File "/path/to/envs/dimscli/lib/python2.7/site-packages/pbr/version.py", line 452, in semantic_version
self._semantic = self._get_version_from_pkg_resources()
File "/path/to/envs/dimscli/lib/python2.7/site-packages/pbr/version.py", line 439, in _get_version_from_pkg_resources
result_string = packaging.get_version(self.package)
File "/path/to/envs/dimscli/lib/python2.7/site-packages/pbr/packaging.py", line 668, in get_version
raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?

OK, now I get the bug behavior (and upgrading distutils *did not* change the output.) But now...

$ cd /path/to/ansible-playbooks
$ dimscli --version
dimscli 1.2.1
$ cd /path/to/dims-devguide/
$ dimscli --version
dimscli 0.0.1

So as you can see, the "fix" is actually changing directory, not upgrading distutils.

Is there a way to fix the version in the installed site-packages directory for the main program? I've been looking and haven't found how to do that yet.