Skip to content

Commit a5d317e

Browse files
authored
Merge pull request #2679 from n3hrox/enhance/conda_detection
updater: detect conda
2 parents 35507df + 83429a5 commit a5d317e

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

dvc/updater.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def _get_update_instructions(self):
133133
"2. Go to {blue}https://dvc.org{reset}\n"
134134
"3. Download and install new binary"
135135
),
136+
"conda": "Run {yellow}conda{reset} {update}update{reset} dvc",
136137
None: (
137138
"Find the latest release at\n{blue}"
138139
"https://github.com/iterative/dvc/releases/latest"

dvc/utils/pkg.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
from dvc.utils import is_binary
22

33

4+
def is_conda():
5+
try:
6+
from .build import PKG # patched during conda package build
7+
8+
return PKG == "conda"
9+
except ImportError:
10+
return False
11+
12+
413
def get_linux():
514
import distro
615

@@ -37,6 +46,9 @@ def get_package_manager():
3746
import platform
3847
from dvc.exceptions import DvcException
3948

49+
if is_conda():
50+
return "conda"
51+
4052
m = {
4153
"Windows": get_windows(),
4254
"Darwin": get_darwin(),

tests/func/test_updater.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@ def test_check_version_outdated(updater):
4949
updater.current = "0.20.8"
5050

5151
assert updater._is_outdated()
52+
53+
54+
@mock.patch("dvc.utils.pkg.is_conda")
55+
def test_check_dvc_from_conda(mocked_is_conda, updater):
56+
mocked_is_conda.return_value = True
57+
updater.latest = "0.21.0"
58+
updater.current = "0.20.8"
59+
60+
msg = "Run {yellow}conda{reset} {update}update{reset} dvc"
61+
assert updater._get_update_instructions() == msg

0 commit comments

Comments
 (0)