Skip to content

Commit

Permalink
add conda update / conda up (#67)
Browse files Browse the repository at this point in the history
* add `conda update / conda up`

* add update function - update README / CHANGELOG
  • Loading branch information
t-bltg authored Jan 25, 2023
1 parent d4a503a commit 8eacfef
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## main
* Add `update` function and REPL command.

## 0.2.16 (2023-01-23)
* Allow `JULIA_CONDAPKG_ENV` to specify the location of a shared Conda environment.
* The PkgREPL now supports the prefixes `@` for versions and `#` for build string.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pkg> conda add python perl # adds conda packages
pkg> conda pip_add build # adds pip packages
pkg> conda rm perl # removes conda packages
pkg> conda run python --version # runs the given command in the conda environment
pkg> conda update # update conda and pip installed packages
```

For more information do `?` or `?conda` from the Pkg REPL.
Expand Down Expand Up @@ -98,6 +99,7 @@ binary = "no" # or "only"
- `resolve(; force=false)` resolves dependencies. You don't normally need to call this
because the other API functions will automatically resolve first. Pass `force=true` if
you change a `CondaPkg.toml` file mid-session.
- `update()` update the conda and pip installed packages.
- `gc()` removes unused caches to save disk space.

### Examples
Expand Down
25 changes: 24 additions & 1 deletion src/PkgREPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ const resolve_spec = Pkg.REPLMode.CommandSpec(
option_spec = [force_opt],
)

### update

function update()
CondaPkg.update()
end

const update_help = Markdown.parse("""
```
conda update
```
Update Conda dependencies.
""")

const update_spec = Pkg.REPLMode.CommandSpec(
name = "update",
api = update,
help = update_help,
description = "update Conda dependencies",
)

### add

function add(args)
Expand Down Expand Up @@ -303,7 +324,7 @@ const gc_spec = Pkg.REPLMode.CommandSpec(
description = "delete files no longer used by Conda",
)

## run
### run

function run(args)
CondaPkg.withenv() do
Expand Down Expand Up @@ -334,6 +355,8 @@ const SPECS = Dict(
"st" => status_spec,
"status" => status_spec,
"resolve" => resolve_spec,
"up" => update_spec,
"update" => update_spec,
"add" => add_spec,
"remove" => rm_spec,
"rm" => rm_spec,
Expand Down
4 changes: 4 additions & 0 deletions src/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,7 @@ function is_resolved()
resolve(io=devnull, dry_run=true)
STATE.resolved
end

function update()
resolve(force=true, interactive=true)
end
8 changes: 7 additions & 1 deletion test/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,13 @@ end
end
end

@testitem "gc()" begin
@testitem "update" begin
include("setup.jl")
CondaPkg.update()
@test CondaPkg.is_resolved()
end

@testitem "gc" begin
include("setup.jl")
testgc && CondaPkg.gc()
@test true
Expand Down
8 changes: 8 additions & 0 deletions test/pkgrepl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ end
@testitem "resolve" begin
include("setup.jl")
CondaPkg.PkgREPL.resolve()
@test CondaPkg.is_resolved()
end

@testitem "update" begin
include("setup.jl")
CondaPkg.PkgREPL.update()
@test CondaPkg.is_resolved()
end

@testitem "gc" begin
include("setup.jl")
testgc && CondaPkg.PkgREPL.gc()
@test true
end

@testitem "run" begin
Expand Down

0 comments on commit 8eacfef

Please sign in to comment.