#!/bin/bash if [ ! -z "$PYTHON_BIN_PATH" ]; then >&2 echo "PYTHON_BIN_PATH already set to $PYTHON_BIN_PATH" echo -n $PYTHON_BIN_PATH else set +a set +e d=`mktemp -d` u=`dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump -v -n 16 -e '1/1 "%02x"'` mkdir -p $d/$u cat <> $d/setup.py from setuptools import setup setup( name="$u", version="0.0.0", packages=[ "$u", ], entry_points={ "console_scripts": [ "$u.bin=$u:main", ], }, ) EOF cat <> $d/$u/__init__.py def main(): pass EOF pushd $d > /dev/null python setup.py --quiet sdist pip install -q dist/${u}-0.0.0.tar.gz p=`which $u.bin` pip uninstall -q -y $u export PYTHON_BIN_PATH=$(dirname $p) echo -n $PYTHON_BIN_PATH popd > /dev/null set -e set -a fi