Merge lp:~zyga/testtools/use-versiontools into lp:~testtools-committers/testtools/trunk

Proposed by Zygmunt Krynicki
Status: Work in progress
Proposed branch: lp:~zyga/testtools/use-versiontools
Merge into: lp:~testtools-committers/testtools/trunk
Diff against target: 77 lines (+3/-51)
1 file modified
setup.py (+3/-51)
To merge this branch: bzr merge lp:~zyga/testtools/use-versiontools
Reviewer Review Type Date Requested Status
Robert Collins Needs Information
Review via email: mp+92824@code.launchpad.net

Description of the change

This patch switches from using hand-made solution to use versiontools. See the commit message for details.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I'm not really a testtools reviewer, but involved in the packaging. Some issues I noticed:

This removes the distinction for version phases ("final", "alpha", etc) and causes the version number to be 0.9.14 for all snapshots following release 0.9.14, rather than snapshot-0.9.14. This in particular matters for recipe builds, where we create a source package without the .bzr directory.

It looks like versiontools isn't packaged for Debian or Ubuntu yet. It would be nice if that could happen before testtools starts depending on it, otherwise we can't upload newer versions to Debian/Ubuntu.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

> I'm not really a testtools reviewer, but involved in the packaging. Some
> issues I noticed:

Hi, thanks for your review!

> This removes the distinction for version phases ("final", "alpha", etc) and
> causes the version number to be 0.9.14 for all snapshots following release
> 0.9.14, rather than snapshot-0.9.14. This in particular matters for recipe
> builds, where we create a source package without the .bzr directory.

versiontools handles this case correctly. The snapshot, created with sdist, will have proper revision information along with it (in the PKG-INFO file). Versiontools will fetch it. As for alphas, betas and more: this is supported but the __version__ needs accurately convey this information. See: http://versiontools.readthedocs.org/en/latest/#how-version-tuple-affects-version-string

> It looks like versiontools isn't packaged for Debian or Ubuntu yet. It would
> be nice if that could happen before testtools starts depending on it,
> otherwise we can't upload newer versions to Debian/Ubuntu.

There is a package but I've never pushed it to Ubuntu. I'll see what I can do about that.

Revision history for this message
Robert Collins (lifeless) wrote :

On Tue, Feb 14, 2012 at 10:54 AM, Zygmunt Krynicki
<email address hidden> wrote:

> There is a package but I've never pushed it to Ubuntu. I'll see what I can do about that.

Debian specifically is needed, unless the resulting sdists are
independent of versiontools.

-Rob

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Wysłane z iPhone'a

Dnia 13 lut 2012 o godz. 23:46 Robert Collins <email address hidden> napisał(a):

> On Tue, Feb 14, 2012 at 10:54 AM, Zygmunt Krynicki
> <email address hidden> wrote:
>
>> There is a package but I've never pushed it to Ubuntu. I'll see what I can do about that.
>
> Debian specifically is needed, unless the resulting sdists are
> independent of versiontools.
>

As of versiontools 1.9 they are. Setuptools is not required either.

ZK

> -Rob
>
> --
> https://code.launchpad.net/~zkrynicki/testtools/use-versiontools/+merge/92824
> You are the owner of lp:~zkrynicki/testtools/use-versiontools.

Revision history for this message
Robert Collins (lifeless) wrote :

I'm going to put this into WIP until the helper library is available in the distro - we like to keep it simple for contributors. At that point, we can un-WIP this and review its behaviour in detail.

review: Needs Information

Unmerged revisions

246. By Zygmunt Krynicki

Use versiontools instead of hand-made solution.

Versiontools (http://versiontools.rtfd.org) is centralized system that handles
formatting __version__ appropriately, according to PEP386. Versiontools
includes support for interrogating the version control system, such as bzr, git
or mercurial to retrieve the revision or other commit identifier and append
that to the version string in certain situations.

The biggest advantage is that this patch makes testtools work on python3.
Currently versiontools requires bzrlib to be importable to work, so without bzr
available inside your virtualenv (or system installation) you will not get
proper versioning of individual development snapshots (they will be just
labeled 1.2.3.dev instead of 1.2.3.dev{revno}). This requirement will go away
in versiontools 1.10 with shell fall-back as bzr is not coming to python3
anytime soon. This patch also requires setuptools to work properly (as
versiontools depends on setup_requires). This requirement will also go away in
versiontools 1.9, or as soon as
https://code.launchpad.net/~zkrynicki/versiontools/1.9/+merge/91568 lands in
trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2011-11-25 18:24:10 +0000
3+++ setup.py 2012-02-13 18:45:10 +0000
4@@ -1,62 +1,13 @@
5 #!/usr/bin/env python
6 """Distutils installer for testtools."""
7
8-from distutils.core import setup
9+from setuptools import setup
10 import email
11 import os
12
13 import testtools
14
15
16-def get_revno():
17- import bzrlib.errors
18- import bzrlib.workingtree
19- try:
20- t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
21- except (bzrlib.errors.NotBranchError, bzrlib.errors.NoWorkingTree):
22- return None
23- else:
24- return t.branch.revno()
25-
26-
27-def get_version_from_pkg_info():
28- """Get the version from PKG-INFO file if we can."""
29- pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
30- try:
31- pkg_info_file = open(pkg_info_path, 'r')
32- except (IOError, OSError):
33- return None
34- try:
35- pkg_info = email.message_from_file(pkg_info_file)
36- except email.MessageError:
37- return None
38- return pkg_info.get('Version', None)
39-
40-
41-def get_version():
42- """Return the version of testtools that we are building."""
43- version = '.'.join(
44- str(component) for component in testtools.__version__[0:3])
45- phase = testtools.__version__[3]
46- if phase == 'final':
47- return version
48- pkg_info_version = get_version_from_pkg_info()
49- if pkg_info_version:
50- return pkg_info_version
51- revno = get_revno()
52- if revno is None:
53- # Apparently if we just say "snapshot" then distribute won't accept it
54- # as satisfying versioned dependencies. This is a problem for the
55- # daily build version.
56- return "snapshot-%s" % (version,)
57- if phase == 'alpha':
58- # No idea what the next version will be
59- return 'next-r%s' % revno
60- else:
61- # Preserve the version number but give it a revno prefix
62- return version + '-r%s' % revno
63-
64-
65 def get_long_description():
66 manual_path = os.path.join(
67 os.path.dirname(__file__), 'doc/overview.rst')
68@@ -70,7 +21,8 @@
69 description=('Extensions to the Python standard library unit testing '
70 'framework'),
71 long_description=get_long_description(),
72- version=get_version(),
73+ version=":versiontools:testtools:",
74 classifiers=["License :: OSI Approved :: MIT License"],
75+ setup_requires=['versiontools'],
76 packages=['testtools', 'testtools.testresult', 'testtools.tests'],
77 cmdclass={'test': testtools.TestCommand})

Subscribers

People subscribed via source and target branches