Add pylocation script

This commit is contained in:
nolash 2021-12-05 07:54:44 +01:00
parent 52acfda7fc
commit e4a85a9cac
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 49 additions and 3 deletions

View File

@ -0,0 +1,46 @@
#!/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
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

View File

@ -14,8 +14,6 @@ PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8
PIP_INDEX_URL=${PIP_INDEX_URL:-"https://pypi.org/simple"}
CIC_SETUP_TRUSTED_FINGERPRINT=${CIC_SETUP_TRUSTED_FINGERPRINT:-0826EDA1702D1E87C6E2875121D2E7BB88C2A746}
CIC_ROOT_URL=${CIC_ROOT_URL:-https://root.grassrootseconomics.net}
default_python_path=$(dirname $(which python))
PYTHON_BIN_PATH=${PYTHON_BIN_PATH:-$default_python_path}
if [ "$UID" -eq 0 ]; then
dbg $dbg_error "This cannot be run as root"
@ -166,7 +164,6 @@ set +a
. setup_systemd.sh
echo foo $INSTALL_EVM
if [ ! -z $INSTALL_EVM ]; then
. setup_${INSTALL_EVM}.sh
fi

View File

@ -9,6 +9,9 @@ _debug=1
cp -v systemd/cic-cache-server.service $HOME/.config/systemd/user/
cp -v systemd/bloxberg.service $HOME/.config/systemd/user/
dbg $dbg_debug "writing rendered services file $p"
export PYTHON_BIN_PATH=`. aux/pylocation/pylocation.sh 2> /dev/null`
dbg $dbg_info "using python bin path $PYTHON_BIN_PATH for systemd executables"
PYTHON_BIN_PATH=$PYTHON_BIN_PATH ./aux/bash-templater/templater.sh systemd/cic-cache-tracker.service > $HOME/.config/systemd/user/cic-cache-tracker.service
for f in systemd/env/*.conf; do