Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local version identifiers #57

Open
cjwatson opened this issue Aug 28, 2020 · 0 comments
Open

Support local version identifiers #57

cjwatson opened this issue Aug 28, 2020 · 0 comments

Comments

@cjwatson
Copy link
Contributor

cjwatson commented Aug 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant