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

Subscribers

People subscribed via source and target branches