Add better heuristic for build detection

This commit is contained in:
n3hrox
2019-11-10 18:04:41 +01:00
parent 387a471857
commit f4ee4b0434
6 changed files with 55 additions and 6 deletions
+4 -2
View File
@@ -18,7 +18,7 @@ from dvc.command.base import CmdBaseNoRepo, append_doc_link
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 @@ class CmdVersion(CmdBaseNoRepo):
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"
+4 -4
View File
@@ -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 = {
+6
View File
@@ -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 \
+2
View File
@@ -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
+20
View File
@@ -0,0 +1,20 @@
From 71707795d27aa848d71780b84e056b4f5735650c Mon Sep 17 00:00:00 2001
From: n3hrox <[email protected]>
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
+19
View File
@@ -0,0 +1,19 @@
From 6b53dcffe5e13cb3c196d29a495d8da9bcc26d6d Mon Sep 17 00:00:00 2001
From: n3hrox <[email protected]>
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