forked from iterative/dvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package added with get_package_manager function and other utils.
import changed accordingly in version Solves issue iterative#2672
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |