Beispiel #1
0
def install_from_local() -> None:
    dist_folder = "dist"

    if os.path.isdir(dist_folder):
        shutil.rmtree(dist_folder)
    args = [
        ConfigData.python,
        "setup.py",
        "sdist",
    ]
    if ConfigData.setup_quiet:
        args.extend(["--quiet"])
    check_call_collect(args)
    files = list(os.listdir(dist_folder))
    assert len(files) == 1, f"too many files in {dist_folder}"
    new_file = os.path.join(dist_folder, files[0])
    args = []
    if ConfigData.use_sudo:
        args.extend(["sudo", "-H"])
    args.extend([ConfigData.pip, "install", "--quiet", "--upgrade", new_file])
    if ConfigData.pip_quiet:
        args.extend(["--quiet"])
    if ConfigData.install_in_user_folder:
        args.extend(["--user"])
    check_call_collect(args)
Beispiel #2
0
def package_it() -> None:
    """
    package our module
    """
    args = [
        ConfigData.python,
        "setup.py",
    ]
    if ConfigData.upload_sdist:
        args.append("sdist")
    if ConfigData.upload_wheel:
        args.append("bdist_wheel")
    check_call_collect(args)
Beispiel #3
0
def upload_by_gemfury() -> None:
    """
    upload to gemfury

    The command line is the one recommended by gemfury at
    https://manage.fury.io/dashboard/[username]/push
    """
    package_it()
    if ConfigData.check_before_upload:
        check_by_twine()
    check_call_collect([
        "fury",
        "push",
        get_package_filename(),
        f"--as={ConfigData.gemfury_user}",
    ])
Beispiel #4
0
def upload_by_twine() -> None:
    """
    upload by twine
    """
    package_it()
    if ConfigData.check_before_upload:
        check_by_twine()
    args = [
        "twine",
        "upload",
    ]
    if ConfigData.upload_sdist:
        args.append(get_package_filename())
    if ConfigData.upload_wheel:
        args.append(get_package_wheelname())
    check_call_collect(args)
Beispiel #5
0
def do_prerequisites(packages: List[str] = None) -> None:
    """
    Gather all prerequisites into a single folder
    """
    if os.path.exists(ConfigData.wheel_folder):
        shutil.rmtree(ConfigData.wheel_folder)
    os.mkdir(ConfigData.wheel_folder)
    args = [
        ConfigData.pip,
        "wheel",
        "--wheel-dir",
        ConfigData.wheel_folder,
    ]
    if packages is None:
        args.extend([
            "--requirement",
            ConfigData.requirements,
        ])
    else:
        args.extend(packages)
    check_call_collect(args)
Beispiel #6
0
def install_from_remote() -> None:
    args = []
    if ConfigData.use_sudo:
        args.extend(["sudo", "-H"])
    args.extend([
        ConfigData.pip,
        "install",
        "--upgrade",
        f"{ConfigData.module_name}",
    ])
    if ConfigData.pip_quiet:
        args.extend(["--quiet"])
    if ConfigData.install_in_user_folder:
        args.extend(["--user"])
    check_call_collect(args)
    output, _ = check_call_collect([
        ConfigData.pip,
        "show",
        f"{ConfigData.module_name}",
    ])
    for line in output.split("\n"):
        if line.startswith("Version"):
            print(line)
Beispiel #7
0
def upload_by_setup() -> None:
    """
    upload by setup.py sdist upload

    This method still works although it is legacy

    see: python setup.py upload --help
    """
    args = [
        ConfigData.python,
        "setup.py",
    ]
    if ConfigData.upload_sdist:
        args.append("sdist")
    if ConfigData.upload_wheel:
        args.append("bdist_wheel")
    args.extend([
        "upload",
        # this means which repository to upload too
        # the default is https://upload.pypi.org/legacy/ and it works
        # '-r',
        # 'pypi',
    ])
    check_call_collect(args)
Beispiel #8
0
def check_by_twine() -> None:
    """
    check by twine
    """
    args = [
        "twine",
        "check",
    ]
    to_check = 0
    if ConfigData.upload_sdist:
        args.append(get_package_filename())
        to_check += 1
    if ConfigData.upload_wheel:
        args.append(get_package_wheelname())
        to_check += 1
    (out, err) = check_call_collect(args)
    out_lines = out.rstrip().split("\n")
    if len(out_lines) > to_check:
        print(out, end="", file=sys.stdout)
        print(err, end="", file=sys.stderr)
        sys.exit(1)
Beispiel #9
0
def register_by_twine() -> None:
    """
    register via the twine method
    """
    check_call_collect(["twine", "register", get_package_filename()])
Beispiel #10
0
def register_by_setup() -> None:
    """
    register via setup.py register
    """
    check_call_collect(
        [ConfigData.python, "setup.py", "register", "-r", "pypi"])
Beispiel #11
0
def git_clean_full() -> None:
    """
    Clean the current git repo in a strict way
    """
    check_call_collect(["git", "clean", "-qffxd"])