47 lines
762 B
Bash
47 lines
762 B
Bash
#!/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 <<EOF >> $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 <<EOF >> $d/$u/__init__.py
|
|
def main():
|
|
pass
|
|
EOF
|
|
|
|
pushd $d > /dev/null
|
|
python3 setup.py --quiet sdist
|
|
pip3 install -q dist/${u}-0.0.0.tar.gz
|
|
p=`which $u.bin`
|
|
pip3 uninstall -q -y $u
|
|
export PYTHON_BIN_PATH=$(dirname $p)
|
|
echo -n $PYTHON_BIN_PATH
|
|
popd > /dev/null
|
|
|
|
set -e
|
|
set -a
|
|
fi
|