Skip to content

Commit

Permalink
update cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Doris committed Dec 1, 2021
1 parent 54cd5f9 commit 54d6f8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ pkg> add MicroMamba
## Usage

The API consists of the following three functions:
- `available()` returns true if MicroMamba is available on this system. Use this to check if the following functions will succeed.
- `executable()` returns a path to a MicroMamba executable.
- `version()` returns the version of the above executable.
- `available()` returns true if MicroMamba is available on this system.
- `cmd([args])` returns a command which calls MicroMamba.

In all three cases, MicroMamba will be downloaded and installed (local to the package)
if required.
In all three cases, MicroMamba will be downloaded and installed if required to the `micromamba` directory in your Julia depot (e.g. `~/.julia/micromamba`).

Note that `executable()` and `version()` can throw errors, such as if MicroMamba is not
supported on this platform. The `available()` function exists to check for this: if it
returns true, then the other functions will succeed.
## Example

The following example creates a new environment and installs Python into it.

```julia
run(MicroMamba.cmd(`--prefix ./env create python --yes --channel conda-forge`))
```

## Environment variables

Expand All @@ -32,3 +36,4 @@ The following environment variables customise the behaviour of this package.
- `{platform}` is replaced with the platform, such as `linux-64`.
- `{version}` is replaced with the desired version, such as `latest` or `0.19.0`.
- `JULIA_MICROMAMBA_VERSION`: If MicroMamba needs to be downloaded, this specifies the version.
- `JULIA_MICROMAMBA_ROOT_PREFIX`: The root prefix used by `cmd()`. Defaults to the `micromamba/root` directory of your Julia depo (e.g. `~/.julia/micromamba/root`).
13 changes: 9 additions & 4 deletions src/MicroMamba.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,19 @@ end
Construct a command which calls MicroMamba, optionally with additional arguments.
Unless the environment variable `MAMBA_ROOT_PREFIX` is set, the root prefix will be
set to `joinpath(DEPOT_PATH[1], "micromamba", "root")`.
By default, the root prefix is a folder in the Julia depot. It can be over-ridden with
the environment variable `JULIA_MICROMAMBA_ROOT_PREFIX`. To use the default root prefix
instead (e.g. as set by `~/.mambarc`) set this variable to the empty string.
"""
function cmd()
root = get(ENV, "MAMBA_ROOT_PREFIX") do
ans = `$(executable())`
root = get(ENV, "JULIA_MICROMAMBA_ROOT_PREFIX") do
joinpath(DEPOT_PATH[1], "micromamba", "root")
end
`$(executable()) --root-prefix $root`
if root != ""
ans = `$ans --root-prefix $root`
end
ans
end
cmd(args) = `$(cmd()) $args`

Expand Down

2 comments on commit 54d6f8e

@cjdoris
Copy link
Collaborator

@cjdoris cjdoris commented on 54d6f8e Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/49695

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 54d6f8ea01b594fef9eff82bb27d0e5fc2e16156
git push origin v0.1.0

Please sign in to comment.