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
9 changes: 0 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,6 @@ Fedora / CentOS (rpm)
sudo yum update
sudo yum install dvc

Arch Linux (AUR)
^^^^^^^^^^^^^^^^
*Unofficial package*, any inquiries regarding the AUR package,
`refer to the maintainer <https://github.com/mroutis/pkgbuilds>`_.

.. code-block:: bash

yay -S dvc

Related technologies
====================

Expand Down
7 changes: 3 additions & 4 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
from dvc.utils.pkg import PKG

logger = logging.getLogger(__name__)

Expand All @@ -31,19 +31,18 @@ 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"
"Package: {package}\n"
).format(
dvc_version=dvc_version,
python_version=python_version,
platform_type=platform_type,
binary=binary,
package_manager=package_manager,
package=PKG,
)

try:
Expand Down
15 changes: 8 additions & 7 deletions dvc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from dvc.lock import LockError
from dvc.utils import boxify
from dvc.utils import env2bool
from dvc.utils.pkg import get_package_manager
from dvc.utils.pkg import PKG

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -123,10 +123,9 @@ def _notify(self):
def _get_update_instructions(self):
instructions = {
"pip": "Run {yellow}pip{reset} install dvc {blue}--upgrade{reset}",
"yum": "Run {yellow}yum{reset} update dvc",
"yay": "Run {yellow}yay{reset} {blue}-S{reset} dvc",
"formula": "Run {yellow}brew{reset} upgrade dvc",
"apt": (
"rpm": "Run {yellow}yum{reset} update dvc",
"brew": "Run {yellow}brew{reset} upgrade dvc",
"deb": (
"Run {yellow}apt-get{reset} install"
" {blue}--only-upgrade{reset} dvc"
),
Expand All @@ -136,14 +135,16 @@ 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",
"conda": "Run {yellow}conda{reset} update dvc",
None: (
"Find the latest release at\n{blue}"
"https://github.com/iterative/dvc/releases/latest"
"{reset}"
),
}

package_manager = get_package_manager()
package_manager = PKG
if package_manager in ("osxpkg", "exe"):
package_manager = "binary"

return instructions[package_manager]
67 changes: 4 additions & 63 deletions dvc/utils/pkg.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,4 @@
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

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

if is_conda():
return "conda"

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
try:
from .build import PKG # file created during dvc build
except ImportError:
PKG = None
2 changes: 2 additions & 0 deletions scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if [ ! -d "dvc" ]; then
exit 1
fi

echo "PKG = \"pip\"" > dvc/utils/build.py

python setup.py sdist
python setup.py bdist_wheel --universal

Expand Down
16 changes: 11 additions & 5 deletions scripts/build_posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,21 @@ build_dvc()
fi
}

cleanup
build()
{
cleanup
echo "PKG = \"$1\"" > dvc/utils/build.py
build_dvc
fpm_build $1
}

install_dependencies
build_dvc

if [[ "$(uname)" == 'Linux' ]]; then
fpm_build rpm
fpm_build deb
build rpm
build deb
else
fpm_build osxpkg
build osxpkg
fi

cleanup
Expand Down
1 change: 1 addition & 0 deletions scripts/build_windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ where iscc
if %errorlevel% neq 0 (echo Error: Couldn't find Inno Setup compiler. && goto :error)

echo ====== Installing requirements... ======
echo 'PKG = "exe"' > dvc\utils\build.py
call pip install .[all] || goto :error
call pip install psutil || goto :error
call dvc pull || goto :error
Expand Down
10 changes: 0 additions & 10 deletions tests/func/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,3 @@ 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
5 changes: 2 additions & 3 deletions tests/func/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ def test_info_in_repo(repo_dir, dvc_repo, caplog):
# adding a file so that dvc creates `.dvc/cache`, that is needed for proper
# supported link types check.
assert main(["add", repo_dir.FOO]) == 0

assert main(["version"]) == 0

assert re.search(re.compile(r"DVC version: \d+\.\d+\.\d+"), caplog.text)
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
assert re.search(re.compile(r"Platform: .*"), caplog.text)
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
assert re.search(re.compile(r"Package manager: .*"), caplog.text)
assert re.search(re.compile(r"Package: .*"), caplog.text)
assert re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)
Expand All @@ -42,7 +41,7 @@ def test_info_outside_of_repo(repo_dir, caplog):
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
assert re.search(re.compile(r"Platform: .*"), caplog.text)
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
assert re.search(re.compile(r"Package manager: .*"), caplog.text)
assert re.search(re.compile(r"Package: .*"), caplog.text)
assert not re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)
Expand Down