From cb88b306ab3cab89fbaaa114007b1cccc23281e8 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 26 Oct 2017 23:30:48 -0400 Subject: [PATCH 1/2] Fix build script to permit paths with spaces - Quote dynamic command names - Use "python pip" instead of "pip" when in virtualenv (pip can't handle paths with spaces inside of a virtualenv, may be fixed in pip 10). --- README.md | 12 +++++------- app/package.json | 1 + build.sh | 2 +- build/build.sh | 18 ++++++++++++------ build/prebuild.sh | 11 +++++------ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 179c7abdd..654778429 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,14 @@ Our [releases page](https://github.com/lbryio/lbry-app/releases/latest) also con To install from source or make changes to the application, continue reading below. -## Development +## Development on Linux and macOS ### One-time Setup -1. Install npm and node (v6 and above required, use [nvm](https://github.com/creationix/nvm/blob/master/README.md) if having trouble) -2. Install keytar and libsecret (see [keytar repository](https://github.com/atom/node-keytar) ) -3. Install yarn by running: npm install -g yarn (may require elevated permissions) -4. Check out this repo. -5. Set up a Python virtual environment, or live on the wild side. -6. Run `./build.sh`. This builds the UI assets and puts them into `app/dist`. It also downloads [lbry daemon](https://github.com/lbryio/lbry/releases). +1. Clone this repo +2. `INSTALL_DEPENDENCIES=true ./build.sh` + +This will download and install the LBRY app and its dependencies, including [the LBRY daemon](https://github.com/lbryio/lbry) and command line utilities like `node` and `yarn`. The LBRY app requires Node >= 6; if you have an earlier version of Node installed and want to keep it, you can use [nvm](https://github.com/creationix/nvm) to switch back and forth. ### Running diff --git a/app/package.json b/app/package.json index d02fc93bd..8ba5df0b5 100644 --- a/app/package.json +++ b/app/package.json @@ -3,6 +3,7 @@ "version": "0.18.0rc4", "main": "main.js", "description": "A browser for the LBRY network, a digital marketplace controlled by its users.", + "homepage": "https://github.com/lbryio/lbry-app", "author": { "name": "LBRY Inc.", "email": "hello@lbry.io" diff --git a/build.sh b/build.sh index 6dc7044f1..ec3e6d703 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ #!/bin/bash # this is here because teamcity runs /build.sh to build the project DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -$DIR/build/build.sh +"$DIR/build/build.sh" diff --git a/build/build.sh b/build/build.sh index 310fbcfd8..8cf38ca20 100755 --- a/build/build.sh +++ b/build/build.sh @@ -29,14 +29,19 @@ FULL_BUILD="${FULL_BUILD:-false}" if [ -n "${TEAMCITY_VERSION:-}" -o -n "${APPVEYOR:-}" ]; then FULL_BUILD="true" fi -if [ "$FULL_BUILD" != "true" ]; then - echo -e "\033[1;36mDependencies will NOT be installed. Run with 'FULL_BUILD=true' to install dependencies.\x1b[m" -fi if [ "$FULL_BUILD" == "true" ]; then + INSTALL_DEPENDENCIES="true" +else + INSTALL_DEPENDENCIES="${INSTALL_DEPENDENCIES:-false}" +fi + +if [ "$INSTALL_DEPENDENCIES" != "true" ]; then + echo -e "\033[1;36mDependencies will NOT be installed. Run with \"INSTALL_DEPENDENCIES=true\" to install dependencies, or \"FULL_BUILD=true\" to install dependencies and build a complete app.\x1b[m" +else # install dependencies echo -e "\033[0;32mInstalling Dependencies\x1b[m" - $BUILD_DIR/prebuild.sh + "$BUILD_DIR/prebuild.sh" VENV="$BUILD_DIR/venv" if [ -d "$VENV" ]; then @@ -46,7 +51,8 @@ if [ "$FULL_BUILD" == "true" ]; then set +u source "$VENV/bin/activate" set -u - pip install -r "$BUILD_DIR/requirements.txt" + # "python pip install" required to support path names with spaces (may be fixed in pip 10) + python "`which pip`" install -r "$BUILD_DIR/requirements.txt" python "$BUILD_DIR/set_version.py" fi @@ -90,7 +96,7 @@ DAEMON_URL=$(echo ${DAEMON_URL_TEMPLATE//DAEMONVER/$DAEMON_VER} | sed "s/OSNAME/ DAEMON_VER_PATH="$BUILD_DIR/daemon.ver" echo "$DAEMON_VER_PATH" if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/app/dist/lbrynet-daemon || "$(< "$DAEMON_VER_PATH")" != "$DAEMON_VER" ]]; then - wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip" + curl -sL -o "$BUILD_DIR/daemon.zip" "$DAEMON_URL" unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/" rm "$BUILD_DIR/daemon.zip" echo "$DAEMON_VER" > "$DAEMON_VER_PATH" diff --git a/build/prebuild.sh b/build/prebuild.sh index 16f4e4d19..fb6d041c3 100755 --- a/build/prebuild.sh +++ b/build/prebuild.sh @@ -18,7 +18,7 @@ fi SUDO='' -if $LINUX && (( $EUID != 0 )); then +if (( $EUID != 0 )); then SUDO='sudo' fi @@ -41,7 +41,7 @@ set -eu if $LINUX; then INSTALL="$SUDO apt-get install --no-install-recommends -y" - $INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev wget + $INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev curl elif $OSX && ! cmd_exists brew ; then /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi @@ -64,11 +64,10 @@ fi if ! cmd_exists pip; then if $LINUX; then $INSTALL python-pip - $SUDO pip install --upgrade pip - else - echo "Pip required" - exit 1 + elif $OSX; then + $SUDO easy_install pip fi + $SUDO pip install --upgrade pip fi if $LINUX && [ "$(pip list --format=columns | grep setuptools | wc -l)" -ge 1 ]; then From 597be05199474a5600817d7b2ec07db5f7dc78d0 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Fri, 10 Nov 2017 10:47:51 -0500 Subject: [PATCH 2/2] simplify build, almost remove python --- README.md | 5 ++-- build/build.sh | 33 ++++++++------------------ build/{prebuild.sh => install_deps.sh} | 18 ++++++++++---- build/set_version.py | 21 ---------------- 4 files changed, 26 insertions(+), 51 deletions(-) rename build/{prebuild.sh => install_deps.sh} (92%) delete mode 100644 build/set_version.py diff --git a/README.md b/README.md index 654778429..8bb0595e9 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ To install from source or make changes to the application, continue reading belo ### One-time Setup 1. Clone this repo -2. `INSTALL_DEPENDENCIES=true ./build.sh` +2. `DEPS=true ./build.sh` -This will download and install the LBRY app and its dependencies, including [the LBRY daemon](https://github.com/lbryio/lbry) and command line utilities like `node` and `yarn`. The LBRY app requires Node >= 6; if you have an earlier version of Node installed and want to keep it, you can use [nvm](https://github.com/creationix/nvm) to switch back and forth. +This will download and install the LBRY app and its dependencies, including [the LBRY daemon](https://github.com/lbryio/lbry) and command line utilities like `node` and `yarn`. \ +The LBRY app requires Node >= 6; if you have an earlier version of Node installed and want to keep it, you can use [nvm](https://github.com/creationix/nvm) to switch back and forth. ### Running diff --git a/build/build.sh b/build/build.sh index 8cf38ca20..2a6fa1d4e 100755 --- a/build/build.sh +++ b/build/build.sh @@ -30,30 +30,13 @@ if [ -n "${TEAMCITY_VERSION:-}" -o -n "${APPVEYOR:-}" ]; then FULL_BUILD="true" fi -if [ "$FULL_BUILD" == "true" ]; then - INSTALL_DEPENDENCIES="true" -else - INSTALL_DEPENDENCIES="${INSTALL_DEPENDENCIES:-false}" -fi - -if [ "$INSTALL_DEPENDENCIES" != "true" ]; then +DEPS="${DEPS:-$FULL_BUILD}" +if [ "$DEPS" != "true" ]; then echo -e "\033[1;36mDependencies will NOT be installed. Run with \"INSTALL_DEPENDENCIES=true\" to install dependencies, or \"FULL_BUILD=true\" to install dependencies and build a complete app.\x1b[m" else # install dependencies echo -e "\033[0;32mInstalling Dependencies\x1b[m" - "$BUILD_DIR/prebuild.sh" - - VENV="$BUILD_DIR/venv" - if [ -d "$VENV" ]; then - rm -rf "$VENV" - fi - virtualenv "$VENV" - set +u - source "$VENV/bin/activate" - set -u - # "python pip install" required to support path names with spaces (may be fixed in pip 10) - python "`which pip`" install -r "$BUILD_DIR/requirements.txt" - python "$BUILD_DIR/set_version.py" + "$BUILD_DIR/install_deps.sh" fi [ -d "$ROOT/dist" ] && rm -rf "$ROOT/dist" @@ -140,9 +123,13 @@ if [ "$FULL_BUILD" == "true" ]; then # electron-build has a publish feature, but I had a hard time getting # it to reliably work and it also seemed difficult to configure. Not proud of # this, but it seemed better to write my own. - python "$BUILD_DIR/upload_assets.py" - - deactivate + VENV="$BUILD_DIR/venv" + if [ -d "$VENV" ]; then + rm -rf "$VENV" + fi + virtualenv "$VENV" + "$VENV/bin/pip" install -r "$BUILD_DIR/requirements.txt" + "$VENV/bin/python" "$BUILD_DIR/upload_assets.py" echo -e '\033[0;32mBuild and packaging complete.\x1b[m' else diff --git a/build/prebuild.sh b/build/install_deps.sh similarity index 92% rename from build/prebuild.sh rename to build/install_deps.sh index fb6d041c3..34a212dfe 100755 --- a/build/prebuild.sh +++ b/build/install_deps.sh @@ -1,8 +1,6 @@ #!/bin/bash set -euo pipefail -set -x - LINUX=false OSX=false @@ -52,6 +50,9 @@ if ! cmd_exists python; then $INSTALL python2.7 elif $OSX; then brew install python + else + echo "python2.7 required" + exit 1 fi fi @@ -66,6 +67,9 @@ if ! cmd_exists pip; then $INSTALL python-pip elif $OSX; then $SUDO easy_install pip + else + echo "pip required" + exit 1 fi $SUDO pip install --upgrade pip fi @@ -84,6 +88,9 @@ if ! cmd_exists node; then $INSTALL nodejs elif $OSX; then brew install node + else + echo "node required" + exit 1 fi fi @@ -95,16 +102,17 @@ if ! cmd_exists yarn; then $SUDO apt-get install yarn elif $OSX; then brew install yarn + else + echo "yarn required" + exit 1 fi fi if ! cmd_exists unzip; then if $LINUX; then $INSTALL unzip - elif $OSX; then + else echo "unzip required" exit 1 - # not sure this works, but OSX should come with unzip - # brew install unzip fi fi diff --git a/build/set_version.py b/build/set_version.py deleted file mode 100644 index 313cf6c93..000000000 --- a/build/set_version.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Set the package version to the output of `git describe`""" - -from __future__ import print_function - -import os.path -import sys -import fileinput - - -def main(): - filename = os.path.abspath( - os.path.join(os.path.abspath(__file__), '..', '..', 'ui', 'js', 'lbryio.js')) - for line in fileinput.input(filename, inplace=True): - if line.startswith(' enabled: false'): - print(' enabled: true') - else: - print(line, end='') - - -if __name__ == '__main__': - sys.exit(main())