Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dvc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions dvc/utils/pkg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from dvc.utils import is_binary


def is_conda():
try:
from .build import PKG # patched during conda package build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we start including this file into other packages, we would be able to simply delete this dvc/utils/pkg.py and have build.py(or maybe pkg.py if we decide to rename it) have PKG = "something" defined and then just from .build import PKG and use it instead of get_package_manager. That would look and feel very nice. 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiop I will rework that method in the next PR where I include patches for other builds as well ;)


return PKG == "conda"
except ImportError:
return False


def get_linux():
import distro

Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 10 additions & 0 deletions tests/func/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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