Exemple #1
0
def test_recipes_to_build():
    clear_binstar(CLIENT, OWNER)

    # Build a recipe.
    meta = build(MetaData(os.path.join(RECIPES_DIR, 'recipe1')))
    upload(CLIENT, meta, OWNER, channels=['testing'])

    metas = fetch_metas(RECIPES_DIR)
    metas.sort(key=lambda meta: meta.name())

    result = list(recipes_to_build(CLIENT, OWNER, channel='testing', recipe_metas=metas))
    # The ones we need to build are all but the first.
    assert_metas_equal(result, metas[1:])
def main():
    # Get our binstar client from the Builder to get BINSTAR_TOKEN obfuscation
    # in windows builds.
    builder = Builder(RECIPE_FOLDER, BINSTAR_CHANNEL, 'main')
    try:
        bdists = os.listdir(BDIST_CONDA_FOLDER)
    except (OSError):
        # Nothing to upload.
        return

    conda_builds_dir = os.path.join(config.default_prefix, 'conda-bld',
                                    config.subdir)
    built_packages = glob.glob(os.path.join(conda_builds_dir, '*.tar.bz2'))
    for package in built_packages:
        _, package_file = os.path.split(package)
        # Work around packages having a hypen in their name
        name = package_file.split('-')
        name.pop(-1)
        name.pop(-1)
        name = "-".join(name)
        if name in bdists:
            # Need to upload this one...
            # First grab the metadata from the package, which requires
            # opening the file.

            # Not going to lie: after fighting with conda for 90 minutes to
            # construct a proper MetaData object from a built package, I give
            # up.

            # Instead, create an object with one method, dist, which returns
            # the build string and be done with it.
            class MetaData(object):
                def __init__(self, dist_info):
                    self._dist_info = dist_info

                def dist(self):
                    return self._dist_info

            meta = MetaData(package_file.split('.tar.bz2')[0])

            try:
                # Upload it
                upload(builder.binstar_cli, meta, BINSTAR_CHANNEL)
            except binstar_client.errors.Unauthorized:
                print("Not authorized to upload.")
def main():
    # Get our binstar client from the Builder to get BINSTAR_TOKEN obfuscation
    # in windows builds.
    builder = Builder(RECIPE_FOLDER, BINSTAR_CHANNEL, 'main')
    try:
        bdists = os.listdir(BDIST_CONDA_FOLDER)
    except (OSError):
        # Nothing to upload.
        return

    conda_builds_dir = os.path.join(config.default_prefix,
                                    'conda-bld', config.subdir)
    built_packages = glob.glob(os.path.join(conda_builds_dir, '*.tar.bz2'))
    for package in built_packages:
        _, package_file = os.path.split(package)
        # Work around packages having a hypen in their name
        name = package_file.split('-')
        name.pop(-1)
        name.pop(-1)
        name = "-".join(name)
        if name in bdists:
            # Need to upload this one...
            # First grab the metadata from the package, which requires
            # opening the file.

            # Not going to lie: after fighting with conda for 90 minutes to
            # construct a proper MetaData object from a built package, I give
            # up.

            # Instead, create an object with one method, dist, which returns
            # the build string and be done with it.
            class MetaData(object):
                def __init__(self, dist_info):
                    self._dist_info = dist_info

                def dist(self):
                    return self._dist_info

            meta = MetaData(package_file.split('.tar.bz2')[0])

            try:
                # Upload it
                upload(builder.binstar_cli, meta, BINSTAR_CHANNEL)
            except binstar_client.errors.Unauthorized:
                print("Not authorized to upload.")
Exemple #4
0
def test_leaky_add_to_channel():
    # A newer distribution (e.g. v0.2.0.dev) on a dev channel was getting promoted to the main channel
    # when an earlier version (e.g. v0.1.0) was being linked to main.
    clear_binstar(CLIENT, OWNER)
    # Build a recipe and upload the recipe to the testing channel.
    meta = MetaData(RECIPE_DEV)
    meta = build(meta)
    upload(CLIENT, meta, OWNER, channels=['testing'])

    # Build a recipe and upload the recipe to the testing channel.
    meta_eariler = MetaData(os.path.join(RECIPES_DIR, 'recipe1'))
    meta_eariler = build(meta_eariler)
    upload(CLIENT, meta_eariler, OWNER, channels=['testing'])

    add_distribution_to_channel(CLIENT, OWNER, meta_eariler, channel='main')

    assert_true(distribution_exists_on_channel(CLIENT, OWNER, meta_eariler, channel='main'))
    assert_false(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))
Exemple #5
0
def test_distribution_exists():
    clear_binstar(CLIENT, OWNER)

    # Build a recipe.
    meta = MetaData(RECIPE_DEV)
    meta = build(meta)

    # Check distribution exists returns false when there is no distribution.
    assert_false(distribution_exists(CLIENT, OWNER, meta))

    # upload the distribution 
    upload(CLIENT, meta, OWNER, channels=['testing'])

    # Check the distribution exists. Notice there is no channel being supplied here.
    assert_true(distribution_exists(CLIENT, OWNER, meta))

    # Check the distribution is on testing but not on main.
    assert_true(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='testing'))
    assert_false(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))

    add_distribution_to_channel(CLIENT, OWNER, meta, channel='main')
    # Check that the distribution has been added.
    assert_true(distribution_exists_on_channel(CLIENT, OWNER, meta, channel='main'))