mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
Merge pull request #2679 from n3hrox/enhance/conda_detection
updater: detect conda
This commit is contained in:
@@ -133,6 +133,7 @@ class Updater(object): # pragma: no cover
|
||||
"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"
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user