mirror of
https://github.com/ivabus/pantry
synced 2024-11-26 18:25:08 +03:00
Merge pull request #54 from magnusviri/python-venv
add scripts/brewkit/python-venv.sh
This commit is contained in:
commit
1a575b3d2e
3 changed files with 60 additions and 47 deletions
|
@ -11,43 +11,8 @@ dependencies:
|
|||
|
||||
build:
|
||||
script: |
|
||||
python -m venv {{prefix}}/libexec
|
||||
python-venv.sh meson mesonbuild.com {{version}} {{prefix}} {{deps.python.org.version}} {{deps.python.org.version.major}} {{deps.python.org.version.minor}}
|
||||
|
||||
cd "{{prefix}}"
|
||||
|
||||
libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed meson
|
||||
mkdir bin
|
||||
|
||||
mv libexec/bin/meson libexec/bin/meson.py
|
||||
|
||||
cd bin
|
||||
ln -s ../libexec/bin/meson meson
|
||||
|
||||
cd ../libexec/bin
|
||||
fix-shebangs.ts *
|
||||
|
||||
cp "$SRCROOT"/props/shim.bash meson
|
||||
chmod +x meson
|
||||
|
||||
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
|
||||
cat <<EOF>>activate
|
||||
|
||||
sed -i.bak \\
|
||||
-e "s|$TEA_PREFIX/python.org/v{{deps.python.org.version}}|\$TEA_PREFIX/python.org/v{{deps.python.org.version.major}}|" \\
|
||||
-e 's|bin/python{{deps.python.org.version.major}}.{{deps.python.org.version.minor}}|bin/python|' \\
|
||||
-e "s|{{prefix}}/libexec|\$TEA_PREFIX/mesonbuild.com/v{{version}}/libexec|" \\
|
||||
\$VIRTUAL_ENV/pyvenv.cfg
|
||||
rm \$VIRTUAL_ENV/pyvenv.cfg.bak
|
||||
EOF
|
||||
|
||||
for x in python*; do
|
||||
ln -sf ../../../../python.org/v{{ deps.python.org.version.major }}/bin/$x $x
|
||||
done
|
||||
test:
|
||||
dependencies:
|
||||
ninja-build.org: 1
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
self="${BASH_SOURCE[0]}"
|
||||
if test -L "$self"; then
|
||||
prefix="$(dirname "$self")"
|
||||
suffix="$(dirname $(readlink $self))"
|
||||
LIBEXEC="$(cd $prefix/$suffix && pwd)"
|
||||
else
|
||||
LIBEXEC="$(cd "$(dirname "$self")" && pwd)"
|
||||
fi
|
||||
source "$LIBEXEC/activate"
|
||||
exec "$LIBEXEC"/meson.py "$@"
|
59
scripts/brewkit/python-venv.sh
Executable file
59
scripts/brewkit/python-venv.sh
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
|
||||
CMD_NAME=$1
|
||||
PROJECT_NAME=$2
|
||||
VERSION=$3
|
||||
PREFIX=$4
|
||||
PYTHON_VERSION=$5
|
||||
PYTHON_VERSION_MAJ=$6
|
||||
PYTHON_VERSION_MIN=$7
|
||||
|
||||
python -m venv $PREFIX/libexec
|
||||
|
||||
cd "$PREFIX"
|
||||
|
||||
libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed $CMD_NAME
|
||||
mkdir bin
|
||||
|
||||
mv libexec/bin/$CMD_NAME libexec/bin/$CMD_NAME.py
|
||||
|
||||
cd bin
|
||||
ln -s ../libexec/bin/$CMD_NAME $CMD_NAME
|
||||
|
||||
cd ../libexec/bin
|
||||
fix-shebangs.ts *
|
||||
|
||||
cat <<EOF>$CMD_NAME
|
||||
#!/usr/bin/env bash
|
||||
self="\${BASH_SOURCE[0]}"
|
||||
if test -L "\$self"; then
|
||||
prefix="\$(dirname "\$self")"
|
||||
suffix="\$(dirname \$(readlink \$self))"
|
||||
LIBEXEC="\$(cd \$prefix/\$suffix && pwd)"
|
||||
else
|
||||
LIBEXEC="\$(cd "\$(dirname "\$self")" && pwd)"
|
||||
fi
|
||||
source "\$LIBEXEC/activate"
|
||||
exec "\$LIBEXEC"/$CMD_NAME.py "\$@"
|
||||
EOF
|
||||
chmod +x $CMD_NAME
|
||||
|
||||
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
|
||||
cat <<EOF>>activate
|
||||
|
||||
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|' \\
|
||||
-e "s|$PREFIX/libexec|\$TEA_PREFIX/$PROJECT_NAME/v$VERSION/libexec|" \\
|
||||
\$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
|
||||
done
|
Loading…
Reference in a new issue