1- #! /bin/sh
1+ #! /usr/ bin/env -S tea sh
22
33# ---
44# dependencies:
5- # gnu.org/coreutils: '*'
5+ # git-scm.org: ^2
6+ # # ^^ required to set version tag used by setup tools
67# ---
78
8- # TODO no need to make a sub-dir, just make what we got the v-env
9-
109set -ex
1110
1211CMD_NAME=$( basename " $1 " )
@@ -15,42 +14,46 @@ VERSION="$(basename "$PREFIX")"
1514PYTHON_VERSION=$( python --version | cut -d' ' -f2)
1615PYTHON_VERSION_MAJ=$( echo " $PYTHON_VERSION " | cut -d. -f1)
1716
18- python -m venv " $PREFIX "
19-
20- cd " $PREFIX " /bin
17+ export VIRTUAL_ENV=" $PREFIX " /venv
2118
22- ./pip install " $CMD_NAME == $VERSION "
19+ python -m venv " $VIRTUAL_ENV "
2320
24- for x in * ; do
25- if test " $x " ! = " $CMD_NAME " -a " $x " ! = python ; then
26- rm " $x "
27- fi
28- done
21+ # setup tools requires a git version typically
22+ cd " $SRCROOT "
23+ git init
24+ git commit -mnil --allow-empty
25+ git tag -a " $VERSION " -m " Version $VERSION "
2926
30- mkdir ../libexec
31- mv " $CMD_NAME " ../libexec/ " $CMD_NAME "
27+ cd " $VIRTUAL_ENV "
28+ bin/pip install " $SRCROOT " --verbose
3229
3330# python virtual-envs are not relocatable
3431# our only working choice is to rewrite these files and symlinks every time
3532# because we promise that tea is relocatable *at any time*
3633
37- cat << EOF > "$CMD_NAME "
34+ mkdir -p ../bin
35+
36+ # FIXME requiring sed is a bit lame
37+ cat << EOF > ../bin/"$CMD_NAME "
3838#!/bin/sh
3939
40- export VIRTUAL_ENV="\$ (cd "\$ (dirname "\$ 0")"/.. && pwd)"
40+ export VIRTUAL_ENV="\$ (cd "\$ (dirname "\$ 0")"/.. && pwd)/venv "
4141
4242cat <<EOSH > \$ VIRTUAL_ENV/pyvenv.cfg
4343home = \$ TEA_PREFIX/python.org/v$PYTHON_VERSION_MAJ /bin
4444include-system-site-packages = false
4545executable = \$ TEA_PREFIX/python.org/v$PYTHON_VERSION_MAJ /bin/python
4646EOSH
4747
48- sed -i.bak "1s|.*|#!\$ VIRTUAL_ENV/bin/python|" "\$ VIRTUAL_ENV"/libexec/$CMD_NAME
48+ find "\$ VIRTUAL_ENV"/bin -depth 1 -type f | xargs \
49+ sed -i.bak "1s|.*|#!\$ VIRTUAL_ENV/bin/python|"
50+
51+ rm "\$ VIRTUAL_ENV"/bin/*.bak
4952
5053ln -sf "\$ TEA_PREFIX"/python.org/v$PYTHON_VERSION_MAJ /bin/python "\$ VIRTUAL_ENV"/bin/python
5154
52- exec "\$ VIRTUAL_ENV"/libexec /$CMD_NAME "\$ @"
55+ exec "\$ VIRTUAL_ENV"/bin /$CMD_NAME "\$ @"
5356
5457EOF
5558
56- chmod +x " $CMD_NAME "
59+ chmod +x ../bin/ " $CMD_NAME "
0 commit comments