예제 #1
0
def deploy(usr, pwd, path=getcwd(), venv=None):
    """release on `pypi.org`"""
    log(INFO, ICONS["deploy"] + 'deploy release on `pypi.org`')
    # check dist
    module('twine', 'check --strict dist/*', path=path, venv=venv)
    # push to pypi.org
    return module("twine",
                  "upload -u %s -p %s dist/*" % (usr, pwd),
                  level=LEVEL,
                  path=path,
                  venv=venv)
예제 #2
0
def build(path=getcwd(), venv=None):
    """build package distribution"""
    log(INFO, ICONS["build"] + 'build package distribution')
    code = False
    code = code or _python("setup.py build",
                           level=LEVEL, path=path, venv=venv)
    code = code or _python("setup.py sdist --formats=zip",
                           level=LEVEL, path=path, venv=venv)
    code = code or module("twine", "check --strict dist/*",
                          level=LEVEL, path=path, venv=venv)
    return code
예제 #3
0
def requirements(path=getcwd(), freeze_file=FREEZE_FILE, venv=None):
    """manage requirements (dependencies) in `requirements.txt`
        and `upgrade_requirements.txt`"""
    log(INFO, ICONS["setup"] + "setup environment requirements")

    code = False
    if freeze_file and not exists(join(path, freeze_file)):
        code = code or module(
            'pip', "freeze > %s" % freeze_file, path=path, venv=venv)

    if exists(join(path, "requirements.txt")):
        code = code or module(
            'pip', "install -r requirements.txt", path=path, venv=venv)

    if exists(join(path, "upgrade_requirements.txt")):
        code = code or module('pip',
                              "install --upgrade -r upgrade_requirements.txt",
                              path=path,
                              venv=venv)
    return code
예제 #4
0
def rollback(path=getcwd(), freeze_file=FREEZE_FILE, venv=None):
    """rollback site-packages"""
    log(INFO, ICONS["clean"] + 'rollback site-packages')
    code = False
    if exists(join(path, freeze_file)):
        code = code or module(
            'pip',
            "freeze --exclude-editable > %s" % TEMP_REMOVE_FILE,
            path=path,
            venv=venv)
        code = code or module('pip',
                              "uninstall -r %s -y" % TEMP_REMOVE_FILE,
                              path=path,
                              venv=venv)
        del_tree(TEMP_REMOVE_FILE)
        code = code or module('pip',
                              "install --upgrade -r %s" % freeze_file,
                              path=path,
                              venv=venv)
        del_tree(join(path, freeze_file))
    return code
예제 #5
0
def install(pkg='.', path=getcwd(), venv=None):
    """(re)install current project via `pip install -e .`"""
    log(INFO, ICONS["install"] + 'install project via pip install -e')
    if exists(join(path, 'setup.py')) or exists(join(path, 'setup.cfg')):
        return module('pip',
                      "install --upgrade -e %s" % pkg,
                      path=path,
                      venv=venv)
    log(
        WARN, ICONS["warn"] + 'could not install project via pip install -e '
        '(setup.py or setup.cfg not found in %s)' % path)
    return 1
예제 #6
0
def uninstall(pkg=basename(getcwd()), path=getcwd(), venv=None):
    """uninstall current project via `pip uninstall`"""
    log(INFO, ICONS["uninstall"] + 'uninstall project via pip uninstall')
    # code = code or del_tree(basename(path) + ".egg-info", ".eggs")
    return module('pip', "uninstall -y %s" % pkg, path=path, venv=venv)
예제 #7
0
def upgrade(pkg='pip', path=getcwd(), venv=None):
    """upgrade python library [PKG] via `pip`"""
    log(INFO, ICONS["upgrade"] + 'upgrade `%s`' % pkg)
    return module('pip', 'install --upgrade %s' % pkg, path=path, venv=venv)
예제 #8
0
def auxilium(command, level=logging.INFO, path=None):
    return module('auxilium', command, level=level, path=path)