Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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))
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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')
Ejemplo n.º 8
0
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')
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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)
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
def test_handle_dry_run():
    assert '' == shell.dry_run('diff README.md README.md', False)
Ejemplo n.º 17
0
def test_handle_dry_run_true():
    assert shell.dry_run('diff README.md README.md', True)
Ejemplo n.º 18
0
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)