From 315c0936586f9402451f012bbfd5994ce07e61d1 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 1 Jun 2017 19:59:23 +0300 Subject: [PATCH 1/2] dvc: add hooks for pyinstall Pyinstall can't resolve all dependencies on it's own, so we need to help it with hoolks. From now on, we could try to use pyinstall on Windows and MacOS to see if will build standalone binaries. --- .gitignore | 2 ++ hooks/hook-google.cloud.py | 2 ++ hooks/hook-google.cloud.storage.py | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 hooks/hook-google.cloud.py create mode 100644 hooks/hook-google.cloud.storage.py diff --git a/.gitignore b/.gitignore index bb6167bad..4b5c0cb5b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ build/ dist/ *.egg-info/ + +hooks/*.pyc diff --git a/hooks/hook-google.cloud.py b/hooks/hook-google.cloud.py new file mode 100644 index 000000000..fc0b4659f --- /dev/null +++ b/hooks/hook-google.cloud.py @@ -0,0 +1,2 @@ +from PyInstaller.utils.hooks import copy_metadata +datas = copy_metadata('google-cloud-core') diff --git a/hooks/hook-google.cloud.storage.py b/hooks/hook-google.cloud.storage.py new file mode 100644 index 000000000..0a943167f --- /dev/null +++ b/hooks/hook-google.cloud.storage.py @@ -0,0 +1,2 @@ +from PyInstaller.utils.hooks import copy_metadata +datas = copy_metadata('google-cloud-storage') From cb263cad3f675e6b548d90542aea6c81caf7d7b8 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 1 Jun 2017 21:36:40 +0300 Subject: [PATCH 2/2] build: add build_linux.sh to build rpm and deb It uses pyintsaller to create standalone dvc binary and then uses fpm to pack it into deb and rpm. Signed-off-by: Ruslan Kuprieiev --- .gitignore | 3 +++ build_linux.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 build_linux.sh diff --git a/.gitignore b/.gitignore index 4b5c0cb5b..315af31ca 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ dist/ *.egg-info/ hooks/*.pyc + +*.rpm +*.deb diff --git a/build_linux.sh b/build_linux.sh new file mode 100755 index 000000000..75ea6f68c --- /dev/null +++ b/build_linux.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +BUILD_DIR=build +INSTALL_DIR=$BUILD_DIR/usr +BIN_DIR=$INSTALL_DIR/bin + +print_error() +{ + echo -e "\e[31m$1\e[0m" +} + +trap 'print_error "FAIL"; exit 1' ERR + +print_info() +{ + echo -e "\e[32m$1\e[0m" +} + +command_exists() +{ + command -v $1 > /dev/null 2>&1 +} + +fpm_build() +{ + print_info "Building $1..." + fpm -s dir -f -t $1 -n dvc -v $(python -c "import dvc; from dvc.main import VERSION; print(str(VERSION))") $INSTALL_DIR +} + +cleanup() +{ + print_info "Cleaning up..." + rm -rf build +} + +install_dependencies() +{ + print_info "Installing requirements..." + pip install -r requirements.txt + + print_info "Installing fpm..." + if command_exists dnf; then + sudo dnf install ruby-devel gcc make rpm-build + elif command_exists yum; then + sudo yum install ruby-devel gcc make rpm-build + elif command_exists apt-get; then + sudo apt-get install ruby ruby-dev rubygems build-essential + else + echo "Unable to install fpm dependencies" && exit 1 + fi + + gem install --no-ri --no-rdoc fpm + + print_info "Installing pyinstaller..." + pip install pyinstaller +} + +build_dvc() +{ + print_info "Building dvc binary..." + pyinstaller --onefile --additional-hooks-dir $(pwd)/hooks dvc/__main__.py --name dvc --distpath $BIN_DIR --specpath $BUILD_DIR +} + +cleanup +install_dependencies +build_dvc +fpm_build rpm +fpm_build deb +cleanup + +print_info "Successfully built dvc rpm and deb packages"