cic-staff-installer/aux/pylocation/pylocation.sh

47 lines
762 B
Bash
Raw Normal View History

2021-12-05 07:54:44 +01:00
#!/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
2021-12-06 10:32:18 +01:00
python3 setup.py --quiet sdist
pip3 install -q dist/${u}-0.0.0.tar.gz
2021-12-05 07:54:44 +01:00
p=`which $u.bin`
2021-12-06 10:32:18 +01:00
pip3 uninstall -q -y $u
2021-12-05 07:54:44 +01:00
export PYTHON_BIN_PATH=$(dirname $p)
echo -n $PYTHON_BIN_PATH
popd > /dev/null
set -e
set -a
fi