| From 07fce2101d83b5334de78e661ba0361c2874ebdf Mon Sep 17 00:00:00 2001 |
| From: Alistair Francis <alistair.francis@wdc.com> |
| Date: Mon, 18 Mar 2019 16:30:45 -0700 |
| Subject: [PATCH 1/5] Remove python venv |
| |
| Remove the python venv requirements and instead just use the native |
| python and pip pacakges. |
| |
| Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
| Upstream-Status: Inappropriate [embedded specific] |
| --- |
| dev_setup.sh | 39 --------------------------------------- |
| start-mycroft.sh | 13 ------------- |
| venv-activate.sh | 44 +------------------------------------------- |
| 3 files changed, 1 insertion(+), 95 deletions(-) |
| |
| diff --git a/dev_setup.sh b/dev_setup.sh |
| index cf81ed25f0f..99a44bfd8a7 100755 |
| --- a/dev_setup.sh |
| +++ b/dev_setup.sh |
| @@ -338,18 +338,6 @@ ${YELLOW}Make sure to manually install:$BLUE git python3 python-setuptools pytho |
| fi |
| } |
| |
| -VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${TOP}/.venv"} |
| - |
| -function install_venv() { |
| - $opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip |
| - # Force version of pip for reproducability, but there is nothing special |
| - # about this version. Update whenever a new version is released and |
| - # verified functional. |
| - curl https://bootstrap.pypa.io/3.3/get-pip.py | "${VIRTUALENV_ROOT}/bin/python" - 'pip==18.0.0' |
| - # Function status depending on if pip exists |
| - [[ -x ${VIRTUALENV_ROOT}/bin/pip ]] |
| -} |
| - |
| install_deps |
| |
| # Configure to use the standard commit template for |
| @@ -383,17 +371,6 @@ else |
| fi |
| fi |
| |
| -if [[ ! -x ${VIRTUALENV_ROOT}/bin/activate ]] ; then |
| - if ! install_venv ; then |
| - echo 'Failed to set up virtualenv for mycroft, exiting setup.' |
| - exit 1 |
| - fi |
| -fi |
| - |
| -# Start the virtual environment |
| -source "${VIRTUALENV_ROOT}/bin/activate" |
| -cd "$TOP" |
| - |
| # Install pep8 pre-commit hook |
| HOOK_FILE='./.git/hooks/pre-commit' |
| if [[ -n $INSTALL_PRECOMMIT_HOOK ]] || grep -q 'MYCROFT DEV SETUP' $HOOK_FILE; then |
| @@ -408,22 +385,6 @@ fi |
| |
| PYTHON=$(python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))") |
| |
| -# Add mycroft-core to the virtualenv path |
| -# (This is equivalent to typing 'add2virtualenv $TOP', except |
| -# you can't invoke that shell function from inside a script) |
| -VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/$PYTHON/site-packages/_virtualenv_path_extensions.pth" |
| -if [[ ! -f $VENV_PATH_FILE ]] ; then |
| - echo 'import sys; sys.__plen = len(sys.path)' > "$VENV_PATH_FILE" || return 1 |
| - echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$VENV_PATH_FILE" || return 1 |
| -fi |
| - |
| -if ! grep -q "$TOP" $VENV_PATH_FILE ; then |
| - echo 'Adding mycroft-core to virtualenv path' |
| - sed -i.tmp '1 a\ |
| -'"$TOP"' |
| -' "$VENV_PATH_FILE" |
| -fi |
| - |
| # install required python modules |
| if ! pip install -r requirements.txt ; then |
| echo 'Warning: Failed to install all requirements. Continue? y/N' |
| diff --git a/start-mycroft.sh b/start-mycroft.sh |
| index 0f88430982e..3aed2f189d4 100755 |
| --- a/start-mycroft.sh |
| +++ b/start-mycroft.sh |
| @@ -20,7 +20,6 @@ script=${0} |
| script=${script##*/} |
| cd -P "$( dirname "$SOURCE" )" |
| DIR="$( pwd )" |
| -VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${DIR}/.venv"} |
| |
| function help() { |
| echo "${script}: Mycroft command/service launcher" |
| @@ -76,19 +75,11 @@ function name-to-script-path() { |
| esac |
| } |
| |
| -function source-venv() { |
| - # Enter Python virtual environment, unless under Docker |
| - if [ ! -f "/.dockerenv" ] ; then |
| - source ${VIRTUALENV_ROOT}/bin/activate |
| - fi |
| -} |
| - |
| first_time=true |
| function init-once() { |
| if ($first_time) ; then |
| echo "Initializing..." |
| "${DIR}/scripts/prepare-msm.sh" |
| - source-venv |
| first_time=false |
| fi |
| } |
| @@ -225,15 +216,12 @@ case ${_opt} in |
| # launch-background ${_opt} |
| # ;; |
| "unittest") |
| - source-venv |
| pytest test/unittests/ --cov=mycroft "$@" |
| ;; |
| "singleunittest") |
| - source-venv |
| pytest "$@" |
| ;; |
| "skillstest") |
| - source-venv |
| pytest test/integrationtests/skills/discover_tests.py "$@" |
| ;; |
| "audiotest") |
| @@ -243,7 +231,6 @@ case ${_opt} in |
| launch-process ${_opt} |
| ;; |
| "sdkdoc") |
| - source-venv |
| cd doc |
| make ${_params} |
| cd .. |
| diff --git a/venv-activate.sh b/venv-activate.sh |
| index d1e7bcb44e7..10b46d4de3b 100644 |
| --- a/venv-activate.sh |
| +++ b/venv-activate.sh |
| @@ -22,49 +22,7 @@ |
| |
| # wrap in function to allow local variables, since this file will be source'd |
| function main() { |
| - local quiet=0 |
| - |
| - for arg in "$@" |
| - do |
| - case $arg in |
| - "-q"|"--quiet" ) |
| - quiet=1 |
| - ;; |
| - |
| - "-h"|"--help" ) |
| - echo "venv-activate.sh: Enter the Mycroft virtual environment" |
| - echo "Usage:" |
| - echo " source venv-activate.sh" |
| - echo "or" |
| - echo " . venv-activate.sh" |
| - echo "" |
| - echo "Options:" |
| - echo " -q | --quiet Don't show instructions." |
| - echo " -h | --help Show help." |
| - return 0 |
| - ;; |
| - |
| - *) |
| - echo "ERROR: Unrecognized option: $@" |
| - return 1 |
| - ;; |
| - esac |
| - done |
| - |
| - if [ "$0" == "$BASH_SOURCE" ] ; then |
| - # Prevent running in script then exiting immediately |
| - echo "ERROR: Invoke with 'source venv-activate.sh' or '. venv-activate.sh'" |
| - else |
| - local SRC_DIR="$( builtin cd "$( dirname "${BASH_SOURCE}" )" ; pwd -P )" |
| - source ${SRC_DIR}/.venv/bin/activate |
| - |
| - # Provide an easier to find "mycroft-" prefixed command. |
| - unalias mycroft-venv-activate 2>/dev/null |
| - alias mycroft-venv-deactivate="deactivate && unalias mycroft-venv-deactivate 2>/dev/null && alias mycroft-venv-activate=\"source '${SRC_DIR}/venv-activate.sh'\"" |
| - if [ $quiet -eq 0 ] ; then |
| - echo "Entering Mycroft virtual environment. Run 'mycroft-venv-deactivate' to exit" |
| - fi |
| - fi |
| + echo "Not entering Python VENV" |
| } |
| |
| main $@ |
| -- |
| 2.23.0 |
| |