Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added package manager to dvc version output. #2720

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 4 additions & 2 deletions dvc/command/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from dvc.version import __version__
from dvc.exceptions import DvcException, NotDvcRepoError
from dvc.system import System

from dvc.utils.pkg import get_package_manager

logger = logging.getLogger(__name__)

Expand All @@ -31,17 +31,19 @@ def run(self):
python_version = platform.python_version()
platform_type = platform.platform()
binary = is_binary()

package_manager = get_package_manager()
info = (
"DVC version: {dvc_version}\n"
"Python version: {python_version}\n"
"Platform: {platform_type}\n"
"Binary: {binary}\n"
"Package manager: {package_manager}\n"
).format(
dvc_version=dvc_version,
python_version=python_version,
platform_type=platform_type,
binary=binary,
package_manager=package_manager,
)

try:
Expand Down
48 changes: 1 addition & 47 deletions dvc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from dvc import __version__
from dvc.lock import Lock, LockError
from dvc.utils import is_binary, boxify, env2bool
from dvc.utils import boxify, env2bool


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -143,49 +143,3 @@ def _get_update_instructions(self):
package_manager = self._get_package_manager()

return instructions[package_manager]

def _get_linux(self):
import distro

if not is_binary():
return "pip"

package_managers = {
"rhel": "yum",
"centos": "yum",
"fedora": "yum",
"amazon": "yum",
"opensuse": "yum",
"ubuntu": "apt",
"debian": "apt",
}

return package_managers.get(distro.id())

def _get_darwin(self):
if not is_binary():
if __file__.startswith("/usr/local/Cellar"):
return "formula"
else:
return "pip"
return None

def _get_windows(self):
return None if is_binary() else "pip"

def _get_package_manager(self):
import platform
from dvc.exceptions import DvcException

m = {
"Windows": self._get_windows,
"Darwin": self._get_darwin,
"Linux": self._get_linux,
}

system = platform.system()
func = m.get(system)
if func is None:
raise DvcException("not supported system '{}'".format(system))

return func()
51 changes: 51 additions & 0 deletions dvc/utils/pkg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from dvc.utils import is_binary


def get_linux():
import distro

if not is_binary():
return "pip"

package_managers = {
"rhel": "yum",
"centos": "yum",
"fedora": "yum",
"amazon": "yum",
"opensuse": "yum",
"ubuntu": "apt",
"debian": "apt",
}

return package_managers.get(distro.id())


def get_darwin():
if not is_binary():
if __file__.startswith("/usr/local/Cellar"):
return "formula"
else:
return "pip"
return None


def get_windows():
return None if is_binary() else "pip"


def get_package_manager():
import platform
from dvc.exceptions import DvcException

m = {
"Windows": get_windows(),
"Darwin": get_darwin(),
"Linux": get_linux(),
}

system = platform.system()
func = m.get(system)
if func is None:
raise DvcException("not supported system '{}'".format(system))

return func