How to use the twine.commands function in twine

To help you get started, we’ve selected a few twine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / twine / tests / test_check.py View on Github external
def test_check_passing_distribution(monkeypatch):
    renderer = pretend.stub(render=pretend.call_recorder(lambda *a, **kw: "valid"))
    package = pretend.stub(
        metadata_dictionary=lambda: {
            "description": "blah",
            "description_content_type": "text/markdown",
        }
    )
    output_stream = io.StringIO()
    warning_stream = ""

    monkeypatch.setattr(check, "_RENDERERS", {None: renderer})
    monkeypatch.setattr(commands, "_find_dists", lambda a: ["dist/dist.tar.gz"])
    monkeypatch.setattr(
        package_file,
        "PackageFile",
        pretend.stub(from_filename=lambda *a, **kw: package),
    )
    monkeypatch.setattr(check, "_WarningStream", lambda: warning_stream)

    assert not check.check(["dist/*"], output_stream=output_stream)
    assert output_stream.getvalue() == "Checking dist/dist.tar.gz: PASSED\n"
    assert renderer.render.calls == [pretend.call("blah", stream=warning_stream)]
github pypa / twine / tests / test_commands.py View on Github external
def test_ensure_wheel_files_uploaded_first():
    files = commands._group_wheel_files_first(
        ["twine/foo.py", "twine/first.whl", "twine/bar.py", "twine/second.whl"]
    )
    expected = [
        "twine/first.whl",
        "twine/second.whl",
        "twine/foo.py",
        "twine/bar.py",
    ]
    assert expected == files
github pypa / twine / tests / test_check.py View on Github external
def test_check_no_distributions(monkeypatch):
    stream = io.StringIO()

    monkeypatch.setattr(commands, "_find_dists", lambda a: [])

    assert not check.check(["dist/*"], output_stream=stream)
    assert stream.getvalue() == "No files to check.\n"
github pypa / twine / tests / test_commands.py View on Github external
def test_ensure_if_no_wheel_files():
    files = commands._group_wheel_files_first(["twine/foo.py", "twine/bar.py"])
    expected = ["twine/foo.py", "twine/bar.py"]
    assert expected == files
github rebase-helper / rebase-helper / containers / webhooks.py View on Github external
def release(url, tag):
        with tempfile.TemporaryDirectory() as wd:
            os.chdir(wd)
            repo = git.Repo.clone_from(url, wd)
            repo.git.checkout(tag)
            sys.path.insert(0, wd)
            distutils.core.run_setup(os.path.join(wd, 'setup.py'),
                                     ['sdist', 'bdist_wheel', '--universal'])
            twine.commands.upload.main([os.path.join(wd, 'dist', '*')])
github pypa / twine / twine / commands / upload.py View on Github external
def upload(upload_settings: settings.Settings, dists: List[str]) -> None:
    dists = commands._find_dists(dists)
    # Determine if the user has passed in pre-signed distributions
    signatures = {os.path.basename(d): d for d in dists if d.endswith(".asc")}
    uploads = [i for i in dists if not i.endswith(".asc")]

    upload_settings.check_repository_url()
    repository_url = cast(str, upload_settings.repository_config["repository"])
    print(f"Uploading distributions to {repository_url}")

    packages_to_upload = [
        _make_package(filename, signatures, upload_settings) for filename in uploads
    ]

    repository = upload_settings.create_repository()
    uploaded_packages = []

    for package in packages_to_upload:
github pypa / twine / twine / commands / check.py View on Github external
def check(dists: List[str], output_stream: IO[str] = sys.stdout) -> bool:
    uploads = [i for i in commands._find_dists(dists) if not i.endswith(".asc")]
    if not uploads:  # Return early, if there are no files to check.
        output_stream.write("No files to check.\n")
        return False

    failure = False

    for filename in uploads:
        output_stream.write("Checking %s: " % filename)
        render_warning_stream = _WarningStream()
        warnings, is_ok = _check_file(filename, render_warning_stream)

        # Print the status and/or error
        if not is_ok:
            failure = True
            output_stream.write("FAILED\n")
github pypa / twine / twine / application.py View on Github external
parser = argparse.ArgumentParser(prog="twine")
        parser.add_argument(
            "-v", "--verbose",
            dest="_verbose",
            action="count",
            default=0,
        )
        parser.add_argument(
            "-q", "--quiet",
            dest="_quiet",
            action="store_true",
            default=False,
        )

        _generate_parser(parser, twine.commands.__commands__)

        args = parser.parse_args(argv)

        logging.config.dictConfig({
            "version": 1,
            "disable_existing_loggers": False,
            "formatters": {
                "simple": {
                    "format": "%(message)s",
                },
            },
            "handlers": {
                "console": {
                    "level": "DEBUG",
                    "class": "logging.StreamHandler",
                    "formatter": "simple",