Example #1
0
File: build.py Project: uxrxts/pyre
import sys
import os
from headlines import h2, h3
from buildlib.utils.yaml import load_yaml
from buildlib.cmds.build import build_python_wheel, inject_interface_txt_into_readme_md

CWD = os.getcwd()
CFG = load_yaml(CWD + '/CONFIG.yaml', keep_order=True)


def build_sequence() -> None:
    print(h2('Build'))

    result = []

    interface_file = CWD + '/' + CFG['proj_package_name'] + '/cli/interface.txt'
    result.append(inject_interface_txt_into_readme_md(interface_file))

    result.append(build_python_wheel(clean_dir=True))

    print(h3('Build Results'))
    for command in result:
        print(command.return_msg)


def execute() -> None:
    try:
        build_sequence()
    except KeyboardInterrupt:
        print('\n\nScript aborted by user. (KeyboardInterrupt)')
        sys.exit(1)
Example #2
0
def bump_routine(
    should_bump_version: Optional[bool] = None,
    should_build_wheel: Optional[bool] = None,
    should_bump_git: Optional[bool] = None,
    should_push_registry: Optional[bool] = None,
) -> None:
    """"""
    print('')

    results = []
    cfg_file = 'CONFIG.yaml'

    cur_version: str = load_yaml(file=cfg_file, keep_order=True).get('version')

    if should_bump_version is None:
        should_bump_version: bool = build.prompt.should_update_version(
            default='y')

    if should_bump_version:
        version: str = semver.prompt.semver_num_by_choice(
            cur_version=cur_version)
    else:
        version: str = cur_version

    if should_build_wheel is None:
        should_build_wheel: bool = build.prompt.should_build_wheel(default='y')

    if should_bump_version:
        results.append(
            build.update_version_num_in_cfg_yaml(config_file=cfg_file,
                                                 semver_num=version))

    if should_build_wheel:
        results.append(build.build_python_wheel(clean_dir=True))

    if should_push_registry is None:
        should_push_registry: bool = build.prompt.should_push_pypi(
            default='y' if should_bump_version else 'n')

    if should_bump_git is None:
        should_bump_git: bool = git.prompt.should_run_any('y')

    if should_bump_git:
        should_bump_git: bool = all(
            [git.prompt.confirm_status('y'),
             git.prompt.confirm_diff('y')])

    if should_bump_git:
        should_add_all: bool = git.prompt.should_add_all(default='y')

        should_commit: bool = git.prompt.should_commit(default='y')

        if should_commit:
            commit_msg: str = git.prompt.commit_msg()

        should_tag: bool = git.prompt.should_tag(
            default='y' if should_bump_version else 'n')

        should_push_git: bool = git.prompt.should_push(default='y')

        if any([should_tag, should_push_git]):
            branch: str = git.prompt.branch()

        if should_add_all:
            results.append(git.add_all())

        if should_commit:
            results.append(git.commit(commit_msg))

        if should_tag:
            results.append(git.tag(version, branch))

        if should_push_git:
            results.append(git.push(branch))

    if should_push_registry:
        results.append(build.push_python_wheel_to_pypi(clean_dir=True))

    print(h3('Publish Results'))

    for i, result in enumerate(results):
        print(result.summary)
Example #3
0
from setuptools import setup, find_packages
from codecs import open
from buildlib.utils.yaml import load_yaml

with open('README.md') as f:
    long_description = f.read()

config = load_yaml('CONFIG.yaml')

setup(name=config['public_name'],
      version=config['version'],
      author=config['author'],
      author_email=config['author_email'],
      maintainer=config['maintainer'],
      maintainer_email=config['maintainer_email'],
      url=config['url'],
      description=config['description'],
      long_description=long_description,
      download_url=config['url'] + '/tarball/' + config['version'],
      license=config['license'],
      keywords=config['keywords'],
      include_package_data=True,
      platforms=config['pypi']['platforms'],
      classifiers=config['pypi']['classifiers'],
      install_requires=config['pypi']['install_requires'],
      packages=find_packages(where='.',
                             exclude=('tests', 'tests.*', 'venv-processy',
                                      'venv-processy.*')),
      package_dir=config['pypi']['package_dir'],
      package_data=config['pypi']['package_data'],
      data_files=config['pypi']['data_files'],
Example #4
0
from typing import Union
from buildlib.utils import yaml
from buildlib.cmds import semver, build
from buildlib.cmds.git import sequence as git_seq
from cmdinter import CmdFuncResult

CFG_FILE = 'Project'
CFG = yaml.load_yaml(file=CFG_FILE, keep_order=True)

__version__ = CFG.get('version')


def get_version_from_user() -> str:
    """
    Get new Version number from user or use the one from CONFIG.yaml.
    """
    return semver.prompt.semver_num_by_choice(cur_version=CFG.get('version'))


def build_wheel(return_result=False, ) -> Union[CmdFuncResult, None]:
    """"""
    result = build.build_python_wheel(clean_dir=True)

    if return_result:
        return result
    else:
        print(f'\n{result.summary}')


def push_registry(return_result=False, ) -> Union[CmdFuncResult, None]:
    """"""
Example #5
0
def publish() -> None:
    """"""

    results = []
    cfg_file = 'CONFIG.yaml'

    cur_version: str = yaml.load_yaml(file=cfg_file,
                                      keep_order=True).get('version')

    should_update_version: bool = build.prompt.should_update_version(
        default='y')

    if should_update_version:
        version: str = semver.prompt.semver_num_by_choice(
            cur_version=cur_version)

    else:
        version: str = cur_version

    should_run_build_file: bool = build.prompt.should_run_build_file(
        default='y')

    if should_update_version:
        results.append(
            build.update_version_num_in_cfg_yaml(config_file=cfg_file,
                                                 semver_num=version))

    if should_run_build_file:
        results.append(build.run_build_file(build_file='build.py'))

    run_any_git: bool = git.prompt.should_run_any('y') \
                        and git.prompt.confirm_status('y') \
                        and git.prompt.confirm_diff('y')

    if run_any_git:
        should_add_all: bool = git.prompt.should_add_all(default='y')

        should_commit: bool = git.prompt.should_commit(default='y')

        if should_commit:
            commit_msg: str = git.prompt.commit_msg()

        should_tag: bool = git.prompt.should_tag(
            default='y' if should_update_version else 'n')

        should_push_git: bool = git.prompt.should_push(default='y')

        if any([should_tag, should_push_git]):
            branch: str = git.prompt.branch()

    should_push_gemfury: bool = build.prompt.should_push_gemfury(default='y')

    if run_any_git:
        if should_add_all:
            results.append(git.add_all())

        if should_commit:
            results.append(git.commit(commit_msg))

        if should_tag:
            results.append(git.tag(version, branch))

        if should_push_git:
            results.append(git.push(branch))

    if should_push_gemfury:
        results.append(
            build.push_python_wheel_to_gemfury(
                wheel_file=wheel.find_python_wheel(wheel_dir='dist',
                                                   semver_num=version)))

    print(h3('Publish Results'))

    for i, result in enumerate(results):
        print(result.return_msg)
Example #6
0
from setuptools import setup, find_packages
from codecs import open
from buildlib.utils.yaml import load_yaml

with open('README.md') as f:
    long_description = f.read()

config = load_yaml('Project')

setup(name=config['public_name'],
      version=config['version'],
      author=config['author'],
      author_email=config['author_email'],
      maintainer=config['maintainer'],
      maintainer_email=config['maintainer_email'],
      url=config['url'],
      description=config['description'],
      long_description=long_description,
      download_url=config['url'] + '/tarball/' + config['version'],
      license=config['license'],
      keywords=config['keywords'],
      include_package_data=True,
      platforms=config['pypi']['platforms'],
      classifiers=config['pypi']['classifiers'],
      install_requires=config['pypi']['install_requires'],
      packages=find_packages(where='.',
                             exclude=('tests', 'tests.*', 'venv-cmdinter',
                                      'venv-cmdinter.*')),
      package_dir=config['pypi']['package_dir'],
      package_data=config['pypi']['package_data'],
      data_files=config['pypi']['data_files'],