|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
ROOT_PATH=$(pwd)/build/gae |
|
BUILD_PATH=${ROOT_PATH}/build |
|
LIB_PATH=${ROOT_PATH}/lib |
|
ENV_PATH=${ROOT_PATH}/ve |
|
LOG_PATH=${ROOT_PATH}/gae_zip_build.log |
|
|
|
|
|
APICLIENT_VERSION=$(python -c "import apiclient; print apiclient.__version__") |
|
|
|
|
|
DIST_PATH=$(pwd)/dist/gae |
|
ZIP_NAME=google-api-python-client-gae-${APICLIENT_VERSION}.zip |
|
ZIP_PATH=${DIST_PATH}/${ZIP_NAME} |
|
|
|
|
|
echo "Cleaning build env" |
|
rm -rf ${ROOT_PATH} |
|
mkdir -p ${ROOT_PATH} |
|
|
|
|
|
|
|
echo "Creating virtualenv and installing pip==dev" |
|
virtualenv --no-site-packages ${ENV_PATH} >> ${LOG_PATH} |
|
${ENV_PATH}/bin/pip install --upgrade pip==dev >> ${LOG_PATH} |
|
|
|
|
|
echo "Building google-api-python client" |
|
${ENV_PATH}/bin/pip install -b ${BUILD_PATH} -t ${LIB_PATH} . >> ${LOG_PATH} |
|
|
|
|
|
echo "Pruning target library" |
|
find ${LIB_PATH} -name "*.pyc" -exec rm {} \; >> ${LOG_PATH} |
|
rm -rf ${LIB_PATH}/*.egg-info >> ${LOG_PATH} |
|
|
|
|
|
echo "Creating zip" |
|
mkdir -p ${DIST_PATH} |
|
pushd ${LIB_PATH} >> ${LOG_PATH} |
|
zip -r ${ZIP_PATH} * >> ${LOG_PATH} |
|
popd >> ${LOG_PATH} |
|
|
|
|
|
echo "Built zip in ${ZIP_PATH}" |
|
|
|
|
|
|
|
echo "Sanity testing the zip:" |
|
export SANITY_MODS="httplib2 apiclient uritemplate oauth2client" |
|
export SANITY_ZIP=${ZIP_PATH} |
|
export PYTHONPATH=${ZIP_PATH} |
|
${ENV_PATH}/bin/python -c "import sys, os |
|
sys.path.pop(0) # remove the pwd |
|
for name in os.getenv('SANITY_MODS').split(): |
|
mod = __import__(name) |
|
assert os.getenv('SANITY_ZIP') in mod.__file__ |
|
print ' ', os.path.relpath(mod.__file__)" |
|
|