Skip to content

Commit 41b535a

Browse files
marcoestersjezdez
andauthored
Update dependencies with conda self update --all (#84)
* Allow passing --update-deps into install command * Improve typing in update tests * Add news * Apply suggestions from code review Co-authored-by: Jannis Leidel <jannis@leidel.info> * Use --all to update dependencies * Remove obsolete test --------- Co-authored-by: Jannis Leidel <jannis@leidel.info>
1 parent 8b207c0 commit 41b535a

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

conda_self/cli/main_update.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def configure_parser(parser: argparse.ArgumentParser) -> None:
3030
update_group.add_argument(
3131
"--all",
3232
action="store_true",
33-
help="Update conda and all plugins.",
33+
help="Update conda, all plugins, and dependencies.",
3434
)
3535
parser.set_defaults(func=execute)
3636

@@ -66,9 +66,14 @@ def execute(args: argparse.Namespace) -> int:
6666
print(f"Installed {package_name}: {installed.version}")
6767
print(f"Latest {package_name}: {latest.version}")
6868

69-
if not update_available and not args.force_reinstall:
69+
if not update_available and not args.force_reinstall and not args.all:
7070
print(f"{package_name} is already using the latest version available!")
7171
else:
72+
if not update_available and args.all:
73+
print(
74+
f"{package_name} is using the latest version available, "
75+
"but may have outdated dependencies."
76+
)
7277
updates[package_name] = latest.version
7378

7479
if args.dry_run:
@@ -80,4 +85,5 @@ def execute(args: argparse.Namespace) -> int:
8085
packages=updates,
8186
channel=channel,
8287
force_reinstall=args.force_reinstall,
88+
update_dependencies=args.all,
8389
)

conda_self/install.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ def install_package_in_protected_env(
99
package_version: str,
1010
channel: str,
1111
force_reinstall: bool = False,
12+
update_dependencies: bool = False,
1213
json: bool = False,
1314
) -> int:
1415
return install_package_list_in_protected_env(
1516
{package_name: package_version},
1617
channel,
17-
force_reinstall,
18-
json,
18+
force_reinstall=force_reinstall,
19+
update_dependencies=update_dependencies,
20+
json=json,
1921
)
2022

2123

2224
def install_package_list_in_protected_env(
2325
packages: dict[str, str],
2426
channel: str,
2527
force_reinstall: bool = False,
28+
update_dependencies: bool = False,
2629
json: bool = False,
2730
) -> int:
2831
specs = [f"{name}={version}" for name, version in packages.items()]
@@ -40,7 +43,7 @@ def install_package_list_in_protected_env(
4043
),
4144
*(("--force-reinstall",) if force_reinstall else ()),
4245
*(("--json",) if json else ()),
43-
"--update-specs",
46+
"--all" if update_dependencies else "--update-specs",
4447
"--override-channels",
4548
f"--channel={channel}",
4649
*specs,

news/84-update-deps

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* Expand `conda self update --all` to also update all dependencies. (#80 via #84)
4+
5+
### Bug fixes
6+
7+
* <news item>
8+
9+
### Deprecations
10+
11+
* <news item>
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

tests/test_cli_update.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pytest_mock import MockerFixture
1919

2020

21-
def test_help(conda_cli):
21+
def test_help(conda_cli: CondaCLIFixture):
2222
out, err, exc = conda_cli("self", "update", "--help", raises=SystemExit)
2323
assert exc.value.code == 0
2424

@@ -43,7 +43,9 @@ def test_help(conda_cli):
4343
),
4444
),
4545
)
46-
def test_update_conda(conda_cli, mocker, latest_version, message):
46+
def test_update_conda(
47+
conda_cli: CondaCLIFixture, mocker: MockerFixture, latest_version: str, message: str
48+
):
4749
mocker.patch.object(
4850
query,
4951
"latest",
@@ -63,7 +65,9 @@ def test_update_conda(conda_cli, mocker, latest_version, message):
6365
@pytest.mark.parametrize(
6466
"plugin_name,ok", (("conda-libmamba-solver", True), ("conda-fake-solver", False))
6567
)
66-
def test_update_plugin(conda_cli, plugin_name, ok):
68+
def test_update_plugin(
69+
conda_cli: CondaCLIFixture, plugin_name: str, ok: tuple[str, bool]
70+
):
6771
conda_cli(
6872
"self",
6973
"update",
@@ -83,8 +87,14 @@ def test_update_plugin(conda_cli, plugin_name, ok):
8387
"conda-libmamba-solver": clms_version,
8488
},
8589
(
86-
"conda is already using the latest version available!",
87-
"conda-libmamba-solver is already using the latest version available!",
90+
(
91+
"conda is using the latest version "
92+
"available, but may have outdated dependencies."
93+
),
94+
(
95+
"conda-libmamba-solver is using the latest version "
96+
"available, but may have outdated dependencies."
97+
),
8898
),
8999
id="No updates",
90100
),
@@ -94,7 +104,10 @@ def test_update_plugin(conda_cli, plugin_name, ok):
94104
"conda-libmamba-solver": "2080",
95105
},
96106
(
97-
"conda is already using the latest version available!",
107+
(
108+
"conda is using the latest version "
109+
"available, but may have outdated dependencies."
110+
),
98111
"Latest conda-libmamba-solver: 2080",
99112
),
100113
id="Update one",

0 commit comments

Comments
 (0)