PBR

VersionInfo doesn't play nice with dh_auto_test

Bug #1637729 reported by Free Ekanayaka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Confirmed
Wishlist
Unassigned

Bug Description

When creating a Debian package of a pbr-based Python package, by default dh-python will try to run unittests right after running "python setup.py build" (see [0]), and *before* running "python setup.py install".

This means that the default dh-python test command ("python -m unittest discover -v") will be run in the setuptools build directory, that does NOT have any PKG-INFO file.

Now, in case the Python package runs the idiomatic VersionInfo(<package-name>).semantic_version() code in its top-level __init__.py, unittests will fail with "Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?", since there's no git tree or local PKG-INFO file.

In that case the only rescue is to set the PBR_VERSION environment variable explicitly (for example in debian/rules).

I think it'd be nice to have some code in pbr.packaging._get_version_from_pkg_metadata() that detects this situation and tries to see if there's a suitable PKG-INFO file somewhere in an ancestor dir (a bit like _get_version_from_git does, after all, since git has that behavior itself).

Or, alternatively to make dh-python export PBR_VERSION automatically (or more generically-named variable, that pbr could honor), but that sounds a bit ad-hoc.

Thoughts?

I'm attaching the log of sample dpkg-buildpackage run that failed due to this bug.

[0] http://debian-python.readthedocs.io/en/latest/dh_python.html

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :
Ben Nemec (bnemec)
Changed in pbr:
status: New → Confirmed
importance: Undecided → Wishlist
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.