def pypi(): module_name, dry_run, _ = config.common_arguments() tmp_dir = make_virtualenv() install_cmd = '%s/bin/pip install %s' % (tmp_dir, module_name) package_index = 'pypi' pypi = config.arguments['--pypi'] if pypi: install_cmd += '-i %s' % pypi package_index = pypi try: result = shell.execute(install_cmd, dry_run=dry_run) if result: log.info('Successfully installed %s from %s', module_name, package_index) else: log.error('Failed to install %s from %s', module_name, package_index) verification.run_test_command() except: log.exception( 'error installing %s from %s', module_name, package_index ) raise Exception( 'Error installing %s from %s', module_name, package_index ) path(tmp_dir).rmtree(path(tmp_dir))
def tag(): _, dry_run, new_version = config.common_arguments() shell.handle_dry_run(sh.git.tag, ('-a', new_version, '-m', '"%s"' % new_version)) shell.handle_dry_run(sh.git.push, ('--tags'))
def pypi(): module_name, dry_run, _ = config.common_arguments() tmp_dir = make_virtualenv() install_cmd = '%s/bin/pip install %s' % (tmp_dir, module_name) package_index = 'pypi' pypi = config.arguments['--pypi'] if pypi: install_cmd += '-i %s' % pypi package_index = pypi try: result = shell.execute(install_cmd, dry_run=dry_run) if result: log.info('Successfully installed %s from %s', module_name, package_index) else: log.error('Failed to install %s from %s', module_name, package_index) verification.run_test_command() except: log.exception('error installing %s from %s', module_name, package_index) raise Exception('Error installing %s from %s', module_name, package_index) path(tmp_dir).rmtree(path(tmp_dir))
def commit_version_change(): module_name, dry_run, new_version = config.common_arguments() shell.handle_dry_run( sh.git.commit, ('-m', new_version, '%s/__init__.py' % module_name, config.CHANGELOG)) shell.handle_dry_run(sh.git.push, ())
def bump_version(): module_name, dry_run, new_version = config.common_arguments() attributes.replace_attribute( module_name, '__version__', new_version, dry_run=dry_run)
def commit_version_change(): module_name, dry_run, new_version = config.common_arguments() shell.handle_dry_run( sh.git.commit, ('-m', new_version, '%s/__init__.py' % module_name, config.CHANGELOG) ) shell.handle_dry_run(sh.git.push, ())
def tag(): _, dry_run, new_version = config.common_arguments() shell.handle_dry_run( sh.git.tag, ('-a', new_version, '-m', '"%s"' % new_version) ) shell.handle_dry_run(sh.git.push, ('--tags'))
def test_common_arguments(self): expected_arguments = ( 'changes', False, '0.0.1', ) self.assertEquals( expected_arguments, config.common_arguments() )
def upload(): module_name, dry_run, new_version = config.common_arguments() pypi = config.arguments['--pypi'] upload_args = 'setup.py clean sdist upload'.split(' ') if pypi: upload_args.extend(['-r', pypi]) upload_result = shell.handle_dry_run(sh.python, tuple(upload_args)) if not upload_result: raise Exception('Error uploading') else: log.info('Succesfully uploaded %s %s', module_name, new_version)
def replace_sha_with_commit_link(git_log_content): repo_url = attributes.extract_attribute(config.common_arguments()[0], '__url__') for index, line in enumerate(git_log_content): # http://stackoverflow.com/a/468378/5549 sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line) if sha1_re: sha1 = sha1_re.group() new_line = line.replace( sha1, '[%s](%s/commit/%s)' % (sha1, repo_url, sha1)) log.debug('old line: %s\nnew line: %s', line, new_line) git_log_content[index] = new_line return git_log_content
def changelog(): module_name, dry_run, new_version = config.common_arguments() changelog_content = [ '\n## [%s](%s/compare/%s...%s)\n\n' % ( new_version, attributes.extract_attribute(module_name, '__url__'), version.current_version(module_name), new_version, ) ] git_log_content = None try: git_log_content = sh.git.log( '--oneline', '--no-merges', '%s..master' % version.current_version(module_name), _tty_out=False ).split('\n') log.debug('content: %s' % git_log_content) except: log.warn('Error diffing previous version, initial release') git_log_content = sh.git.log( '--oneline', '--no-merges', _tty_out=False ).split('\n') git_log_content = replace_sha_with_commit_link(git_log_content) log.debug('content: %s' % git_log_content) # makes change log entries into bullet points if git_log_content: [ changelog_content.append('* %s\n' % line) if line else line for line in git_log_content[:-1] ] write_new_changelog( module_name, config.CHANGELOG, changelog_content, dry_run=dry_run ) log.info('Added content to CHANGELOG.md')
def changelog(): module_name, dry_run, new_version = config.common_arguments() changelog_content = [ '\n## [%s](%s/compare/%s...%s)\n\n' % ( new_version, attributes.extract_attribute(module_name, '__url__'), version.current_version(module_name), new_version, ) ] git_log_content = None try: git_log_content = sh.git.log('--oneline', '--no-merges', '%s..master' % version.current_version(module_name), _tty_out=False).split('\n') log.debug('content: %s' % git_log_content) except: log.warn('Error diffing previous version, initial release') git_log_content = sh.git.log('--oneline', '--no-merges', _tty_out=False).split('\n') git_log_content = replace_sha_with_commit_link(git_log_content) log.debug('content: %s' % git_log_content) # makes change log entries into bullet points if git_log_content: [ changelog_content.append('* %s\n' % line) if line else line for line in git_log_content[:-1] ] write_new_changelog(module_name, config.CHANGELOG, changelog_content, dry_run=dry_run) log.info('Added content to CHANGELOG.md')
def replace_sha_with_commit_link(git_log_content): repo_url = attributes.extract_attribute( config.common_arguments()[0], '__url__' ) for index, line in enumerate(git_log_content): # http://stackoverflow.com/a/468378/5549 sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line) if sha1_re: sha1 = sha1_re.group() new_line = line.replace( sha1, '[%s](%s/commit/%s)' % (sha1, repo_url, sha1) ) log.debug('old line: %s\nnew line: %s', line, new_line) git_log_content[index] = new_line return git_log_content
def install(): module_name, dry_run, new_version = config.common_arguments() commands = ['setup.py', 'clean', 'sdist'] if probe.has_requirement('wheel'): commands.append('bdist_wheel') result = shell.handle_dry_run(sh.python, tuple(commands)) if result: tmp_dir = make_virtualenv() package_name = config.arguments.get('--package-name') or module_name try: virtualenv.install_sdist( config.arguments['<module_name>'], 'dist/%s-%s.tar.gz' % (package_name, new_version), '%s/bin/python' % tmp_dir) log.info('Successfully installed %s sdist', module_name) if verification.run_test_command(): log.info('Successfully ran test command: %s', config.arguments['--test-command']) except: raise Exception('Error installing %s sdist', module_name) path(tmp_dir).rmtree(path(tmp_dir))
def install(): module_name, dry_run, new_version = config.common_arguments() commands = ['setup.py', 'clean', 'sdist'] if probe.has_requirement('wheel'): commands.append('bdist_wheel') result = shell.handle_dry_run(sh.python, tuple(commands)) if result: tmp_dir = make_virtualenv() package_name = config.arguments.get('--package-name') or module_name try: virtualenv.install_sdist( config.arguments['<module_name>'], 'dist/%s-%s.tar.gz' % (package_name, new_version), '%s/bin/python' % tmp_dir ) log.info('Successfully installed %s sdist', module_name) if verification.run_test_command(): log.info('Successfully ran test command: %s', config.arguments['--test-command']) except: raise Exception('Error installing %s sdist', module_name) path(tmp_dir).rmtree(path(tmp_dir))