|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Create a sitedir-style directory with an installed PyObjC distribution |
| 4 | +# - if the build/wheelhouse directory doesn't exist, pre-built copies will |
| 5 | +# be fetched from the website |
| 6 | +# - running rebuild.sh prior to setup will generate a fresh set of wheels from |
| 7 | +# the current source distribution on PyPI and fill the wheelhouse subdir |
| 8 | +# - the subsequent call to setup.sh will populate the sitedir using these |
| 9 | +# fresh copies |
| 10 | +# |
| 11 | +set -e |
| 12 | + |
| 13 | +TOP=$(dirname "$0") |
| 14 | +BUILD_DIR="${TOP}/build" |
| 15 | +DEST_DIR="${BUILD_DIR}/lib/PyObjC" |
| 16 | + |
| 17 | +VENV_VERSION="13.0.1" |
| 18 | +VENV_PKG="virtualenv-${VENV_VERSION}" |
| 19 | +VENV_TAR="${TOP}/${VENV_PKG}.tar.gz" |
| 20 | +VENV_URL="https://pypi.python.org/packages/source/v/virtualenv/${VENV_PKG}.tar.gz" |
| 21 | +VENV_DIR="${BUILD_DIR}/${VENV_PKG}" |
| 22 | + |
| 23 | +PYOBJC_VERSION="3.0.4" |
| 24 | +PYOBJC_PKG="wheelhouse-pyobjc-${PYOBJC_VERSION}" |
| 25 | +PYOBJC_TAR="${TOP}/${PYOBJC_PKG}.tar.gz" |
| 26 | +PYOBJC_URL="http://plotdevice.io/${PYOBJC_PKG}.tar.gz" |
| 27 | +PYOBJC_DIR="${BUILD_DIR}/wheelhouse" |
| 28 | + |
| 29 | +ENV="${BUILD_DIR}/env" |
| 30 | +PIP="${ENV}/bin/pip -q --isolated" |
| 31 | +VIRTUALENV="python2.7 ${VENV_DIR}/virtualenv.py -q" |
| 32 | + |
| 33 | +#-- |
| 34 | + |
| 35 | +mkdir -p "${BUILD_DIR}" |
| 36 | + |
| 37 | +# fetch/unpack the tarball of wheels |
| 38 | +if [ ! -d "$PYOBJC_DIR" ]; then |
| 39 | + if [ ! -f "$PYOBJC_TAR" ]; then |
| 40 | + echo "${PYOBJC_URL}" |
| 41 | + curl -L -# "${PYOBJC_URL}" -o "${PYOBJC_TAR}" |
| 42 | + fi |
| 43 | + tar xzf "${PYOBJC_TAR}" -C "${BUILD_DIR}" |
| 44 | +fi |
| 45 | + |
| 46 | +# grab a copy of virtualenv to help with the installation |
| 47 | +if [ ! -d "$VENV_DIR" ]; then |
| 48 | + if [ ! -f "${VENV_TAR}" ]; then |
| 49 | + echo "${VENV_URL}" |
| 50 | + curl -L -# "${VENV_URL}" -o "${VENV_TAR}" |
| 51 | + fi |
| 52 | + tar xzf "${VENV_TAR}" -C "${BUILD_DIR}" |
| 53 | +fi |
| 54 | + |
| 55 | +# create a temporary env that we'll only use for its pip command |
| 56 | +if [ ! -d "${ENV}" ]; then |
| 57 | + echo "Setting up staging area..." |
| 58 | + $VIRTUALENV "${ENV}" |
| 59 | +fi |
| 60 | + |
| 61 | +# use our local pip to unpack the wheels into a subdirectory |
| 62 | +if [ ! -d "$DEST_DIR" ]; then |
| 63 | + echo "Unpacking ${PYOBJC_PKG}..." |
| 64 | + $PIP install --target="${DEST_DIR}" --no-index --find-links="${PYOBJC_DIR}" pyobjc |
| 65 | +fi |
| 66 | + |
| 67 | +#-- |
0 commit comments