Skip to content

Commit

Permalink
Prepared docs for release (spietras#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Pietras authored Dec 2, 2021
1 parent a14adfb commit bfee4f8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_conda",
sha256 = "c5ad3a077bddff381790d64dd9cc1516b8133c1d695eb3eff4fed04a39dc4522",
url = "https://github.com/spietras/rules_conda/releases/download/0.0.6/rules_conda-0.0.6.zip"
sha256 = "9793f86162ec5cfb32a1f1f13f5bf776e2c06b243c4f1ee314b9ec870144220d",
url = "https://github.com/spietras/rules_conda/releases/download/0.1.0/rules_conda-0.1.0.zip"
)

load("@rules_conda//:defs.bzl", "conda_create", "load_conda", "register_toolchain")
Expand Down Expand Up @@ -58,8 +58,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_conda",
sha256 = "c5ad3a077bddff381790d64dd9cc1516b8133c1d695eb3eff4fed04a39dc4522",
url = "https://github.com/spietras/rules_conda/releases/download/0.0.6/rules_conda-0.0.6.zip",
sha256 = "9793f86162ec5cfb32a1f1f13f5bf776e2c06b243c4f1ee314b9ec870144220d",
url = "https://github.com/spietras/rules_conda/releases/download/0.1.0/rules_conda-0.1.0.zip",
)

load("@rules_conda//:defs.bzl", "conda_create", "load_conda", "register_toolchain")
Expand Down
48 changes: 46 additions & 2 deletions docs/docs/usage/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_conda",
sha256 = "c5ad3a077bddff381790d64dd9cc1516b8133c1d695eb3eff4fed04a39dc4522",
url = "https://github.com/spietras/rules_conda/releases/download/0.0.6/rules_conda-0.0.6.zip"
sha256 = "9793f86162ec5cfb32a1f1f13f5bf776e2c06b243c4f1ee314b9ec870144220d",
url = "https://github.com/spietras/rules_conda/releases/download/0.1.0/rules_conda-0.1.0.zip"
)

load("@rules_conda//:defs.bzl", "conda_create", "load_conda", "register_toolchain")
Expand Down Expand Up @@ -55,3 +55,47 @@ Otherwise the environment will be recreated from scratch, so that it always refl
However, if the `clean` flag is set to `False` (the default) in `conda_create` then the downloaded package data will be reused so you don't need to download everything everytime.

Also see [here](https://github.com/spietras/rules_conda/tree/main/example) for a complete example with all the code available.

## Advanced example

This example shows all possibilities of `rules_conda`:

```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_conda",
sha256 = "9793f86162ec5cfb32a1f1f13f5bf776e2c06b243c4f1ee314b9ec870144220d",
url = "https://github.com/spietras/rules_conda/releases/download/0.1.0/rules_conda-0.1.0.zip",
)

load("@rules_conda//:defs.bzl", "conda_create", "load_conda", "register_toolchain")

load_conda(
conda_version = "4.10.3", # version of conda to download, default is 4.10.3
installer = "miniforge", # which conda installer to download, either miniconda or miniforge, default is miniconda
install_mamba = True, # whether to install mamba, which is a faster drop-in replacement for conda, default is False
mamba_version = "0.17.0", # version of mamba to install, default is 0.17.0
quiet = False, # True if conda output should be hidden, default is True
timeout = 600, # how many seconds each execute action can take, default is 3600
)

conda_create(
name = "py3_env", # name of the environment
environment = "@//:py3_environment.yml", # label pointing to environment configuration file
use_mamba = True, # Whether to use mamba to create the conda environment. If this is True, install_mamba must also be True False
clean = False, # True if conda cache should be cleaned (less space taken, but slower subsequent builds), default is False
quiet = False, # True if conda output should be hidden True, default is True
timeout = 600, # how many seconds each execute action can take, default is 3600
)

conda_create(
name = "py2_env", # name of the environment
environment = "@//:py2_environment.yml", # label pointing to environment configuration file
)

register_toolchain(
py2_env = "py2_env", # python2 is optional
py3_env = "py3_env",
)
```
4 changes: 2 additions & 2 deletions example/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ local_repository(
# keep in mind that there may be differences between them
#http_archive(
# name = "rules_conda",
# sha256 = "c5ad3a077bddff381790d64dd9cc1516b8133c1d695eb3eff4fed04a39dc4522",
# url = "https://github.com/spietras/rules_conda/releases/download/0.0.6/rules_conda-0.0.6.zip"
# sha256 = "9793f86162ec5cfb32a1f1f13f5bf776e2c06b243c4f1ee314b9ec870144220d",
# url = "https://github.com/spietras/rules_conda/releases/download/0.1.0/rules_conda-0.1.0.zip"
#)

load("@rules_conda//:defs.bzl", "conda_create", "load_conda", "register_toolchain")
Expand Down

0 comments on commit bfee4f8

Please sign in to comment.