From 10f82bd474c5bc91b330beccd883da06b0014a99 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 5 Aug 2016 11:56:48 -0400 Subject: adjust tools and version information. upstream snapshots are versioned in the format 'X.Y.Z+.g' where X.Y.Z are major, minor, and micro. Distance is number of commits since last annotated tag, and commit is the git commit. bddeb and brpm will now create and use the "upstream version" like above. Things changed here: - tools/make-tarball update cloudinit/version.py to contain the full version support --output support '--long' to always create the long format version string. - bddeb: - use quilt debian source format - use read-version and long version in changelog. - brpm: - change to use read-version and upstream long version in the spec. - flake8 changes - tools/read-version - read version from git or from cloudinit/version. - provide --json output with more nicely formed data. --- cloudinit/version.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cloudinit/version.py') diff --git a/cloudinit/version.py b/cloudinit/version.py index 3d1d1d23..01785eb8 100644 --- a/cloudinit/version.py +++ b/cloudinit/version.py @@ -16,12 +16,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from distutils import version as vr +__VERSION__ = "0.7.6" +__EXPORT_VERSION__ = "@@EXPORT_VERSION@@" -def version(): - return vr.StrictVersion("0.7.7") +def version_string(): + if not __EXPORT_VERSION__.startswith("@@"): + return __EXPORT_VERSION__ + return __VERSION__ -def version_string(): - return str(version()) +def full_version_string(): + if __EXPORT_VERSION__.startswith("@@"): + raise ValueError("No full version available") + return __EXPORT_VERSION__ -- cgit v1.2.3 From 42bed116b411eb25ebd8368b2b4ed6c56ffd85e7 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 5 Aug 2016 15:51:34 -0400 Subject: drop modification of version during make-tarball, tools changes. Modification of the tarball became problematic, as it meant that any tool extracting source would find the orig source tarball different. I found this unusable when trying to use 'gbp buildpackage'. Other changes here are to better support using python3 or python2 for the build. Makefile will try to call the right python version and can be told which python to use. read-version: by adding 'tiny_p' and avoiding the import of cloudinit.util, we need less dependencies to run this. --- Makefile | 19 +++++++++++-------- cloudinit/version.py | 9 --------- packages/debian/rules.in | 2 +- setup.py | 4 ++-- tools/make-tarball | 8 +------- tools/read-version | 26 +++++++++++++++++++------- 6 files changed, 34 insertions(+), 34 deletions(-) (limited to 'cloudinit/version.py') diff --git a/Makefile b/Makefile index 32c50aee..5d35dcc0 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,20 @@ CWD=$(shell pwd) -PYVER ?= 3 +PYVER ?= $(shell for p in python3 python2; do \ + out=$(which $$p 2>&1) && echo $$p && exit; done; \ + exit 1) noseopts ?= -v YAML_FILES=$(shell find cloudinit bin tests tools -name "*.yaml" -type f ) YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f ) -CHANGELOG_VERSION=$(shell $(CWD)/tools/read-version) -CODE_VERSION=$(shell python -c "from cloudinit import version; print version.version_string()") - PIP_INSTALL := pip install -ifeq ($(PYVER),3) +ifeq ($(PYVER),python3) pyflakes = pyflakes3 unittests = unittest3 yaml = yaml else -ifeq ($(PYVER),2) +ifeq ($(PYVER),python2) pyflakes = pyflakes unittests = unittest else @@ -28,6 +27,10 @@ ifeq ($(distro),) distro = redhat endif +READ_VERSION=$(shell $(PYVER) $(CWD)/tools/read-version) +CODE_VERSION=$(shell $(PYVER) -c "from cloudinit import version; print(version.version_string())") + + all: check check: check_version pep8 $(pyflakes) test $(yaml) @@ -58,8 +61,8 @@ pip-test-requirements: test: $(unittests) check_version: - @if [ "$(CHANGELOG_VERSION)" != "$(CODE_VERSION)" ]; then \ - echo "Error: ChangeLog version $(CHANGELOG_VERSION)" \ + @if [ "$(READ_VERSION)" != "$(CODE_VERSION)" ]; then \ + echo "Error: read-version version $(READ_VERSION)" \ "not equal to code version $(CODE_VERSION)"; exit 2; \ else true; fi diff --git a/cloudinit/version.py b/cloudinit/version.py index 01785eb8..aa8ccd7e 100644 --- a/cloudinit/version.py +++ b/cloudinit/version.py @@ -17,16 +17,7 @@ # along with this program. If not, see . __VERSION__ = "0.7.6" -__EXPORT_VERSION__ = "@@EXPORT_VERSION@@" def version_string(): - if not __EXPORT_VERSION__.startswith("@@"): - return __EXPORT_VERSION__ return __VERSION__ - - -def full_version_string(): - if __EXPORT_VERSION__.startswith("@@"): - raise ValueError("No full version available") - return __EXPORT_VERSION__ diff --git a/packages/debian/rules.in b/packages/debian/rules.in index cf2dd405..9b004357 100755 --- a/packages/debian/rules.in +++ b/packages/debian/rules.in @@ -14,7 +14,7 @@ override_dh_install: override_dh_auto_test: ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) - http_proxy= make PYVER=${pyver} check + http_proxy= make PYVER=python${pyver} check else @echo check disabled by DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS) endif diff --git a/setup.py b/setup.py index 0af576a9..4abbb67e 100755 --- a/setup.py +++ b/setup.py @@ -116,13 +116,13 @@ def in_virtualenv(): def get_version(): - cmd = ['tools/read-version'] + cmd = [sys.executable, 'tools/read-version'] (ver, _e) = tiny_p(cmd) return str(ver).strip() def read_requires(): - cmd = ['tools/read-dependencies'] + cmd = [sys.executable, 'tools/read-dependencies'] (deps, _e) = tiny_p(cmd) return str(deps).splitlines() diff --git a/tools/make-tarball b/tools/make-tarball index bd7399c1..57358447 100755 --- a/tools/make-tarball +++ b/tools/make-tarball @@ -62,11 +62,5 @@ if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then fi fi -git archive --format=tar --prefix="$archive_base/" "$rev" | - ( cd "$TEMP_D" && tar xpf - ) - -sed -i "s,@@EXPORT_VERSION@@,$version," "$archive_base/cloudinit/version.py" - -( cd "$TEMP_D" && tar cpzf - "$archive_base/" ) > "$output" - +git archive --format=tar.gz --prefix="$archive_base/" "$rev" > "$output" echo "$output" diff --git a/tools/read-version b/tools/read-version index e585ab2e..78e34157 100755 --- a/tools/read-version +++ b/tools/read-version @@ -2,13 +2,28 @@ import os import json +import subprocess import sys if "avoid-pep8-E402-import-not-top-of-file": _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) sys.path.insert(0, _tdir) from cloudinit import version as ci_version - from cloudinit import util + + +def tiny_p(cmd, capture=True): + # python 2.6 doesn't have check_output + stdout = subprocess.PIPE + stderr = subprocess.PIPE + sp = subprocess.Popen(cmd, stdout=stdout, + stderr=stderr, stdin=None, + universal_newlines=True) + (out, err) = sp.communicate() + ret = sp.returncode + if ret not in [0]: + raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" % + (cmd, ret, out, err)) + return out use_long = '--long' in sys.argv or os.environ.get('CI_RV_LONG') @@ -31,20 +46,17 @@ if os.path.isdir(os.path.join(_tdir, ".git")): flags = ['--tags'] cmd = ['git', 'describe'] + flags - version = fix_git_version(util.subp(cmd)[0]) + version = fix_git_version(tiny_p(cmd)) if not version.startswith(src_version): sys.stderr.write("git describe version (%s) differs from " "cloudinit.version (%s)\n" % (version, src_version)) sys.exit(1) - version_long = fix_git_version(util.subp(cmd + ["--long"])[0]) + version_long = fix_git_version(tiny_p(cmd + ["--long"])) else: version = src_version - try: - version_long = ci_version.full_version_string() - except ValueError: - pass + version_long = None # version is X.Y.Z[+xxx.gHASH] # version_long is None or X.Y.Z+xxx.gHASH -- cgit v1.2.3 From 3aa094b6917240e6654993b34a48403cb7e14b02 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 9 Aug 2016 23:05:38 -0600 Subject: release 0.7.7 Bump the version in cloudinit/version.py to be 0.7.7. --- cloudinit/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cloudinit/version.py') diff --git a/cloudinit/version.py b/cloudinit/version.py index aa8ccd7e..6acada84 100644 --- a/cloudinit/version.py +++ b/cloudinit/version.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -__VERSION__ = "0.7.6" +__VERSION__ = "0.7.7" def version_string(): -- cgit v1.2.3