def _grab_version(self, initial=False):
        """Grab the version.

        When initial is False, ask the user for a non-development
        version.  When initial is True, grab the current suggestion.

        """
        original_version = self.vcs.version
        logger.debug("Extracted version: %s", original_version)
        if not original_version:
            logger.critical('No version found.')
            sys.exit(1)
        suggestion = new_version = self.data.get('new_version')
        if not new_version:
            # Get a suggestion.
            breaking = self.data['breaking']
            feature = self.data['feature']
            # Compare the suggestion for the last tag with the current version.
            # The wanted version bump may already have been done.
            last_tag_version = utils.get_last_tag(self.vcs, allow_missing=True)
            if last_tag_version is None:
                print("No tag found. No version bump needed.")
                sys.exit(0)
            else:
                print("Last tag: {}".format(last_tag_version))
            print("Current version: {}".format(original_version))
            params = dict(
                feature=feature,
                breaking=breaking,
                less_zeroes=self.pypiconfig.less_zeroes(),
                levels=self.pypiconfig.version_levels(),
                dev_marker=self.pypiconfig.development_marker(),
            )
            minimum_version = utils.suggest_version(
                last_tag_version, **params)
            if parse_version(minimum_version) <= parse_version(
                    utils.cleanup_version(original_version)):
                print("No version bump needed.")
                sys.exit(0)
            # A bump is needed.  Get suggestion for next version.
            suggestion = utils.suggest_version(
                original_version, **params)
        if not initial:
            new_version = utils.ask_version(
                "Enter version", default=suggestion)
        if not new_version:
            new_version = suggestion
        self.data['original_version'] = original_version
        self.data['new_version'] = new_version
        self.data['clean_new_version'] = utils.cleanup_version(new_version)
Exemple #2
0
def append_jenkins_build_number_to_package_version(jenkins_build_number):
    from zest.releaser.vcs import BaseVersionControl
    from zest.releaser.utils import cleanup_version
    vcs = BaseVersionControl()
    old_version = cleanup_version(vcs.version)
    new_version = '{}.{}'.format(old_version, jenkins_build_number)
    vcs.version = new_version
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        logger.debug("Extracted version: %s", current)
        if not current:
            logger.critical('No version found.')
            sys.exit(1)
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(
            current,
            less_zeroes=self.pypiconfig.less_zeroes(),
            levels=self.pypiconfig.version_levels(),
            dev_marker=self.pypiconfig.development_marker(),
        )
        print("Current version is %s" % current)
        q = ("Enter new development version "
             "('%(development_marker)s' will be appended)" % self.data)
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %s",
                    dev_version)
Exemple #4
0
 def _grab_version(self):
     """Set the version to a non-development version."""
     original_version = self.vcs.version
     logger.debug("Extracted version: %s", original_version)
     if original_version is None:
         logger.critical('No version found.')
         sys.exit(1)
     suggestion = utils.cleanup_version(original_version)
     new_version = utils.ask_version("Enter version", default=suggestion)
     if not new_version:
         new_version = suggestion
     self.data['original_version'] = original_version
     self.data['new_version'] = new_version
Exemple #5
0
    def _grab_version(self, initial=False):
        """Grab the version.

        When initial is False, ask the user for a non-development
        version.  When initial is True, grab the current suggestion.

        """
        original_version = self.vcs.version
        logger.debug("Extracted version: %s", original_version)
        if original_version is None:
            logger.critical('No version found.')
            sys.exit(1)
        suggestion = new_version = self.data.get('new_version')
        if not new_version:
            # Get a suggestion.
            breaking = self.data['breaking']
            feature = self.data['feature']
            # Compare the suggestion for the last tag with the current version.
            # The wanted version bump may already have been done.
            last_tag_version = utils.get_last_tag(self.vcs, allow_missing=True)
            if last_tag_version is None:
                print("No tag found. No version bump needed.")
                sys.exit(0)
            else:
                print("Last tag: {}".format(last_tag_version))
            print("Current version: {}".format(original_version))
            params = dict(
                feature=feature,
                breaking=breaking,
                less_zeroes=self.pypiconfig.less_zeroes(),
                levels=self.pypiconfig.version_levels(),
                dev_marker=self.pypiconfig.development_marker(),
            )
            minimum_version = utils.suggest_version(last_tag_version, **params)
            if minimum_version <= original_version:
                print("No version bump needed.")
                sys.exit(0)
            # A bump is needed.  Get suggestion for next version.
            suggestion = utils.suggest_version(original_version, **params)
        if not initial:
            new_version = utils.ask_version("Enter version",
                                            default=suggestion)
        if not new_version:
            new_version = suggestion
        self.data['original_version'] = original_version
        self.data['new_version'] = new_version
        self.data['clean_new_version'] = utils.cleanup_version(new_version)
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(current)
        print("Current version is %s" % current)
        q = "Enter new development version ('.dev0' will be appended)"
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %s", dev_version)
Exemple #7
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        # Try to make sure that the suggestion for next version after
        # 1.1.19 is not 1.1.110, but 1.1.20.
        current_split = current.split('.')
        major = '.'.join(current_split[:-1])
        minor = current_split[-1]
        try:
            minor = int(minor) + 1
            suggestion = '.'.join([major, str(minor)])
        except ValueError:
            # Fall back on simply updating the last character when it is
            # an integer.
            try:
                last = int(current[-1]) + 1
                suggestion = current[:-1] + str(last)
            except ValueError:
                logger.warn("Version does not end with a number, so we can't "
                            "calculate a suggestion for a next version.")
                suggestion = None
        print "Current version is %r" % current
        if suggestion:
            suggestion_string = ' [%s]' % suggestion
        else:
            suggestion_string = ''
        q = ("Enter new development version ('.dev0' will be appended)"
             "%s: " % suggestion_string)
        version = utils.get_input(q).strip()
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit()

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %r",
                    dev_version)
Exemple #8
0
    def _release(self, packagename):
        config = ConfigParser()
        origcfg = None

        if os.path.exists('setup.cfg'):
            origcfg = open('setup.cfg', 'r').read()
            config.readfp(open('setup.cfg'))

        if not config.has_section('egg_info'):
            config.add_section('egg_info')
        config.set('egg_info', 'tag_date', 'true')
        config.set('egg_info', 'tag_build', 'dev')

        if not config.has_section('sdist'):
            config.add_section('sdist')
        config.set('sdist', 'formats', 'zip')


        stream = StringIO()
        config.write(stream)
        open('setup.cfg', 'w').write(stream.getvalue())
        os.system(self.releasercmd)
        if origcfg is not None:
            open('setup.cfg', 'w').write(origcfg)
        else:
            os.remove('setup.cfg')
        version = utils.cleanup_version(
            BaseVersionControl()._extract_version()
        )

        date = datetime.now().strftime('%Y%m%d')
        version = '%sdev-%s' % (version, date)

        zipfile = '%s-%s.zip' % (packagename, version)
        outputdir = os.path.join(self.buildoutdir, self.outputdir)
        if not os.path.exists(outputdir):
            os.mkdir(outputdir)
        shutil.move(
            os.path.join(os.getcwd(), 'dist', zipfile), 
            os.path.join(outputdir, zipfile)
        )
        return version
Exemple #9
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(current)
        print("Current version is %s" % current)
        q = "Enter new development version ('.dev0' will be appended)"
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %s",
                    dev_version)
Exemple #10
0
    def _grab_version(self, initial=False):
        """Grab the version.

        When initial is False, ask the user for a non-development
        version.  When initial is True, grab the current suggestion.
        """
        original_version = self.vcs.version
        logger.debug("Extracted version: %s", original_version)
        if not original_version:
            logger.critical("No version found.")
            sys.exit(1)
        suggestion = utils.cleanup_version(original_version)
        new_version = None
        if not initial:
            new_version = utils.ask_version("Enter version",
                                            default=suggestion)
        if not new_version:
            new_version = suggestion
        self.data["original_version"] = original_version
        self.data["new_version"] = new_version
Exemple #11
0
    def _grab_version(self, initial=False):
        """Grab the version.

        When initial is False, ask the user for a non-development
        version.  When initial is True, grab the current suggestion.

        """
        original_version = self.vcs.version
        logger.debug("Extracted version: %s", original_version)
        if original_version is None:
            logger.critical('No version found.')
            sys.exit(1)
        suggestion = utils.cleanup_version(original_version)
        new_version = None
        if not initial:
            new_version = utils.ask_version(
                "Enter version", default=suggestion)
        if not new_version:
            new_version = suggestion
        self.data['original_version'] = original_version
        self.data['new_version'] = new_version
Exemple #12
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        # Try to make sure that the suggestion for next version after
        # 1.1.19 is not 1.1.110, but 1.1.20.
        current_split = current.split('.')
        major = '.'.join(current_split[:-1])
        minor = current_split[-1]
        try:
            minor = int(minor) + 1
            suggestion = '.'.join([major, str(minor)])
        except ValueError:
            # Fall back on simply updating the last character when it is
            # an integer.
            try:
                last = int(current[-1]) + 1
                suggestion = current[:-1] + str(last)
            except ValueError:
                logger.warn("Version does not end with a number, so we can't "
                            "calculate a suggestion for a next version.")
                suggestion = None
        print("Current version is %s" % current)
        q = "Enter new development version ('.dev0' will be appended)"
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        self.data['new_version'] = version
        dev_version = self.data['dev_version_template'] % self.data
        self.data['dev_version'] = dev_version
        logger.info("New version string is %s",
                    dev_version)
Exemple #13
0
 def _release(self, package):
     version = utils.cleanup_version(
         BaseVersionControl()._extract_version()
     )
     os.system(self.releasercmd)
     return version