diff --git a/dvc/updater.py b/dvc/updater.py index 5176c3cb39..8b13754e85 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -133,6 +133,7 @@ def _get_update_instructions(self): "2. Go to {blue}https://dvc.org{reset}\n" "3. Download and install new binary" ), + "conda": "Run {yellow}conda{reset} {update}update{reset} dvc", None: ( "Find the latest release at\n{blue}" "https://github.com/iterative/dvc/releases/latest" diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index a35bd73063..4d2a0228df 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -1,6 +1,15 @@ from dvc.utils import is_binary +def is_conda(): + try: + from .build import PKG # patched during conda package build + + return PKG == "conda" + except ImportError: + return False + + def get_linux(): import distro @@ -37,6 +46,9 @@ def get_package_manager(): import platform from dvc.exceptions import DvcException + if is_conda(): + return "conda" + m = { "Windows": get_windows(), "Darwin": get_darwin(), diff --git a/tests/func/test_updater.py b/tests/func/test_updater.py index 3cd2758041..fd92729c0f 100644 --- a/tests/func/test_updater.py +++ b/tests/func/test_updater.py @@ -49,3 +49,13 @@ def test_check_version_outdated(updater): updater.current = "0.20.8" assert updater._is_outdated() + + +@mock.patch("dvc.utils.pkg.is_conda") +def test_check_dvc_from_conda(mocked_is_conda, updater): + mocked_is_conda.return_value = True + updater.latest = "0.21.0" + updater.current = "0.20.8" + + msg = "Run {yellow}conda{reset} {update}update{reset} dvc" + assert updater._get_update_instructions() == msg