# \[ANN\] CondaPkg.jl: Add Conda dependencies to your Julia project

**URL:** <https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034>\
**Category:** Package Announcements\
**Created:** [December 13, 2021, 5:27pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034 "2021-12-13T17:27:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [December 13, 2021, 5:27pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/1 "2021-12-13T17:27:43Z")

</div>

[Conda](https://conda.io) is a cross-platform package manager, originally used to manage the Anaconda Python distribution, but also handles non-Python packages too.

[CondaPkg.jl](https://github.com/cjdoris/CondaPkg.jl) is a bit like Pkg but for managing Conda dependencies.

This provides an convenient means to add binary dependencies to your Julia project. It can be used as an alternative to [artifacts](https://pkgdocs.julialang.org/v1/artifacts/), [JLL packages](https://docs.binarybuilder.org/dev/jll/) or [manual downloading](https://docs.julialang.org/en/v1/stdlib/Downloads/). It is particularly useful for Python dependencies.

# Example

To declare dependencies, you simply create a `CondaPkg.toml` file in your Julia project, such as:

```toml
[deps]
perl = "5.*"

```

Alternatively, we provide interactive functions to add and remove dependencies, such as:

```julia
CondaPkg.add("perl", version="5.*")

```

Now you can run programs in the environment like so:

```julia
CondaPkg.withenv() do
    run(`perl -e 'print("Hello world!\n")'`)
end

```

# Features

- Automatically resolves your Conda dependencies.
- Uses a different Conda environment for each Julia environment, so avoiding version conflicts.
- Also handles Pip dependencies, and maybe more kinds in the future.
- Behind the scenes we use [MicroMamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html), the new fast reimplementation of Conda. Installation of this is managed by the new [MicroMamba.jl](https://github.com/cjdoris/MicroMamba.jl) package.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [June 18, 2023, 5:10pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/2 "2023-06-18T17:10:05Z")

</div>

What’s the syntax for specifying version bounds in `CondaPkg.toml` ?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 18, 2023, 7:06pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/3 "2023-06-18T19:06:45Z")

</div>

There are examples in the README: [GitHub - cjdoris/CondaPkg.jl: Add Conda dependencies to your Julia project](https://github.com/cjdoris/CondaPkg.jl#condapkgtoml)

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [June 18, 2023, 7:27pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/4 "2023-06-18T19:27:41Z")

</div>

Thanks, I had seen that. It shows only examples with `<=, ==, <`. To be concrete, I have two questions:

1. `~, ^` (as defined in Pkg) are not supported by `CondaPkg`?

2. If I write:

```julia
[deps]
pyarrow = "6.0"

```

what does it mean? Is it automatically equivalent to `>=6.0, <7`? How does it treat leading `0.` versions?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 18, 2023, 7:35pm UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/5 "2023-06-18T19:35:49Z")

</div>

I don’t know the answer to that myself, so I went digging. CondaPkg dependencies are stored in an object of type `CondaPkg.PkgSpec` or `CondaPkg.PipPkgSpec`, and the version validation is done by the following lines:

```julia
is_valid_version(ver) = occursin(r"^\s*($|[!<>=0-9])", ver) && is_valid_string(ver; allow_glob=true)

normalise_version(ver) = strip(ver)

validate_version(ver) =
    if is_valid_version(ver)
        normalise_version(ver)
    else
        error("invalid version: $(repr(ver))")
    end

```

```julia
is_valid_pip_version(ver) = occursin(r"^\s*($|[~!<>=@])", ver) && !occursin(";", ver)

normalise_pip_version(ver) = strip(ver)

validate_pip_version(ver) =
    if is_valid_pip_version(ver)
        normalise_pip_version(ver)
    else
        error("invalid pip version: $(repr(ver))")
    end

```

Source: [CondaPkg.jl/src/spec.jl at main · cjdoris/CondaPkg.jl · GitHub](https://github.com/cjdoris/CondaPkg.jl/blob/main/src/spec.jl)

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [June 19, 2023, 9:01am UTC](https://discourse.julialang.org/t/ann-condapkg-jl-add-conda-dependencies-to-your-julia-project/73034/6 "2023-06-19T09:01:34Z")

</div>

CondaPkg uses the Conda version syntax for Conda dependencies (and pip syntax for pip dependencies).

In short, it supports `<`, `<=`, `>`, `>=` and `==` ranges, `,` means “and” and `|` means “or”.

A “naked” version like `6.0` means `6.0.*`, equivalent to `>=6.0,<6.1`.

It doesn’t directly support anything like Julia’s SemVer ranges. You just have to build them like `>=6.0,<7`.
