2022-12-01 20:58:32 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-12-30 19:06:52 +03:00
|
|
|
set -e
|
|
|
|
|
2022-12-20 15:51:18 +03:00
|
|
|
CMD_NAME=$(basename "$1")
|
|
|
|
PREFIX="$(dirname "$(dirname "$1")")"
|
|
|
|
PROJECT_NAME=$(basename "$(dirname "$PREFIX")")
|
|
|
|
VERSION=$(basename "$PREFIX")
|
|
|
|
PYTHON_VERSION=$(python --version | cut -d' ' -f2)
|
|
|
|
PYTHON_VERSION_MAJ=$(echo $PYTHON_VERSION | cut -d. -f1)
|
|
|
|
PYTHON_VERSION_MIN=$(echo $PYTHON_VERSION | cut -d. -f1,2)
|
2022-12-01 20:58:32 +03:00
|
|
|
|
|
|
|
python -m venv $PREFIX/libexec
|
|
|
|
|
|
|
|
cd "$PREFIX"
|
|
|
|
|
2022-12-30 19:06:52 +03:00
|
|
|
libexec/bin/pip install -v --no-binary :all: --ignore-installed $CMD_NAME
|
2022-12-01 20:58:32 +03:00
|
|
|
mkdir bin
|
|
|
|
|
2023-01-19 18:16:05 +03:00
|
|
|
cat <<EOF >bin/$CMD_NAME
|
2022-12-01 21:30:51 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
self="\${BASH_SOURCE[0]}"
|
2023-01-19 18:16:05 +03:00
|
|
|
LIBEXEC="\$(cd "\$(dirname "\$self")"/../libexec/bin && pwd)"
|
2022-12-01 21:30:51 +03:00
|
|
|
source "\$LIBEXEC/activate"
|
2023-01-19 18:16:05 +03:00
|
|
|
exec "\$LIBEXEC"/$CMD_NAME "\$@"
|
2022-12-01 21:30:51 +03:00
|
|
|
EOF
|
2023-01-19 18:16:05 +03:00
|
|
|
chmod +x bin/$CMD_NAME
|
|
|
|
|
|
|
|
cd libexec/bin
|
|
|
|
fix-shebangs.ts *
|
2022-12-01 20:58:32 +03:00
|
|
|
|
|
|
|
rm Activate.ps1 activate.csh activate.fish
|
|
|
|
|
|
|
|
sed -i.bak 's|VIRTUAL_ENV=".*"|VIRTUAL_ENV="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. \&\& pwd)"|' activate
|
|
|
|
rm activate.bak
|
|
|
|
|
|
|
|
# FIXME a lot: this "updates" the `venv` on each run for relocatability
|
2022-12-20 15:51:18 +03:00
|
|
|
cat <<EOF >>activate
|
2022-12-01 20:58:32 +03:00
|
|
|
|
|
|
|
sed -i.bak \\
|
|
|
|
-e "s|$TEA_PREFIX/python.org/v$PYTHON_VERSION|\$TEA_PREFIX/python.org/v$PYTHON_VERSION_MAJ|" \\
|
|
|
|
-e 's|bin/python$PYTHON_VERSION_MAJ.$PYTHON_VERSION_MIN|bin/python|' \\
|
2022-12-30 19:06:52 +03:00
|
|
|
-e "s|$PREFIX/libexec|\$TEA_PREFIX/$PROJECT_NAME/$VERSION/libexec|" \\
|
2022-12-01 20:58:32 +03:00
|
|
|
\$VIRTUAL_ENV/pyvenv.cfg
|
|
|
|
rm \$VIRTUAL_ENV/pyvenv.cfg.bak
|
|
|
|
EOF
|
|
|
|
|
|
|
|
for x in python*; do
|
|
|
|
ln -sf ../../../../python.org/v$PYTHON_VERSION_MAJ/bin/$x $x
|
2022-12-20 15:51:18 +03:00
|
|
|
done
|