rules_condaAPI docs @0.1.3

@rules_conda//conda:extensions.bzl

Module extensions for loading Conda environments.

Module Extensions

conda

Create Conda environments

Tag Classes
environment

Create a Conda environment

AttributeTypeDescription
*namename

The name of the repository to create.

*lockfilelabel

The lockfile containing the environment.

execute_link_scriptsboolean

Execute link scripts when installing the environment. Only applies to the host platform.

Default: False
platformstring

The platform to create an environment for. Defaults to the host platform.

Default: ""
environmentstring

The environment to create. Defaults to name.

Default: ""
deduplicate_downloadsboolean

Allow this environment to participate in package download deduplication. For very large environments or an excessive number of environments, this option can increase the initialization time of this module extension.

Default: True

@rules_conda//conda/cc:import.bzl

Rules

import_library

Imports a library from an environment, as if by cc_import

AttributeTypeDescription
*namename

A unique name for this target.

*environmentlabel
depslist of labels

The list of other libraries that the target depends on.

Default: []
packageslist of strings

Packages containing libraries and headers to import

Default: []
alwayslinkboolean

If true, link in all object files specified by the static library, even if no symbols are referenced.

Default: False
includeslist of strings

List of include dirs to be added to the compile line, relative to the conda environment include directory root.

Default: []
interface_librarystring
Default: ""
pic_static_librarystring
Default: ""
shared_librarystring
Default: ""
static_librarystring
Default: ""

@rules_conda//conda/environment:defs.bzl

Functions & Macros

lock_environments

Lock Conda environments.

Creates two targets:

  • bazel run [name].update to update the lockfile
  • bazel test [name].test to ensure the lockfile is up-to-date
Parameters
name

The name of this rule

Default: None
environments

A list of environment files, in YAML format

Default: []
lockfile

The lockfile to create

Default: "conda.lock"
cuda_version

The CUDA version to use to solve

Default: None
macos_version

The macOS version to use to solve

Default: None
glibc_version

The glibc version to use to solve

Default: None
visibility

passed to both .update and .test

Default: ["//visibility:private"]
tags

passed to both .update and .test

Default: []
kwargs

additional arguments passed to .test

Rules

environment_glob

Globs files from an environment

AttributeTypeDescription
*namename

A unique name for this target.

*environmentlabel
allow_emptyboolean

If true, allows globs to not match anything.

Default: False
datalist of strings

A list of globs to files within the environment to put in the runfiles.

For example, data = ["foo/**"] would collect all files contained within <environment>/foo into the
runfiles.

Default: []
excludelist of strings

A list of globs to files within the environment to exclude from the files and runfiles.

Default: []
include_package_dependenciesboolean

If true, includes dependencies of packages as well.

Default: True
packageslist of strings

A list of packages globs are allowed to match.

If empty, matches all packages.

Default: []
srcslist of strings

A list of globs to files within the environment to put in the files.

For example, srcs = ["foo/**"] would collect the file at <environment>/foo into the
files.

Default: []
run_binary

Creates a binary target from an executable in an environment

AttributeTypeDescription
*namename

A unique name for this target.

*environmentlabel
pathstring

Explicit relative path of the binary within the environment. Set either this or executable.

Default: ""
executablestring

Executable filename (no directories). Used together with search_paths to locate the binary by name. Set either this or path.

Default: ""
search_pathslist of strings

Directories to search for executable. Defaults to ['bin'] on Linux/macOS and ['.', 'Library/mingw-w64/bin', 'Library/usr/bin', 'Library/bin', 'Scripts', 'bin'] on Windows.

Default: []

@rules_conda//conda/environment:providers.bzl

Functions & Macros

dependent_packages

Get the dependent packages of a package

Parameters
*environment_info

(EnvironmentInfo) The environment to use

*package

(string) The name of a package

get_files_provided_by

Get all files provided by a package.

Parameters
*environment_info

(EnvironmentInfo) The environment to use

*package_name

(string or List[string]) The name of the package or packages

include_dependencies

(bool) Whether or not to include files from dependencies as well

Default: True
file_relative_path

Get the relative path of a file to the environment

Parameters
*environment_info

(EnvironmentInfo) The environment to use

*file

(File) The file

what_provides

Find the package that provided a file

Parameters
*environment_info

(EnvironmentInfo) The environment to use

*path

(string) The file path

Providers

EnvironmentInfo

Information about a Conda environment

Fields
metadata

(Dict[string, Dict]) Conda metadata for each package

files

(DirectoryInfo) The files contained in this environment

@rules_conda//conda/python:toolchain.bzl

Functions & Macros

conda_python_toolchain
Parameters
*name
*environment