Skip to content

Support local version identifiers #57

@cjwatson

Description

@cjwatson

PEP 440 defines local version identifiers which can be used when applying local patches to upstream projects. For example, in Launchpad we occasionally have to backport fixes from later releases that we can't upgrade to wholesale yet, or apply patches that haven't been integrated yet upstream; we do this by making distributions with local version identifiers that we commit to a git repository containing our dependencies.

This works fine with most Python projects, but it's awkward for ones that use incremental because incremental doesn't directly support local version identifiers: there's a Version.local, but it's just equal to Version.public. Let's say we're making a fork of Twisted 20.3.0, which has:

__version__ = Version('Twisted', 20, 3, 0)

Ideally we'd just be able to change that to something like:

__version__ = Version('Twisted', 20, 3, 0, local='lp1')

... and have that generate 20.3.0+lp1. However, since incremental doesn't support local version identifiers and since Twisted uses __version__.short(), I guess we end up doing something like this (obviously incomplete, but just for the purpose of getting distribution files with the right version number in them):

class LocalVersion(Version):
    def __init__(self, *args, **kwargs):
        self._local = kwargs.pop('local')
        super(LocalVersion, self).__init__(*args, **kwargs)

    def public(self):
        public = super(LocalVersion, self).public()
        if self._local:
            public += '+%s' % self._local
        return public

__version__ = LocalVersion('Twisted', 20, 3, 0, local='lp1')

Or alternatively I suppose that we could make src/twisted/__init__.py say:

__version__ = version.short() + '+lp1'

Either way, this seems like a lot of awkwardness just to make a temporary local backport distribution! I think incremental could usefully help to make this easier.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions