From: Daira Hopwood Date: Fri, 21 Nov 2014 08:12:13 +0000 (+0000) Subject: setup.py: generate _version.h for use by Windows installer. X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/htmlfontify-example.html?a=commitdiff_plain;h=ea7700848490c3bf0820375202084276ca2dae27;p=tahoe-lafs%2Ftahoe-lafs.git setup.py: generate _version.h for use by Windows installer. Signed-off-by: Daira Hopwood --- diff --git a/setup.py b/setup.py index 0693e634..7e214adf 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,8 @@ def read_version_py(infname): return mo.group(1) VERSION_PY_FILENAME = 'src/allmydata/_version.py' +VERSION_H_FILENAME = 'misc/build_helpers/windows/installer/installer/_version.h' + version = read_version_py(VERSION_PY_FILENAME) APPNAME='allmydata-tahoe' @@ -250,7 +252,7 @@ class MakeExecutable(Command): raise -GIT_VERSION_BODY = ''' +GIT_VERSION_PY = ''' # This _version.py is generated from git metadata by the tahoe setup.py. __pkgname__ = %(pkgname)r @@ -261,6 +263,12 @@ verstr = %(normalized)r __version__ = verstr ''' +GIT_VERSION_H = ''' +// This _version.h is generated from git metadata by the tahoe setup.py. + +#define PKGNAME_AND_VERSION L"%(pkgname)s-%(normalized)s" +''' + def run_command(args, cwd=None): try: # remember shell=False, so use git.cmd on windows, not just git @@ -369,17 +377,23 @@ Warning: no version information found. This may cause tests to fail. # If we change APPNAME, the release tag names should also change from then on. versions = versions_from_git(APPNAME + '-') if versions: + version_info = { + "pkgname": self.distribution.get_name(), + "version": versions["version"], + "normalized": versions["normalized"], + "full": versions["full"], + "branch": versions["branch"], + } + f = open(VERSION_PY_FILENAME, "wb") - f.write(GIT_VERSION_BODY % - { "pkgname": self.distribution.get_name(), - "version": versions["version"], - "normalized": versions["normalized"], - "full": versions["full"], - "branch": versions["branch"], - }) + f.write(GIT_VERSION_PY % version_info) f.close() print("Wrote normalized version %r into '%s'" % (versions["normalized"], VERSION_PY_FILENAME)) + f = open(VERSION_H_FILENAME, "wb") + f.write(GIT_VERSION_H % version_info) + f.close() + return versions.get("normalized", None)