Skip to content

Commit

Permalink
Package added with get_package_manager function and other utils.
Browse files Browse the repository at this point in the history
import changed accordingly in version
Solves issue iterative#2672
  • Loading branch information
kss682 committed Nov 4, 2019
1 parent bb7a9a5 commit 0786a70
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
4 changes: 2 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.updater import Updater
from dvc.utils.pkg import get_package_manager

logger = logging.getLogger(__name__)

Expand All @@ -31,7 +31,7 @@ def run(self):
python_version = platform.python_version()
platform_type = platform.platform()
binary = is_binary()
package_manager = Updater("dvc/")._get_package_manager()
package_manager = get_package_manager()
info = (
"DVC version: {dvc_version}\n"
"Python version: {python_version}\n"
Expand Down
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

0 comments on commit 0786a70

Please sign in to comment.