author David Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 22:46:44 +0100
changeset 1768 48066736c862
parent 1759 b9915807bddb
child 1621 faa3d4a5bafc
permissions -rw-r--r--
[recipe] make recipe names a bit more consistant

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from os.path import exists, join, abspath

import apycotlib

from checkers.apycot import BaseChecker

class PypiUploader(BaseChecker):
    id = 'pypi.upload'

    options_def = {
        'verbose': {
            'type': 'int', 'default': False,
            'help': 'set verbose mode'

    def do_check(self, test):
        """run the distutils 'setup.py register sdist upload' command

        The user running the narval bot must have a properly filled
        .pypirc file
        path = test.project_path()
        if not exists(join(path, 'setup.py')):
            raise apycotlib.SetupException('No file %s' % abspath(join(path, 'setup.py')))
        python = apycotlib.pyversions(test)[0]
        cmdargs = [python, 'setup.py', 'register', 'sdist', 'upload']
        if not self.options.get('verbose'):
        cmd = apycotlib.Command(self.writer, cmdargs, raises=True, cwd=path)
        cmdstatus = cmd.run()
        if cmdstatus == apycotlib.SUCCESS:
            self.writer.info('uploaded tarball to pypi')
        return cmdstatus

apycotlib.register('checker', PypiUploader)