From f4ee4b043481cc96ee2463b9af97ce2dadc6ae43 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 18:04:41 +0100 Subject: [PATCH 01/13] Add better heuristic for build detection --- dvc/command/version.py | 6 ++++-- dvc/utils/pkg.py | 8 ++++---- scripts/build_posix.sh | 6 ++++++ scripts/build_windows.cmd | 2 ++ scripts/patches/darwin.patch | 20 ++++++++++++++++++++ scripts/patches/windows.patch | 19 +++++++++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 scripts/patches/darwin.patch create mode 100644 scripts/patches/windows.patch diff --git a/dvc/command/version.py b/dvc/command/version.py index ad03858619..38b16cc930 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -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 get_package_manager, check_build_patch logger = logging.getLogger(__name__) @@ -30,7 +30,9 @@ def run(self): dvc_version = __version__ python_version = platform.python_version() platform_type = platform.platform() - binary = is_binary() + binary = False + if is_binary(): + binary = check_build_patch() package_manager = get_package_manager() info = ( "DVC version: {dvc_version}\n" diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index 4d2a0228df..08a2875ce6 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -1,11 +1,11 @@ from dvc.utils import is_binary -def is_conda(): +def check_build_patch(): try: from .build import PKG # patched during conda package build - return PKG == "conda" + return PKG except ImportError: return False @@ -31,7 +31,7 @@ def get_linux(): def get_darwin(): if not is_binary(): - if __file__.startswith("/usr/local/Cellar"): + if check_build_patch() == "darwin": return "formula" else: return "pip" @@ -46,7 +46,7 @@ def get_package_manager(): import platform from dvc.exceptions import DvcException - if is_conda(): + if check_build_patch() == "conda": return "conda" m = { diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index 86e44181f4..56b383f6a2 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -82,6 +82,7 @@ install_dependencies() sudo apt-get install ruby-dev build-essential rpm python-pip python-dev elif command_exists brew; then brew install ruby + brew install git else echo "Unable to install fpm dependencies" && exit 1 fi @@ -101,6 +102,11 @@ install_dependencies() build_dvc() { print_info "Building dvc binary..." + + if [[ "$(uname)" != 'Linux' ]]; then + git apply $(pwd)/scripts/darwin.patch + fi + pyinstaller \ --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ --name dvc \ diff --git a/scripts/build_windows.cmd b/scripts/build_windows.cmd index d9a2942fe9..de7e8f79b9 100755 --- a/scripts/build_windows.cmd +++ b/scripts/build_windows.cmd @@ -16,11 +16,13 @@ where choco if %errorlevel% neq 0 (echo Error: choco not found && goto :error) choco install InnoSetup +choco install git call refreshenv where iscc if %errorlevel% neq 0 (echo Error: Couldn't find Inno Setup compiler. && goto :error) echo ====== Installing requirements... ====== +call git patch scripts/patches/windows.patch call pip install .[all] || goto :error call pip install psutil || goto :error call dvc pull || goto :error diff --git a/scripts/patches/darwin.patch b/scripts/patches/darwin.patch new file mode 100644 index 0000000000..efcb75b19f --- /dev/null +++ b/scripts/patches/darwin.patch @@ -0,0 +1,20 @@ +From 71707795d27aa848d71780b84e056b4f5735650c Mon Sep 17 00:00:00 2001 +From: n3hrox +Date: Sun, 10 Nov 2019 17:35:10 +0100 +Subject: [PATCH] Darwin patch + +--- + dvc/utils/build.py | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 dvc/utils/build.py + +diff --git a/dvc/utils/build.py b/dvc/utils/build.py +new file mode 100644 +index 00000000..3d149b9a +--- /dev/null ++++ b/dvc/utils/build.py +@@ -0,0 +1 @@ ++PKG = "darwin" +-- +2.17.1 + diff --git a/scripts/patches/windows.patch b/scripts/patches/windows.patch new file mode 100644 index 0000000000..7b8c7f8525 --- /dev/null +++ b/scripts/patches/windows.patch @@ -0,0 +1,19 @@ +From 6b53dcffe5e13cb3c196d29a495d8da9bcc26d6d Mon Sep 17 00:00:00 2001 +From: n3hrox +Date: Sun, 10 Nov 2019 15:44:14 +0100 +Subject: [PATCH] Windows patch + +--- + dvc/utils/buid.py | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 dvc/utils/buid.py + +diff --git a/dvc/utils/buid.py b/dvc/utils/buid.py +new file mode 100644 +index 00000000..ada7a0bb +--- /dev/null ++++ b/dvc/utils/buid.py +@@ -0,0 +1 @@ ++PKG = "windows" +-- +2.17.1 From e1dfb7505582aba851a535b4058de949f8d5b0aa Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 19:46:48 +0100 Subject: [PATCH 02/13] Refactor get_package_manager --- dvc/command/version.py | 8 ++- dvc/updater.py | 9 ++-- dvc/utils/bulid.py | 1 + dvc/utils/pkg.py | 52 ++----------------- scripts/build_posix.sh | 5 +- scripts/build_windows.cmd | 2 +- scripts/patches/deb.patch | 14 +++++ .../patches/{darwin.patch => osxpkg.patch} | 8 +-- scripts/patches/rpm.patch | 14 +++++ scripts/patches/windows.patch | 15 ++---- 10 files changed, 47 insertions(+), 81 deletions(-) create mode 100644 dvc/utils/bulid.py create mode 100644 scripts/patches/deb.patch rename scripts/patches/{darwin.patch => osxpkg.patch} (58%) create mode 100644 scripts/patches/rpm.patch diff --git a/dvc/command/version.py b/dvc/command/version.py index 38b16cc930..0025ee4b25 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -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, check_build_patch +from dvc.utils.pkg import get_package_manager logger = logging.getLogger(__name__) @@ -30,16 +30,14 @@ def run(self): dvc_version = __version__ python_version = platform.python_version() platform_type = platform.platform() - binary = False - if is_binary(): - binary = check_build_patch() + 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 type: {package_manager}\n" ).format( dvc_version=dvc_version, python_version=python_version, diff --git a/dvc/updater.py b/dvc/updater.py index a9da1183e7..cdb9490e41 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -123,14 +123,13 @@ 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", + "osxpkg": "Run {yellow}brew{reset} upgrade dvc", + "deb": ( "Run {yellow}apt-get{reset} install" " {blue}--only-upgrade{reset} dvc" ), - "binary": ( + "exe": ( "To upgrade follow these steps:\n" "1. Uninstall dvc binary\n" "2. Go to {blue}https://dvc.org{reset}\n" diff --git a/dvc/utils/bulid.py b/dvc/utils/bulid.py new file mode 100644 index 0000000000..ada7a0bbae --- /dev/null +++ b/dvc/utils/bulid.py @@ -0,0 +1 @@ +PKG = "windows" diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index 08a2875ce6..df44931387 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -7,57 +7,11 @@ def check_build_patch(): return PKG except ImportError: - return False + return None -def get_linux(): - import distro - +def get_package_manager(): 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 check_build_patch() == "darwin": - 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 check_build_patch() == "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 + return check_build_patch() diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index 56b383f6a2..c37acf6bba 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -52,6 +52,7 @@ command_exists() fpm_build() { print_info "Building $1..." + git apply "$(pwd)/scripts/$1.patch" VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") fpm -s dir \ -f \ @@ -103,10 +104,6 @@ build_dvc() { print_info "Building dvc binary..." - if [[ "$(uname)" != 'Linux' ]]; then - git apply $(pwd)/scripts/darwin.patch - fi - pyinstaller \ --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ --name dvc \ diff --git a/scripts/build_windows.cmd b/scripts/build_windows.cmd index de7e8f79b9..0df597f31f 100755 --- a/scripts/build_windows.cmd +++ b/scripts/build_windows.cmd @@ -22,7 +22,7 @@ where iscc if %errorlevel% neq 0 (echo Error: Couldn't find Inno Setup compiler. && goto :error) echo ====== Installing requirements... ====== -call git patch scripts/patches/windows.patch +call git patch scripts\patches\windows.patch call pip install .[all] || goto :error call pip install psutil || goto :error call dvc pull || goto :error diff --git a/scripts/patches/deb.patch b/scripts/patches/deb.patch new file mode 100644 index 0000000000..1ece153cfa --- /dev/null +++ b/scripts/patches/deb.patch @@ -0,0 +1,14 @@ +--- + dvc/utils/build.py | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 dvc/utils/build.py + +diff --git a/dvc/utils/build.py b/dvc/utils/build.py +new file mode 100644 +index 00000000..ada7a0bb +--- /dev/null ++++ b/dvc/utils/build.py +@@ -0,0 +1 @@ ++PKG = "deb" +-- +2.17.1 diff --git a/scripts/patches/darwin.patch b/scripts/patches/osxpkg.patch similarity index 58% rename from scripts/patches/darwin.patch rename to scripts/patches/osxpkg.patch index efcb75b19f..21de8fff45 100644 --- a/scripts/patches/darwin.patch +++ b/scripts/patches/osxpkg.patch @@ -1,8 +1,3 @@ -From 71707795d27aa848d71780b84e056b4f5735650c Mon Sep 17 00:00:00 2001 -From: n3hrox -Date: Sun, 10 Nov 2019 17:35:10 +0100 -Subject: [PATCH] Darwin patch - --- dvc/utils/build.py | 1 + 1 file changed, 1 insertion(+) @@ -14,7 +9,6 @@ index 00000000..3d149b9a --- /dev/null +++ b/dvc/utils/build.py @@ -0,0 +1 @@ -+PKG = "darwin" ++PKG = "osxpkg" -- 2.17.1 - diff --git a/scripts/patches/rpm.patch b/scripts/patches/rpm.patch new file mode 100644 index 0000000000..d9157d9e8c --- /dev/null +++ b/scripts/patches/rpm.patch @@ -0,0 +1,14 @@ +--- + dvc/utils/build.py | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 dvc/utils/build.py + +diff --git a/dvc/utils/build.py b/dvc/utils/build.py +new file mode 100644 +index 00000000..ada7a0bb +--- /dev/null ++++ b/dvc/utils/build.py +@@ -0,0 +1 @@ ++PKG = "rpm" +-- +2.17.1 diff --git a/scripts/patches/windows.patch b/scripts/patches/windows.patch index 7b8c7f8525..32a293b6b4 100644 --- a/scripts/patches/windows.patch +++ b/scripts/patches/windows.patch @@ -1,19 +1,14 @@ -From 6b53dcffe5e13cb3c196d29a495d8da9bcc26d6d Mon Sep 17 00:00:00 2001 -From: n3hrox -Date: Sun, 10 Nov 2019 15:44:14 +0100 -Subject: [PATCH] Windows patch - --- - dvc/utils/buid.py | 1 + + dvc/utils/build.py | 1 + 1 file changed, 1 insertion(+) - create mode 100644 dvc/utils/buid.py + create mode 100644 dvc/utils/build.py -diff --git a/dvc/utils/buid.py b/dvc/utils/buid.py +diff --git a/dvc/utils/build.py b/dvc/utils/build.py new file mode 100644 index 00000000..ada7a0bb --- /dev/null -+++ b/dvc/utils/buid.py ++++ b/dvc/utils/build.py @@ -0,0 +1 @@ -+PKG = "windows" ++PKG = "exe" -- 2.17.1 From 36f75dd519a6f2ded946763f2831ccc4a0043672 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 19:48:15 +0100 Subject: [PATCH 03/13] Remove unnecessary file --- dvc/utils/bulid.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dvc/utils/bulid.py diff --git a/dvc/utils/bulid.py b/dvc/utils/bulid.py deleted file mode 100644 index ada7a0bbae..0000000000 --- a/dvc/utils/bulid.py +++ /dev/null @@ -1 +0,0 @@ -PKG = "windows" From c48c84261d411a4b7f928bd662566e9a73399e14 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 20:03:32 +0100 Subject: [PATCH 04/13] remove patches in favor of echo --- scripts/build_posix.sh | 3 +-- scripts/patches/deb.patch | 14 -------------- scripts/patches/osxpkg.patch | 14 -------------- scripts/patches/rpm.patch | 14 -------------- 4 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 scripts/patches/deb.patch delete mode 100644 scripts/patches/osxpkg.patch delete mode 100644 scripts/patches/rpm.patch diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index c37acf6bba..6c896c9c70 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -51,8 +51,8 @@ command_exists() fpm_build() { + echo "PKG = \"$1\"" > dvc/build.py print_info "Building $1..." - git apply "$(pwd)/scripts/$1.patch" VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") fpm -s dir \ -f \ @@ -83,7 +83,6 @@ install_dependencies() sudo apt-get install ruby-dev build-essential rpm python-pip python-dev elif command_exists brew; then brew install ruby - brew install git else echo "Unable to install fpm dependencies" && exit 1 fi diff --git a/scripts/patches/deb.patch b/scripts/patches/deb.patch deleted file mode 100644 index 1ece153cfa..0000000000 --- a/scripts/patches/deb.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- - dvc/utils/build.py | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 dvc/utils/build.py - -diff --git a/dvc/utils/build.py b/dvc/utils/build.py -new file mode 100644 -index 00000000..ada7a0bb ---- /dev/null -+++ b/dvc/utils/build.py -@@ -0,0 +1 @@ -+PKG = "deb" --- -2.17.1 diff --git a/scripts/patches/osxpkg.patch b/scripts/patches/osxpkg.patch deleted file mode 100644 index 21de8fff45..0000000000 --- a/scripts/patches/osxpkg.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- - dvc/utils/build.py | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 dvc/utils/build.py - -diff --git a/dvc/utils/build.py b/dvc/utils/build.py -new file mode 100644 -index 00000000..3d149b9a ---- /dev/null -+++ b/dvc/utils/build.py -@@ -0,0 +1 @@ -+PKG = "osxpkg" --- -2.17.1 diff --git a/scripts/patches/rpm.patch b/scripts/patches/rpm.patch deleted file mode 100644 index d9157d9e8c..0000000000 --- a/scripts/patches/rpm.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- - dvc/utils/build.py | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 dvc/utils/build.py - -diff --git a/dvc/utils/build.py b/dvc/utils/build.py -new file mode 100644 -index 00000000..ada7a0bb ---- /dev/null -+++ b/dvc/utils/build.py -@@ -0,0 +1 @@ -+PKG = "rpm" --- -2.17.1 From 4fdf2694507230d9eb0e8849e7860dac38dbd8ab Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 20:06:19 +0100 Subject: [PATCH 05/13] fix dvc build path --- scripts/build_posix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index 6c896c9c70..899933e5ad 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -51,7 +51,7 @@ command_exists() fpm_build() { - echo "PKG = \"$1\"" > dvc/build.py + echo "PKG = \"$1\"" > $(pwd)/dvc/utils/build.py print_info "Building $1..." VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") fpm -s dir \ From c68adc9a6d4aa89ba8868dead336e0207861a8ac Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 20:23:14 +0100 Subject: [PATCH 06/13] remove windows patch in favor of echo --- scripts/build_windows.cmd | 3 +-- scripts/patches/windows.patch | 14 -------------- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 scripts/patches/windows.patch diff --git a/scripts/build_windows.cmd b/scripts/build_windows.cmd index 0df597f31f..90c513c83c 100755 --- a/scripts/build_windows.cmd +++ b/scripts/build_windows.cmd @@ -16,13 +16,12 @@ where choco if %errorlevel% neq 0 (echo Error: choco not found && goto :error) choco install InnoSetup -choco install git call refreshenv where iscc if %errorlevel% neq 0 (echo Error: Couldn't find Inno Setup compiler. && goto :error) echo ====== Installing requirements... ====== -call git patch scripts\patches\windows.patch +echo PKG = "exe" > dvc\utils\build.py call pip install .[all] || goto :error call pip install psutil || goto :error call dvc pull || goto :error diff --git a/scripts/patches/windows.patch b/scripts/patches/windows.patch deleted file mode 100644 index 32a293b6b4..0000000000 --- a/scripts/patches/windows.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- - dvc/utils/build.py | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 dvc/utils/build.py - -diff --git a/dvc/utils/build.py b/dvc/utils/build.py -new file mode 100644 -index 00000000..ada7a0bb ---- /dev/null -+++ b/dvc/utils/build.py -@@ -0,0 +1 @@ -+PKG = "exe" --- -2.17.1 From 707cce9bd25a9edc97f17f2a5fdee22a1076336a Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 20:24:26 +0100 Subject: [PATCH 07/13] remove unnecessary line --- scripts/build_posix.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index 899933e5ad..d8a92ea6d9 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -102,7 +102,6 @@ install_dependencies() build_dvc() { print_info "Building dvc binary..." - pyinstaller \ --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ --name dvc \ From a0efedcd31fdf2167ead5f41a32135a56771ed62 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 21:02:07 +0100 Subject: [PATCH 08/13] remove arch support from readme --- README.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.rst b/README.rst index 793c0093a7..2ba9c2c25b 100644 --- a/README.rst +++ b/README.rst @@ -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 `_. - -.. code-block:: bash - - yay -S dvc - Related technologies ==================== From 1156763e842fcd30ec7ee6ac2f2a9a4332a60e64 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 21:40:46 +0100 Subject: [PATCH 09/13] add pip fallback --- dvc/updater.py | 6 ++++-- dvc/utils/pkg.py | 2 +- scripts/build_package.sh | 2 ++ scripts/build_posix.sh | 15 ++++++++++----- tests/func/test_updater.py | 10 ---------- tests/func/test_version.py | 5 ++--- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/dvc/updater.py b/dvc/updater.py index cdb9490e41..53cf64da7b 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -124,12 +124,12 @@ def _get_update_instructions(self): instructions = { "pip": "Run {yellow}pip{reset} install dvc {blue}--upgrade{reset}", "rpm": "Run {yellow}yum{reset} update dvc", - "osxpkg": "Run {yellow}brew{reset} upgrade dvc", + "brew": "Run {yellow}brew{reset} upgrade dvc", "deb": ( "Run {yellow}apt-get{reset} install" " {blue}--only-upgrade{reset} dvc" ), - "exe": ( + "binary": ( "To upgrade follow these steps:\n" "1. Uninstall dvc binary\n" "2. Go to {blue}https://dvc.org{reset}\n" @@ -144,5 +144,7 @@ def _get_update_instructions(self): } package_manager = get_package_manager() + if package_manager in ("osxpkg", "exe"): + package_manager = "binary" return instructions[package_manager] diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index df44931387..f1a6fe3699 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -3,7 +3,7 @@ def check_build_patch(): try: - from .build import PKG # patched during conda package build + from .build import PKG # file created during dvc build return PKG except ImportError: diff --git a/scripts/build_package.sh b/scripts/build_package.sh index 218fde1b16..d64f3e6e43 100755 --- a/scripts/build_package.sh +++ b/scripts/build_package.sh @@ -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 diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index d8a92ea6d9..c9926a2c46 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -51,7 +51,6 @@ command_exists() fpm_build() { - echo "PKG = \"$1\"" > $(pwd)/dvc/utils/build.py print_info "Building $1..." VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") fpm -s dir \ @@ -132,15 +131,21 @@ build_dvc() fi } +build() +{ + echo "PKG = \"$1\"" > dvc/utils/build.py + build_dvc + fpm_build $1 +} + cleanup 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 diff --git a/tests/func/test_updater.py b/tests/func/test_updater.py index bef364bbfa..4045c0ca67 100644 --- a/tests/func/test_updater.py +++ b/tests/func/test_updater.py @@ -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 diff --git a/tests/func/test_version.py b/tests/func/test_version.py index dae8aef5f4..0668fe7203 100644 --- a/tests/func/test_version.py +++ b/tests/func/test_version.py @@ -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 type: .*"), caplog.text) assert re.search( re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text ) @@ -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 type: .*"), caplog.text) assert not re.search( re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text ) From 172ad715537f5f6aba1eb1ba7fcb10a461c810cd Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 21:46:36 +0100 Subject: [PATCH 10/13] fix typo --- dvc/updater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/updater.py b/dvc/updater.py index 53cf64da7b..b8349416a3 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -135,7 +135,7 @@ 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" From 3ba4b8bd4d952546a1bb5e847750cdac33efb797 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 22:10:19 +0100 Subject: [PATCH 11/13] remove unnecessary pip check --- dvc/utils/pkg.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index f1a6fe3699..f5dace688c 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -1,17 +1,7 @@ -from dvc.utils import is_binary - - -def check_build_patch(): +def get_package_manager(): try: from .build import PKG # file created during dvc build return PKG except ImportError: return None - - -def get_package_manager(): - if not is_binary(): - return "pip" - - return check_build_patch() From 448ae956047ef591d8775312c7784377b7f0f926 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 22:22:25 +0100 Subject: [PATCH 12/13] fix windows echo --- scripts/build_windows.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_windows.cmd b/scripts/build_windows.cmd index 90c513c83c..61ff864c57 100755 --- a/scripts/build_windows.cmd +++ b/scripts/build_windows.cmd @@ -21,7 +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 +echo 'PKG = "exe"' > dvc\utils\build.py call pip install .[all] || goto :error call pip install psutil || goto :error call dvc pull || goto :error From 53f4ad294373bae22267b81562d84651565bab10 Mon Sep 17 00:00:00 2001 From: n3hrox Date: Sun, 10 Nov 2019 23:56:28 +0100 Subject: [PATCH 13/13] add build cleanup --- dvc/command/version.py | 7 +++---- dvc/updater.py | 4 ++-- dvc/utils/pkg.py | 11 ++++------- scripts/build_posix.sh | 2 +- tests/func/test_version.py | 4 ++-- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/dvc/command/version.py b/dvc/command/version.py index 0025ee4b25..e8e687d2db 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -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__) @@ -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 type: {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: diff --git a/dvc/updater.py b/dvc/updater.py index b8349416a3..279d5d23af 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -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__) @@ -143,7 +143,7 @@ def _get_update_instructions(self): ), } - package_manager = get_package_manager() + package_manager = PKG if package_manager in ("osxpkg", "exe"): package_manager = "binary" diff --git a/dvc/utils/pkg.py b/dvc/utils/pkg.py index f5dace688c..5d04b78ba9 100644 --- a/dvc/utils/pkg.py +++ b/dvc/utils/pkg.py @@ -1,7 +1,4 @@ -def get_package_manager(): - try: - from .build import PKG # file created during dvc build - - return PKG - except ImportError: - return None +try: + from .build import PKG # file created during dvc build +except ImportError: + PKG = None diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index c9926a2c46..53e07dacfb 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -133,12 +133,12 @@ build_dvc() build() { + cleanup echo "PKG = \"$1\"" > dvc/utils/build.py build_dvc fpm_build $1 } -cleanup install_dependencies if [[ "$(uname)" == 'Linux' ]]; then diff --git a/tests/func/test_version.py b/tests/func/test_version.py index 0668fe7203..c8614acd61 100644 --- a/tests/func/test_version.py +++ b/tests/func/test_version.py @@ -16,7 +16,7 @@ def test_info_in_repo(repo_dir, dvc_repo, 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 type: .*"), 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 ) @@ -41,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 type: .*"), 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 )