Skip to content

Commit 895c9da

Browse files
committed
Fixes not installing the python sources we dl
Also restores putting the venv in PREFIX/venv Doesn’t delete anything the venv creates since pipenv seems to want to run its own activate in some context or another.
1 parent cf5df18 commit 895c9da

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

share/brewkit/python-venv.sh

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
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-
109
set -ex
1110

1211
CMD_NAME=$(basename "$1")
@@ -15,42 +14,46 @@ VERSION="$(basename "$PREFIX")"
1514
PYTHON_VERSION=$(python --version | cut -d' ' -f2)
1615
PYTHON_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
4242
cat <<EOSH > \$VIRTUAL_ENV/pyvenv.cfg
4343
home = \$TEA_PREFIX/python.org/v$PYTHON_VERSION_MAJ/bin
4444
include-system-site-packages = false
4545
executable = \$TEA_PREFIX/python.org/v$PYTHON_VERSION_MAJ/bin/python
4646
EOSH
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
5053
ln -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
5457
EOF
5558

56-
chmod +x "$CMD_NAME"
59+
chmod +x ../bin/"$CMD_NAME"

0 commit comments

Comments
 (0)