From 18557b8e77e78abf350e498bbb5bf18bd92cf9ac Mon Sep 17 00:00:00 2001 From: Michael Kotliar Date: Thu, 27 Feb 2020 17:22:55 -0500 Subject: [PATCH] Tested script to pack portable ubuntu version --- dev/README.dev.md | 2 +- dev/linux/airflow | 2 +- dev/linux/apiserver | 2 +- dev/pack_ubuntu.sh | 49 ++++--------------------------------- dev/pack_ubuntu_docker.sh | 51 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 47 deletions(-) create mode 100755 dev/pack_ubuntu_docker.sh diff --git a/dev/README.dev.md b/dev/README.dev.md index 3bae3bd..9bc0360 100644 --- a/dev/README.dev.md +++ b/dev/README.dev.md @@ -48,7 +48,7 @@ sudo apt install python3-pip ### Build portable version for Ubuntu -On the virtual machine with Ubuntu 18.04.2 (Python3, pip3 and virtualenv preinstalled) +On the machine with Docker installed 1. Run `pack_ubuntu.sh` from the dev folder ```bash ./pack_ubuntu.sh diff --git a/dev/linux/airflow b/dev/linux/airflow index b30905a..2b62814 100755 --- a/dev/linux/airflow +++ b/dev/linux/airflow @@ -1,5 +1,5 @@ #!/bin/bash BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) -export PYTHONPATH="$BASE_DIR/lib/python3.6/site-packages" +export PYTHONPATH="$BASE_DIR/lib/python3.*/site-packages" export PATH="$BASE_DIR/bin":"$PATH" airflow "$@" diff --git a/dev/linux/apiserver b/dev/linux/apiserver index bc93759..3e1d4f3 100755 --- a/dev/linux/apiserver +++ b/dev/linux/apiserver @@ -1,5 +1,5 @@ #!/bin/bash BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) -export PYTHONPATH="$BASE_DIR/lib/python3.6/site-packages" +export PYTHONPATH="$BASE_DIR/lib/python3.*/site-packages" export PATH="$BASE_DIR/bin":"$PATH" cwl-airflow apiserver "$@" \ No newline at end of file diff --git a/dev/pack_ubuntu.sh b/dev/pack_ubuntu.sh index 6f2f1b8..97fefaa 100755 --- a/dev/pack_ubuntu.sh +++ b/dev/pack_ubuntu.sh @@ -1,48 +1,9 @@ #!/usr/bin/env bash -# Run script in the current directory without any arguments -# Ubuntu 18.04.3 -# sudo apt-get install python3-dev python3-pip virtualenv 2to3 -# -# -# sudo apt-get install python3-distutils -# sudo apt install python3-testresources +UBUNTU_VERSION="18.04" +PYTHON_VERSION="3.6" +PYTHON_LINK="https://briefcase-support.s3.amazonaws.com/python/${PYTHON_VERSION}/linux/x86_64/Python-${PYTHON_VERSION}-linux-x86_64-support.b1.tar.gz" +BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) -# create directory for portable version of cwl-airflow -mkdir cwl-airflow -cd cwl-airflow - - -# create virtual environment -virtualenv -p `which python3.6` --always-copy . -source ./bin/activate - - -# install cwl-airflow -cd ../.. -pip3 install . -cd ./dev/cwl-airflow -deactivate - - -# replace default path to python3 -find ./bin -executable -type f -maxdepth 1 -exec grep -Iq "^#\!.*python.*" {} \; -exec sed -i '' -e '1s/.*/#!\/usr\/bin\/env python3/' {} \; - - -# copy executable files -mkdir bin_portable -cp ../linux/* ./bin_portable - - -# Copy 2to3 and distutils/ manually which is not included in virtual environment by default -cp -r /usr/lib/python3.6/lib2to3 ./lib/python3.6/site-packages -cp -r /usr/bin/2to3 ./bin -cp -r /usr/lib/python3.6/distutils ./lib/python3.6/site-packages - - -# compress to tar.gz -cd .. -chmod -R u+w ./cwl-airflow -tar -zcvf cwl-airflow.ubuntu.tar.gz cwl-airflow -rm -rf cwl-airflow \ No newline at end of file +docker run --rm -it -v ${BASE_DIR}:/tmp/cwl-airflow ubuntu:${UBUNTU_VERSION} /tmp/cwl-airflow/dev/pack_ubuntu_docker.sh ${PYTHON_LINK} ${PYTHON_VERSION} \ No newline at end of file diff --git a/dev/pack_ubuntu_docker.sh b/dev/pack_ubuntu_docker.sh new file mode 100755 index 0000000..d9dc1ad --- /dev/null +++ b/dev/pack_ubuntu_docker.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) +PYTHON_LINK=$1 +PYTHON_VERSION=$2 + + +apt-get update +apt-get install gcc git wget curl -y + + +mkdir $BASE_DIR/dev/cwl-airflow-ubuntu +cd $BASE_DIR/dev/cwl-airflow-ubuntu + + +wget $PYTHON_LINK +tar xzf Python-${PYTHON_VERSION}-linux-x86_64-support.b1.tar.gz +rm Python-${PYTHON_VERSION}-linux-x86_64-support.b1.tar.gz + + +curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +./bin/python3 get-pip.py +rm get-pip.py + + +./bin/pip3 install --prefix="." --no-warn-script-location --upgrade $BASE_DIR + + +find ./bin -executable -type f -maxdepth 1 -exec grep -Iq "^#\!.*python.*" {} \; -exec sed -i '' -e '1s/.*/#!\/usr\/bin\/env python3/' {} \; + + +mkdir bin_portable +cp ../linux/* ./bin_portable + + +chmod -R u+w . + + +cd .. +tar -zcvf cwl-airflow.ubuntu.tar.gz cwl-airflow-ubuntu +rm -rf cwl-airflow-ubuntu + + + + + + + + + +