Skip to content

Commit

Permalink
Tested script to pack portable ubuntu version
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-kotliar committed Feb 27, 2020
1 parent f0f44d8 commit 18557b8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion dev/README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev/linux/airflow
Original file line number Diff line number Diff line change
@@ -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 "$@"
2 changes: 1 addition & 1 deletion dev/linux/apiserver
Original file line number Diff line number Diff line change
@@ -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 "$@"
49 changes: 5 additions & 44 deletions dev/pack_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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
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}
51 changes: 51 additions & 0 deletions dev/pack_ubuntu_docker.sh
Original file line number Diff line number Diff line change
@@ -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










0 comments on commit 18557b8

Please sign in to comment.