From 2b063c0d5b0da8f76c5de64d7bdeb2ee1edf1b93 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 29 Oct 2013 12:36:12 -0200 Subject: Adds a command to freeze debian versions. --- changes/feature_4315-freeze-debianver-command | 1 + setup.py | 72 ++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 changes/feature_4315-freeze-debianver-command diff --git a/changes/feature_4315-freeze-debianver-command b/changes/feature_4315-freeze-debianver-command new file mode 100644 index 00000000..0ae8ad97 --- /dev/null +++ b/changes/feature_4315-freeze-debianver-command @@ -0,0 +1 @@ +- Add a command to setup.py to freeze the versions reported under debian branches. Closes: #4315 diff --git a/setup.py b/setup.py index fd87e56c..dca8f44a 100755 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ versioneer.versionfile_build = 'leap/bitmask/_version.py' versioneer.tag_prefix = '' # tags are like 1.2.0 versioneer.parentdir_prefix = 'leap.bitmask-' -#from setuptools import Command # The following import avoids the premature unloading of the `util` submodule # when running tests, which would cause an error when nose finishes tests and @@ -74,10 +73,69 @@ trove_classifiers = [ "Topic :: Utilities", ] +DOWNLOAD_BASE = ('https://github.com/leapcode/bitmask_client/' + 'archive/%s.tar.gz') +_versions = versioneer.get_versions() +VERSION = _versions['version'] +VERSION_FULL = _versions['full'] +DOWNLOAD_URL = "" -parsed_reqs = utils.parse_requirements() +# get the short version for the download url +_version_short = re.findall('\d+\.\d+\.\d+', VERSION) +if len(_version_short) > 0: + VERSION_SHORT = _version_short[0] + DOWNLOAD_URL = DOWNLOAD_BASE % VERSION_SHORT cmdclass = versioneer.get_cmdclass() + + +from setuptools import Command + + +class freeze_debianver(Command): + """ + Freezes the version in a debian branch. + To be used after merging the development branch onto the debian one. + """ + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + proceed = str(raw_input( + "This will overwrite the file _version.py. Continue? [y/N] ")) + if proceed != "y": + print("He. You scared. Aborting.") + return + template = r""" +# This file was generated by the `freeze_debianver` command in setup.py +# Using 'versioneer.py' (0.7+) from +# revision-control system data, or from the parent directory name of an +# unpacked source archive. Distribution tarballs contain a pre-generated copy +# of this file. + +version_version = '{version}' +version_full = '{version_full}' +""" + templatefun = r""" + +def get_versions(default={}, verbose=False): + return {'version': version_version, 'full': version_full} +""" + subst_template = template.format( + version=VERSION_SHORT, + version_full=VERSION_FULL) + templatefun + with open(versioneer.versionfile_source, 'w') as f: + f.write(subst_template) + + +cmdclass["freeze_debianver"] = freeze_debianver +parsed_reqs = utils.parse_requirements() + leap_launcher = 'bitmask=leap.bitmask.app:main' from setuptools.command.develop import develop as _develop @@ -150,16 +208,6 @@ if IS_LINUX: ["pkg/linux/resolv-update"]), ] -DOWNLOAD_BASE = ('https://github.com/leapcode/bitmask_client/' - 'archive/%s.tar.gz') -VERSION = versioneer.get_version() -DOWNLOAD_URL = "" - -# get the short version for the download url -short_ver = re.findall('\d+\.\d+\.\d+', VERSION) -if len(short_ver) > 0: - DOWNLOAD_URL = DOWNLOAD_BASE % short_ver[0] - setup( name="leap.bitmask", -- cgit v1.2.3