-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbkpyvenv
More file actions
executable file
·63 lines (51 loc) · 1.28 KB
/
bkpyvenv
File metadata and controls
executable file
·63 lines (51 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env -S pkgx +git +install bash
set -eo pipefail
cd "$SRCROOT"
d="$(cd "$(dirname "$0")"/.. && pwd)"
CMD=$1
shift
if [ $1 = '--engine=poetry' ]; then
ENGINE=poetry
shift
fi
PREFIX=$1
shift
set -x
case $CMD in
stage)
VERSION=$1
if [ ! -d "$SRCROOT/.git" ]; then
GIT_DIR="$SRCROOT/.git"
git init
git config user.name 'pkgx[bot]'
git config user.email 'bot@pkgx.dev'
git commit -mnil --allow-empty
git tag -a "$VERSION" -m "Version $VERSION" --force
unset GIT_DIR
fi
if [ "$ENGINE" = poetry ]; then
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
else
python -m venv "$PREFIX"/venv
fi
;;
seal)
PYTHON=$(python --version | sed -n 's/Python \([0-9]\+\.[0-9]\+\).*/\1/p')
if [ "$ENGINE" = poetry ]; then
# FIXME is there a more efficient way to do this?
# FIXME the glob is unfortunate
poetry build -f sdist
tar xzf \
dist/*.tar.gz \
--directory "$SRCROOT"/.venv/lib/python$PYTHON/site-packages \
--strip-components=1
mkdir -p "$PREFIX"
mv "$SRCROOT"/.venv "$PREFIX/venv"
fi
for cmd in $@; do
install -D "$d/share/brewkit/python-venv-stub.py" $PREFIX/bin/$cmd
sed -i "1s|.*|#!/usr/bin/env -S pkgx python@$PYTHON|" $PREFIX/bin/$cmd
done
;;
esac