mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 11:28:23 +00:00
upgrading scripts to use uv
This commit is contained in:
108
venv-trog.sh
108
venv-trog.sh
@@ -1,19 +1,17 @@
|
||||
#!/bin/bash
|
||||
# footled lots to make this work with python 3.10 & 3.11 and WSL1 and WSL2 on Ubuntu 22.04
|
||||
# now using uv, unbelieveably simpler.
|
||||
# Run this in a terminal in the troggle directory: 'bash venv-trog.sh'
|
||||
echo '-- Run this in a terminal in the directory above the troggle directory: "bash troggle/venv-trog.sh"'
|
||||
|
||||
# Expects an Ubuntu 22.04 with all the gubbins already installed
|
||||
# If you have not already installed these on your clean Ubuntu install DO THIS FIRST
|
||||
# use the script os-trog24.04.sh
|
||||
# use the script os-trog24.04.sh runniing it in /home/username/
|
||||
python --version
|
||||
|
||||
echo "-- EXPO folder [current directory]: `pwd`"
|
||||
|
||||
TROGDIR=$(cd $(dirname $0) && pwd)
|
||||
echo "-- Troggle folder [this script location]: ${TROGDIR}"
|
||||
|
||||
|
||||
cp troggle/pyproject.toml .
|
||||
|
||||
uv self update
|
||||
@@ -24,31 +22,11 @@ exit 1
|
||||
# this next is a bit wordy
|
||||
# uv python list --only-installed
|
||||
|
||||
# NOW we set up troggle
|
||||
PYTHONSVR=python3.11
|
||||
PYTHONDEV=python3.13
|
||||
|
||||
VSVR=svr # python3.11 and django 3.2
|
||||
VDEV=dev # python3.13 and django 5
|
||||
#echo "The 50MB pip cache will be in /home/`id -u -n`/.cache/"
|
||||
# echo "-- venvs will created in /home/`id -u -n`/expo/$VSVR/ " "and /home/`id -u -n`/expo/$VDEV/"
|
||||
|
||||
# This will install uv copies in .local as well as creating venv
|
||||
#uv venv $VSVR --python 3.11
|
||||
uv venv $VDEV --python 3.13
|
||||
# uv python list --only-installed
|
||||
|
||||
|
||||
exit 1
|
||||
|
||||
|
||||
|
||||
|
||||
# we are in /home/$USER/$VSVR/
|
||||
ln -s ${TROGDIR} troggle
|
||||
ln -s ${TROGDIR}/../expoweb expoweb
|
||||
ln -s ${TROGDIR}/../loser loser
|
||||
ln -s ${TROGDIR}/../drawings drawings
|
||||
# we are in /home/$USER/expo/
|
||||
# ln -s ${TROGDIR} troggle
|
||||
# ln -s ${TROGDIR}/../expoweb expoweb
|
||||
# ln -s ${TROGDIR}/../loser loser
|
||||
# ln -s ${TROGDIR}/../drawings drawings
|
||||
#ln -s ${TROGDIR}/../expofiles expofiles
|
||||
|
||||
# fudge for philip's laptop prior to M2 SSD upgrade
|
||||
@@ -63,88 +41,34 @@ else
|
||||
ln -s /mnt/d/EXPO/expofiles expofiles
|
||||
fi
|
||||
|
||||
echo "### Setting file permissions.. may take a while.."
|
||||
git config --global --add safe.directory '*'
|
||||
sudo chmod -R 777 *
|
||||
|
||||
echo "### links to expoweb, troggle etc. complete:"
|
||||
ls -tla
|
||||
echo "###"
|
||||
echo "### now installing ${TROGDIR}/${REQUIRE}"
|
||||
echo "###"
|
||||
cat ${TROGDIR}/${REQUIRE}
|
||||
|
||||
# NOW THERE IS A PERMISSIONS FAILURE THAT DIDN'T HAPPEN BEFORE
|
||||
# seen on wsl2 as well as wsl1
|
||||
# which ALSO ruins EXISTING permissions !
|
||||
# Guessing it is to do with pip not liking non-standard py 3.11 installation on Ubuntu 22.04
|
||||
|
||||
read -p "Press any key to resume ..."
|
||||
$PIP install -r ${TROGDIR}/${REQUIRE}
|
||||
echo "### install from ${TROGDIR}/${REQUIRE} completed."
|
||||
echo '### '
|
||||
PIP="uv pip"
|
||||
|
||||
$PIP install --pre django
|
||||
|
||||
REQUIRE="requirements.txt"
|
||||
$PIP freeze > $REQUIRE
|
||||
# so that we can track requirements more easily with git
|
||||
# because we do not install these with pip, but they are listed by the freeze command
|
||||
# Now find out what we actually installed by subtracting the stuff venv installed anyway
|
||||
sort original.txt > 1
|
||||
sort $REQUIRE >2
|
||||
comm -3 1 2 --check-order | awk '{ print $1}'>fresh-$REQUIRE
|
||||
rm 1
|
||||
rm 2
|
||||
$PIP list
|
||||
|
||||
# cp $REQUIRE requirements-$VSVR.txt
|
||||
cp $REQUIRE troggle/$REQUIRE
|
||||
|
||||
$PIP list > installed-pip.list
|
||||
$PIP list -o > installed-pip-o.list
|
||||
|
||||
REQ=installation-record
|
||||
mkdir $REQ
|
||||
|
||||
mv original.txt $REQ
|
||||
mv $REQUIRE $REQ
|
||||
mv original-pip.list $REQ
|
||||
mv installed-pip.list $REQ
|
||||
mv installed-pip-o.list $REQ
|
||||
cp fresh-$REQUIRE ../$REQUIRE
|
||||
mv fresh-$REQUIRE $REQ
|
||||
cp troggle/`basename "$0"` $REQ
|
||||
|
||||
|
||||
$PYTHON --version
|
||||
python --version
|
||||
echo "Django version:`django-admin --version`"
|
||||
echo "Django version:`uv run django-admin --version`"
|
||||
|
||||
echo "### Now do
|
||||
'[sudo service mysql start]'
|
||||
'[sudo service mariadb restart]'
|
||||
'[sudo mysql_secure_installation]'
|
||||
'cd ~/$VSVR'
|
||||
'source bin/activate'
|
||||
'cd troggle'
|
||||
'django-admin'
|
||||
'python manage.py check'
|
||||
'uv run django-admin'
|
||||
'uv run manage.py check'
|
||||
## this tests if you have set up ssh correcting. Refer to documentation https://expo.survex.com/handbook/computing/keyexchange.html
|
||||
## you need to follow the Linux instructions.
|
||||
'ssh expo@expo.survex.com'
|
||||
|
||||
## the next tests will fail unless ~/expofiles is set correctly to a folder on your machine
|
||||
## the tests may ALSO fail because of ssh and permissions errors
|
||||
|
||||
## So you will need to run
|
||||
$sudo chown -Rhv philip:philip ~/$VSVR (if your username is philip)
|
||||
# and then REBOOT (or at least, exit WSL and terminate and restart WSL)
|
||||
# because this chmod only takes effect then.
|
||||
|
||||
'python manage.py test -v 2'
|
||||
'uv run manage.py test -v 2'
|
||||
'./pre-run.sh' (runs the tests again)
|
||||
|
||||
'python databaseReset.py reset $VSVR'
|
||||
'python manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)'
|
||||
'uv run databaseReset.py reset INIT'
|
||||
'uv run manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)'
|
||||
"
|
||||
# if [ ! -d /mnt/d/expofiles ]; then
|
||||
# echo '### No valid expofiles directory on /mnt/d . Fix this before any tests will work.'
|
||||
|
||||
Reference in New Issue
Block a user