source: OpenWorkouts-current/bin/install @ d17dffe

currentfeature/docs
Last change on this file since d17dffe was d17dffe, checked in by borja <borja@…>, 5 years ago

(#41) Added install script.

Now, after getting a fresh copy of the repo, you can install OpenWorkouts by
doing:

chmod +x bin/install
./bin/install

This installs OpenWorkouts in a python3 virtual environment located in the
same directory as the OpenWorkouts repo (useful for developers mostly)

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#!/bin/sh
2#
3# Script to install OpenWorkouts for development
4#
5
6# Full path to where we run the script from
7current=`pwd`
8# Full path to the main python binary (will be set by check_python3())
9python_bin=''
10# Full path to the env
11env_path=${current}/env
12
13check_python3() {
14    # if python3 is not installed, exit with an error
15    if command -v python3 > /dev/null; then
16        # ok
17        python_bin=`command -v python3`
18        return
19    else
20        # no python3 binary, look for python
21        if command -v python > /dev/null; then
22            # python found, check if it is 3.x
23            if `command -v python` -c "import sys; exit(0) if sys.version.startswith('3.') else exit(1)"; then
24                python_bin=`command -v python`
25                return
26            else
27                # no python binary, error
28                echo "Error: could not find a suitable python version installed, please install python 3.x"
29                exit 1
30            fi
31        else
32            # no python binary, error
33            echo "Error: could not find a suitable python version installed, please install python 3.x"
34            exit 1
35        fi
36    fi
37}
38
39create_venv() {
40    # create a new virtual environment
41    ${python_bin} -m venv ${env_path}
42}
43
44upgrade_pip_setuptools() {
45    . ${env_path}/bin/activate
46    yes | pip install --upgrade setuptools pip
47    deactivate
48}
49
50install_openworkouts() {
51    . ${env_path}/bin/activate
52    yes | pip install --upgrade --process-dependency-links -e ${current}[testing]
53    deactivate
54}
55
56install_js_deps() {
57    chmod +x ${current}/bin/js_deps
58    ${current}/bin/js_deps
59}
60
61setup_start_stop() {
62    chmod +x ${current}/bin/start
63    echo "OpenWorkouts successfully installed in ${env_path}"
64    echo ""
65    echo "You can now start the OpenWorkouts service calling:"
66    echo ""
67    echo "  cd ${current} && ./bin/start"
68    echo ""
69    # echo "You can stop any running OpenWorkouts instances calling:"
70    # echo ""
71    # echo "  ${current}/bin/stop"
72    # echo ""
73}
74
75check_python3
76create_venv
77upgrade_pip_setuptools
78install_openworkouts
79install_js_deps
80setup_start_stop
81
82echo ${python_bin}
Note: See TracBrowser for help on using the repository browser.