PBR

No "sem-ver:" line processing if pkg_resources can determine the package version

Bug #1795221 reported by Andreas Maier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Confirmed
Medium
Unassigned

Bug Description

I started using "Sem-Ver: feature" in commit messages of the pywbem project on GitHub with the goal to get the (pbr-created) project version to be properly incremented in its middle version number (i.e. last tag 0.12.0 results in 0.13.0.devXXX).

However, any "Sem-Ver: feature" seemed to be ignored, and the dev version still incremented only the right version number (i.e. last tag 0.12.0 results in 0.12.1.devXXX).

After digging in the code, I found the following in pbr.version:

    def _get_version_from_pkg_resources(self):
        """Obtain a version from pkg_resources or setup-time logic if missing.

        This will try to get the version of the package from the pkg_resources
        record associated with the package, and if there is no such record
        falls back to the logic sdist would use.
        """
        # Lazy import because pkg_resources is costly to import so defer until
        # we absolutely need it.
        import pkg_resources
        try:
            requirement = pkg_resources.Requirement.parse(self.package)
            provider = pkg_resources.get_provider(requirement)
            result_string = provider.version
        except pkg_resources.DistributionNotFound:
            # The most likely cause for this is running tests in a tree
            # produced from a tarball where the package itself has not been
            # installed into anything. Revert to setup-time logic.
            from pbr import packaging
            result_string = packaging.get_version(self.package)
        return SemanticVersion.from_pip_string(result_string)

This causes the pbr based version determination not even to be invoked when pkg_resources can determine the package version. In that case, no sem-ver processing takes place at all.

The desired result would be that "sem-ver:" lines are processed independently of whether pkg_resources can determine the package version.

Revision history for this message
Andreas Maier (maiera) wrote :

Changing the code above so that it uses the code in the except: clause unconditionally produces the desired result.

Ben Nemec (bnemec)
Changed in pbr:
status: New → Confirmed
importance: Undecided → Medium
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.