def test_packaging(c, package, sanity, alt_python=None):
    """
    Execute a wipe-build-install-test cycle for a given packaging config.

    Ideally, tests everything but actual upload to package index.

    When possible, leverages in-process calls to other packaging tasks.

    :param str package: Package name to uninstall before testing installation.
    :param str sanity: Sanity-check command string to run.
    :param str alt_python:
        Path to alternate virtualenv's Python interpreter. If given, will also
        enable a "2 vs 3" mode during wheel installation testing, which will
        select only the interpreter-family-appropriate wheel (going by
        ``$TRAVIS_PYTHON_VERSION``.)
    """
    # Use an explicit directory for building so we can reference after
    path = "tmp"
    # Echo on please
    c.config.run.echo = True
    # Ensure no GPG signing is attempted.
    c.packaging.sign = False
    # Publish in dry-run context, to explicit (non-tmp) directory.
    publish(c, dry_run=True, directory=path, alt_python=alt_python)
    # Various permutations of nuke->install->sanity test, as needed
    # TODO: normalize sdist so it's actually a config option, rn is kwarg-only
    globs = ["*.tar.gz"]
    if c.packaging.wheel:
        if alt_python:
            # TODO: the original .travis.yml was structured with logic this
            # way; I don't recall if it was purposeful or if an 'if/else' would
            # suffice instead.
            # TODO: shouldn't we just be able to use internal Python hints
            # about this now anyways (eg `sys.version`)? Will that work for
            # pypy and pypy3?
            if PYTHON.startswith("3") or PYTHON == "pypy3":
                globs.append("*py3*.whl")
            if PYTHON.startswith("2") or PYTHON == "pypy":
                globs.append("*py2*.whl")
        else:
            globs.append("*.whl")
    for glob in globs:
        c.run("pip uninstall -y {0}".format(package), warn=True)
        c.run("pip install tmp/dist/{0}".format(glob))
        c.run(sanity)
def test_packaging ( c , package , sanity , alt_python = None ) : path = "tmp" c . config . run . echo = True c . packaging . sign = False publish ( c , dry_run = True , directory = path , alt_python = alt_python ) globs = [ "*.tar.gz" ] if c . packaging . wheel : if alt_python : if PYTHON . startswith ( "3" ) or PYTHON == "pypy3" : globs . append ( "*py3*.whl" ) if PYTHON . startswith ( "2" ) or PYTHON == "pypy" : globs . append ( "*py2*.whl" ) else : globs . append ( "*.whl" ) for glob in globs : c . run ( "pip uninstall -y {0}" . format ( package ) , warn = True ) c . run ( "pip install tmp/dist/{0}" . format ( glob ) ) c . run ( sanity )
Execute a wipe-build-install-test cycle for a given packaging config.

    Ideally, tests everything but actual upload to package index.

    When possible, leverages in-process calls to other packaging tasks.

    :param str package: Package name to uninstall before testing installation.
    :param str sanity: Sanity-check command string to run.
    :param str alt_python:
        Path to alternate virtualenv's Python interpreter. If given, will also
        enable a "2 vs 3" mode during wheel installation testing, which will
        select only the interpreter-family-appropriate wheel (going by
        ``$TRAVIS_PYTHON_VERSION``.)