Merge lp:~mabac/linaro-image-tools/display-version into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Approved by: Loïc Minier
Approved revision: 443
Merged at revision: 439
Proposed branch: lp:~mabac/linaro-image-tools/display-version
Merge into: lp:linaro-image-tools/11.11
Diff against target: 106 lines (+17/-9)
5 files modified
do-release (+8/-5)
linaro-hwpack-create (+2/-1)
linaro_image_tools/__version__.py (+1/-0)
linaro_image_tools/media_create/__init__.py (+3/-2)
setup.py (+3/-1)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/display-version
Reviewer Review Type Date Requested Status
linaro-image-tools maintainers Pending
Review via email: mp+77872@code.launchpad.net

Description of the change

Hi,

This branch enables the -v/--version option for linaro-media-create, linaro-android-media-create and linaro-hwpack-create.

The setup.py file is changed to get the version from __version__.py and do-release is changed to update the version in that py file.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

 overall happy with the changes, just some minor points:

On Mon, Oct 03, 2011, Mattias Backman wrote:
> === modified file 'do-release'
> --- do-release 2011-05-23 15:07:05 +0000
> +++ do-release 2011-10-03 08:48:54 +0000
> @@ -47,8 +47,8 @@
> die "Tag $version already exists"
> fi
>
> -log_i "Setting version to $version in setup.py"
> -sed -i "s/^\\([[:space:]]*version=\"\\)[^\"]*\",\$/\1$version\",/" setup.py
> +log_i "Setting version to $version in __version__.py"
> +sed -i "s/^\\(__version__\ =\ \"\\)[^\"]*\"\$/\1$version\"/" linaro_image_tools/__version__.py
>
> log_i "Committing $version"
> bzr commit -m "Release $version"
> @@ -68,8 +68,8 @@
> log_i "Signing tarball"
> gpg --armor --sign --detach-sig "../linaro-image-tools-$version.tar.gz"
>
> -log_i "Setting version to $version.1 in setup.py"
> -sed -i "s/^\\([[:space:]]*version=\"\\)[^\"]*\",\$/\1$version.1\",/" setup.py
> +log_i "Setting version to $version (devel) in __version__.py"
> +sed -i "s/^\\(__version__\ =\ \"\\)[^\"]*\"\$/\1$version.1 (devel)\"/" linaro_image_tools/__version__.py

 Might be worth factoring these seds into a set_version() function.

 The \\( \\) were to preserve spacing in setup.py which could happen
 within complex formatting, but given that version.py just holds the
 version = string, I think you could be more aggressive in your sed:
    sed -i "s/^version =.*/version = $version/" version.py
 which would make the sed much easier to read than it is in the current
 version!

> +__version__ = "2011.09.1 (devel)"

 Could we keep the version entirely numeric? I'd much prefer if that
 was the case because it would allow for e.g. easy version comparison if
 we needed that. For instance external scripts could verify the version
 of linaro-media-create, and dealing with alphanumeric is just a bit
 harder than splitting on . for major/minor version numbers.

    Thanks!
--
Loïc Minier

Revision history for this message
Mattias Backman (mabac) wrote :

>> -log_i "Setting version to $version.1 in setup.py"
>> -sed -i "s/^\\([[:space:]]*version=\"\\)[^\"]*\",\$/\1$version.1\",/" setup.py
>> +log_i "Setting version to $version (devel) in __version__.py"
>> +sed -i "s/^\\(__version__\ =\ \"\\)[^\"]*\"\$/\1$version.1 (devel)\"/" linaro_image_tools/__version__.py
>
>  Might be worth factoring these seds into a set_version() function.
>
>  The \\( \\) were to preserve spacing in setup.py which could happen
>  within complex formatting, but given that version.py just holds the
>  version = string, I think you could be more aggressive in your sed:
>    sed -i "s/^version =.*/version = $version/" version.py
>  which would make the sed much easier to read than it is in the current
>  version!

Sure, I'll be happy to simplify them, it took a lot of head scratching
for me to understand them now.

>
>> +__version__ = "2011.09.1 (devel)"
>
>  Could we keep the version entirely numeric?  I'd much prefer if that
>  was the case because it would allow for e.g. easy version comparison if
>  we needed that.  For instance external scripts could verify the version
>  of linaro-media-create, and dealing with alphanumeric is just a bit
>  harder than splitting on . for major/minor version numbers.

I have no problem with keeping the current .1 versioning. I think fabo
suggested the more clear distinction.

442. By Mattias Backman

Move seds to function.

443. By Mattias Backman

Change version back to numeric only.

Revision history for this message
Fathi Boudra (fboudra) wrote :

> >> +__version__ = "2011.09.1 (devel)"
> >
> >  Could we keep the version entirely numeric?  I'd much prefer if that
> >  was the case because it would allow for e.g. easy version comparison if
> >  we needed that.  For instance external scripts could verify the version
> >  of linaro-media-create, and dealing with alphanumeric is just a bit
> >  harder than splitting on . for major/minor version numbers.
>
> I have no problem with keeping the current .1 versioning. I think fabo
> suggested the more clear distinction.

I don't have a strong opinion. "devel" is still better for human readable version.
easy comparison is a valid use case. feel free to use a version entirely numeric, no objections.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'do-release'
2--- do-release 2011-05-23 15:07:05 +0000
3+++ do-release 2011-10-04 10:56:25 +0000
4@@ -22,6 +22,11 @@
5 exit 1
6 }
7
8+set_version() {
9+ log_i "Setting version to $1 in __version__.py"
10+ sed -i "s/^__version__ =.*/__version__ = \"$1\"/" linaro_image_tools/__version__.py
11+}
12+
13 version="$1"
14
15 if [ -z "$version" ]; then
16@@ -47,8 +52,7 @@
17 die "Tag $version already exists"
18 fi
19
20-log_i "Setting version to $version in setup.py"
21-sed -i "s/^\\([[:space:]]*version=\"\\)[^\"]*\",\$/\1$version\",/" setup.py
22+set_version $version
23
24 log_i "Committing $version"
25 bzr commit -m "Release $version"
26@@ -68,8 +72,7 @@
27 log_i "Signing tarball"
28 gpg --armor --sign --detach-sig "../linaro-image-tools-$version.tar.gz"
29
30-log_i "Setting version to $version.1 in setup.py"
31-sed -i "s/^\\([[:space:]]*version=\"\\)[^\"]*\",\$/\1$version.1\",/" setup.py
32+set_version "$version.1"
33
34-log_i "Committing $version"
35+log_i "Committing $version.1"
36 bzr commit -m "Post-release version bump to $version.1"
37
38=== modified file 'linaro-hwpack-create'
39--- linaro-hwpack-create 2011-05-25 15:47:02 +0000
40+++ linaro-hwpack-create 2011-10-04 10:56:25 +0000
41@@ -27,9 +27,10 @@
42 from linaro_image_tools.hwpack.builder import (
43 ConfigFileMissing, HardwarePackBuilder)
44
45+from linaro_image_tools.__version__ import __version__
46
47 if __name__ == '__main__':
48- parser = argparse.ArgumentParser()
49+ parser = argparse.ArgumentParser(version='%(prog)s ' + __version__)
50 parser.add_argument(
51 "CONFIG_FILE",
52 help="The configuration file to take the hardware pack information "
53
54=== added file 'linaro_image_tools/__version__.py'
55--- linaro_image_tools/__version__.py 1970-01-01 00:00:00 +0000
56+++ linaro_image_tools/__version__.py 2011-10-04 10:56:25 +0000
57@@ -0,0 +1,1 @@
58+__version__ = "2011.09.1"
59
60=== modified file 'linaro_image_tools/media_create/__init__.py'
61--- linaro_image_tools/media_create/__init__.py 2011-08-19 14:04:54 +0000
62+++ linaro_image_tools/media_create/__init__.py 2011-10-04 10:56:25 +0000
63@@ -21,6 +21,7 @@
64
65 from linaro_image_tools.media_create.boards import board_configs
66 from linaro_image_tools.media_create.android_boards import android_board_configs
67+from linaro_image_tools.__version__ import __version__
68
69
70 KNOWN_BOARDS = board_configs.keys()
71@@ -47,7 +48,7 @@
72
73 def get_args_parser():
74 """Get the ArgumentParser for the arguments given on the command line."""
75- parser = argparse.ArgumentParser()
76+ parser = argparse.ArgumentParser(version='%(prog)s ' + __version__)
77 group = parser.add_mutually_exclusive_group(required=True)
78 group.add_argument(
79 '--mmc', dest='device', help='The storage device to use.')
80@@ -128,7 +129,7 @@
81
82 def get_android_args_parser():
83 """Get the ArgumentParser for the arguments given on the command line."""
84- parser = argparse.ArgumentParser()
85+ parser = argparse.ArgumentParser(version='%(prog)s ' + __version__)
86 group = parser.add_mutually_exclusive_group(required=True)
87 group.add_argument(
88 '--mmc', dest='device', help='The storage device to use.')
89
90=== modified file 'setup.py'
91--- setup.py 2011-09-23 07:41:58 +0000
92+++ setup.py 2011-10-04 10:56:25 +0000
93@@ -2,10 +2,12 @@
94
95 # https://launchpad.net/python-distutils-extra
96 import DistUtilsExtra.auto
97+from linaro_image_tools.__version__ import __version__
98+
99
100 DistUtilsExtra.auto.setup(
101 name="linaro-image-tools",
102- version="2011.09.1",
103+ version=__version__,
104 description="Tools to create and write Linaro images",
105 url="https://launchpad.net/linaro-image-tools",
106 license="GPL v3 or later",

Subscribers

People subscribed via source and target branches