コード例 #1
0
ファイル: test_create.py プロジェクト: Korijn/conda
def package_is_installed(prefix, dist, exact=False):
    packages = list(linked(prefix))
    if '::' not in text_type(dist):
        packages = [p.dist_name for p in packages]
    if exact:
        return dist in packages
    return any(p.startswith(dist) for p in packages)
コード例 #2
0
ファイル: env.py プロジェクト: Korijn/conda
def from_environment(name, prefix, no_builds=False, ignore_channels=False):
    """
        Get environment object from prefix
    Args:
        name: The name of environment
        prefix: The path of prefix
        no_builds: Whether has build requirement
        ignore_channels: whether ingore_channels

    Returns:     Environment obejct

    """
    installed = linked(prefix, ignore_channels=ignore_channels)
    conda_pkgs = copy(installed)
    # json=True hides the output, data is added to installed
    add_pip_installed(prefix, installed, json=True)

    pip_pkgs = sorted(installed - conda_pkgs)

    if no_builds:
        dependencies = ['='.join(a.quad[0:3]) for a in sorted(conda_pkgs)]
    else:
        dependencies = ['='.join(a.quad[0:3]) for a in sorted(conda_pkgs)]
    if len(pip_pkgs) > 0:
        dependencies.append({'pip': ['=='.join(a.rsplit('-', 2)[:2]) for a in pip_pkgs]})
    # conda uses ruamel_yaml which returns a ruamel_yaml.comments.CommentedSeq
    # this doesn't dump correctly using pyyaml
    channels = list(context.channels)
    if not ignore_channels:
        for dist in installed:
            if dist.channel not in channels:
                channels.insert(0, dist.channel)
    return Environment(name=name, dependencies=dependencies, channels=channels, prefix=prefix)
コード例 #3
0
ファイル: main_list.py プロジェクト: jakirkham/conda
def print_packages(prefix, regex=None, format='human', piplist=False,
                   json=False, show_channel_urls=context.show_channel_urls):
    if not isdir(prefix):
        raise CondaEnvironmentNotFoundError(prefix)

    if not json:
        if format == 'human':
            print('# packages in environment at %s:' % prefix)
            print('#')
        if format == 'export':
            print_export_header()

    installed = linked(prefix)
    log.debug("installed conda packages:\n%s", installed)
    if piplist and context.use_pip and format == 'human':
        other_python = get_egg_info(prefix)
        log.debug("other installed python packages:\n%s", other_python)
        installed.update(other_python)

    exitcode, output = list_packages(prefix, installed, regex, format=format,
                                     show_channel_urls=show_channel_urls)
    if not json:
        print('\n'.join(map(text_type, output)))
    else:
        stdout_json(output)
    return exitcode
コード例 #4
0
ファイル: main_list.py プロジェクト: nitikaraj11/conda
def print_packages(prefix, regex=None, format='human', piplist=False,
                   json=False, show_channel_urls=context.show_channel_urls):
    if not isdir(prefix):
        raise CondaEnvironmentNotFoundError(prefix)

    if not json:
        if format == 'human':
            print('# packages in environment at %s:' % prefix)
            print('#')
        if format == 'export':
            print_export_header()

    installed = linked(prefix)
    log.debug("installed conda packages:\n%s", installed)
    if piplist and context.use_pip and format == 'human':
        other_python = get_egg_info(prefix)
        log.debug("other installed python packages:\n%s", other_python)
        installed.update(other_python)

    exitcode, output = list_packages(prefix, installed, regex, format=format,
                                     show_channel_urls=show_channel_urls)
    if not json:
        print('\n'.join(output))
    else:
        stdout_json(output)
    return exitcode
コード例 #5
0
ファイル: test_create.py プロジェクト: zapnat/conda
def package_is_installed(prefix, dist, exact=False, pip=False):
    packages = list(get_egg_info(prefix) if pip else linked(prefix))
    if '::' not in text_type(dist):
        packages = [p.dist_name for p in packages]
    if exact:
        return dist in packages
    return any(p.startswith(dist) for p in packages)
コード例 #6
0
ファイル: env.py プロジェクト: zapnat/conda
def from_environment(name, prefix, no_builds=False, ignore_channels=False):
    """
        Get environment object from prefix
    Args:
        name: The name of environment
        prefix: The path of prefix
        no_builds: Whether has build requirement
        ignore_channels: whether ignore_channels

    Returns:     Environment object
    """
    installed = linked(prefix, ignore_channels=ignore_channels)
    conda_pkgs = copy(installed)
    # json=True hides the output, data is added to installed
    add_pip_installed(prefix, installed, json=True)

    pip_pkgs = sorted(installed - conda_pkgs)

    if no_builds:
        dependencies = ['='.join((a.name, a.version)) for a in sorted(conda_pkgs)]
    else:
        dependencies = ['='.join((a.name, a.version, a.build)) for a in sorted(conda_pkgs)]
    if len(pip_pkgs) > 0:
        dependencies.append({'pip': ['=='.join(a.rsplit('-', 2)[:2]) for a in pip_pkgs]})
    # conda uses ruamel_yaml which returns a ruamel_yaml.comments.CommentedSeq
    # this doesn't dump correctly using pyyaml
    channels = list(context.channels)
    if not ignore_channels:
        for dist in conda_pkgs:
            if dist.channel not in channels:
                channels.insert(0, dist.channel)
    return Environment(name=name, dependencies=dependencies, channels=channels, prefix=prefix)
コード例 #7
0
ファイル: main_package.py プロジェクト: ESSS/conda
def which_package(path):
    """
    given the path (of a (presumably) conda installed file) iterate over
    the conda packages the file came from.  Usually the iteration yields
    only one package.
    """
    path = abspath(path)
    prefix = which_prefix(path)
    if prefix is None:
        raise RuntimeError("could not determine conda prefix from: %s" % path)
    for dist in linked(prefix):
        meta = is_linked(prefix, dist)
        if any(abspath(join(prefix, f)) == path for f in meta['files']):
            yield dist
コード例 #8
0
def which_package(path):
    """
    given the path (of a (presumably) conda installed file) iterate over
    the conda packages the file came from.  Usually the iteration yields
    only one package.
    """
    path = abspath(path)
    prefix = which_prefix(path)
    if prefix is None:
        raise RuntimeError("could not determine conda prefix from: %s" % path)
    for dist in linked(prefix):
        meta = is_linked(prefix, dist)
        if any(abspath(join(prefix, f)) == path for f in meta['files']):
            yield dist
コード例 #9
0
ファイル: common.py プロジェクト: nitikaraj11/conda
 def _get_items(self):
     from conda.core.linked_data import linked
     packages = linked(context.prefix_w_legacy_search)
     return [dist.quad[0] for dist in packages]
コード例 #10
0
ファイル: test_create.py プロジェクト: Korijn/conda
def assert_package_is_installed(prefix, package, exact=False):
    if not package_is_installed(prefix, package, exact):
        print(list(linked(prefix)))
        raise AssertionError("package {0} is not in prefix".format(package))
コード例 #11
0
 def _get_items(self):
     from conda.core.linked_data import linked
     packages = linked(context.prefix_w_legacy_search)
     return [dist.quad[0] for dist in packages]
コード例 #12
0
ファイル: test_create.py プロジェクト: zapnat/conda
def assert_package_is_installed(prefix, package, exact=False, pip=False):
    if not package_is_installed(prefix, package, exact, pip):
        print(list(linked(prefix)))
        raise AssertionError("package {0} is not in prefix".format(package))