def tag_and_push(context): """Tags your git repo with the new version number""" tag_option = '--annotate' if probe.has_signing_key(context): tag_option = '--sign' shell.dry_run(TAG_TEMPLATE % (tag_option, context.new_version, context.new_version), context.dry_run) shell.dry_run('git push --tags', context.dry_run)
def tag_and_push(context): """Tags your git repo with the new version number""" tag_option = '--annotate' if probe.has_signing_key(context): tag_option = '--sign' shell.dry_run( TAG_TEMPLATE % (tag_option, context.new_version, context.new_version), context.dry_run) shell.dry_run('git push --tags', context.dry_run)
def install_from_pypi(context): """Attempts to install your package from pypi.""" tmp_dir = venv.create_venv() install_cmd = '%s/bin/pip install %s' % (tmp_dir, context.module_name) package_index = 'pypi' if context.pypi: install_cmd += '-i %s' % context.pypi package_index = context.pypi try: result = shell.dry_run(install_cmd, context.dry_run) if not context.dry_run and not result: log.error('Failed to install %s from %s', context.module_name, package_index) else: log.info('Successfully installed %s from %s', context.module_name, package_index) except Exception as e: error_msg = 'Error installing %s from %s' % (context.module_name, package_index) log.exception(error_msg) raise Exception(error_msg, e) path(tmp_dir).rmtree(path(tmp_dir))
def install_from_pypi(context): """Attempts to install your package from pypi.""" tmp_dir = venv.create_venv() install_cmd = '%s/bin/pip install %s' % (tmp_dir, context.module_name) package_index = 'pypi' if context.pypi: install_cmd += '-i %s' % context.pypi package_index = context.pypi try: result = shell.dry_run(install_cmd, context.dry_run) if not context.dry_run and not result: log.error('Failed to install %s from %s', context.module_name, package_index) else: log.info('Successfully installed %s from %s', context.module_name, package_index) except Exception as e: error_msg = 'Error installing %s from %s' % (context.module_name, package_index) log.exception(error_msg) raise Exception(error_msg, e)
def build_distributions(context): """Builds package distributions""" rmtree('dist', ignore_errors=True) build_package_command = 'python setup.py clean sdist bdist_wheel' result = shell.dry_run(build_package_command, context.dry_run) packages = Path('dist').files() if not context.dry_run else "nothing" if not result: raise Exception('Error building packages: %s' % result) else: log.info('Built %s' % ', '.join(packages)) return packages
def build_distributions(context): """Builds package distributions""" rmtree('dist', ignore_errors=True) build_package_command = 'python setup.py clean sdist bdist_wheel' result = shell.dry_run(build_package_command, context.dry_run) packages = Path('dist').files() if not context.dry_run else "nothing" if not result: raise Exception('Error building packages: %s' % result) else: log.info('Built %s' % ', '.join(packages)) return packages
def upload_package(context): """Uploads your project packages to pypi with twine.""" if not context.dry_run and build_package(context): upload_args = 'twine upload ' upload_args += ' '.join(path('dist').files()) if context.pypi: upload_args += ' -r %s' % context.pypi upload_result = shell.dry_run(upload_args, context.dry_run) if not context.dry_run and not upload_result: raise Exception('Error uploading: %s' % upload_result) else: log.info('Successfully uploaded %s:%s', context.module_name, context.new_version) else: log.info('Dry run, skipping package upload')
def upload_package(context): """Uploads your project packages to pypi with twine.""" if not context.dry_run and build_distributions(context): upload_args = 'twine upload ' upload_args += ' '.join(Path('dist').files()) if context.pypi: upload_args += ' -r %s' % context.pypi upload_result = shell.dry_run(upload_args, context.dry_run) if not context.dry_run and not upload_result: raise Exception('Error uploading: %s' % upload_result) else: log.info('Successfully uploaded %s:%s', context.module_name, context.new_version) else: log.info('Dry run, skipping package upload')
def run_test_command(test_command): if test_command: result = shell.dry_run(test_command, context.dry_run) log.info('Test command "%s", returned %s', test_command, result) return True
def commit_version_change(context): # TODO: signed commits? shell.dry_run( COMMIT_TEMPLATE % (context.new_version, context.module_name), context.dry_run ) shell.dry_run('git push', context.dry_run)
def run_test_command(test_command): if test_command: result = shell.dry_run(test_command, context.dry_run) log.info('Test command "%s", returned %s', test_command, result) return True
def commit_version_change(context): shell.dry_run('git commit -m %s %s/__init__.py CHANGELOG.md' % (context.new_version, context.module_name), context.dry_run) shell.dry_run('git push', context.dry_run)
def commit_version_change(context): # TODO: signed commits? shell.dry_run(COMMIT_TEMPLATE % (context.new_version, context.module_name), context.dry_run) shell.dry_run('git push', context.dry_run)
def tag_and_push(context): """Tags your git repo with the new version number""" shell.dry_run('git tag -a %s -m %s' % (context.new_version, context.new_version), context.dry_run) shell.dry_run('git push --tags', context.dry_run)
def commit_version_change(context): shell.dry_run('git commit -m %s %s/__init__.py CHANGELOG.md' % (context.new_version, context.module_name), context.dry_run) shell.dry_run('git push', context.dry_run)
def test_handle_dry_run(): assert '' == shell.dry_run('diff README.md README.md', False)
def test_handle_dry_run_true(): assert shell.dry_run('diff README.md README.md', True)
def tag_and_push(context): """Tags your git repo with the new version number""" shell.dry_run('git tag -a %s -m %s' % (context.new_version, context.new_version), context.dry_run) shell.dry_run('git push --tags', context.dry_run)