2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00

Struggling to use venv pip with WSL2 Ubuntu-20.04

This commit is contained in:
Philip Sargent 2022-03-30 02:17:08 +01:00
parent 7f16bca7f7
commit dddb9b1f57
4 changed files with 23 additions and 10 deletions

View File

@ -49,8 +49,8 @@ Follow the instructions contained in the file to fill out your settings.
Python3, Django, and Database setup Python3, Django, and Database setup
----------------------------------- -----------------------------------
We are now using Django 2.2.19 We are now using Django 2.2.19 and will move to 3.2 shortly
We are installing with python3.7 We are installing with python3.9
Install Django using pip, not with apt, on your test system. Install Django using pip, not with apt, on your test system.
Conventionally on our main master expo server we install everything that we can as debian packages, not using pip. Conventionally on our main master expo server we install everything that we can as debian packages, not using pip.

View File

@ -1,7 +1,7 @@
asgiref==3.3.4 asgiref==3.3.4
confusable-homoglyphs==3.2.0 confusable-homoglyphs==3.2.0
coverage==5.5 coverage==5.5
Django==3.2.12 Django==3.2
docutils==0.14 docutils==0.14
gunicorn==20.1.0 gunicorn==20.1.0
Pillow==9.0.1 Pillow==9.0.1

View File

@ -4,32 +4,44 @@ echo 'Run this in a terminal in the troggle directory: "bash venv-trog.sh"'
# Expects an Ubuntu 20.04 relatively clean install. # Expects an Ubuntu 20.04 relatively clean install.
# Running using SQLite 3.31.1 2020-01-27 19:55:54 # Running using SQLite 3.31.1 2020-01-27 19:55:54
# Many permissions conflicts under WSL2 mean more sudo needed
# If you have not already installed these on your clean Ubuntu install DO THIS FIRST # If you have not already installed these on your clean Ubuntu install DO THIS FIRST
# /usr/bin/python : ensure python is an alias for python3 not python2.7 # /usr/bin/python --version : ensure python is an alias for python3 not python2.7
# sudo apt install sqlite3 # sudo apt install sqlite3
# sudo apt install python3-pip # sudo apt install python3-pip # this installs a shed-load of other stuff: binutils etc.
# sudo apt install python3.9 # sudo apt install python3.9
# sudo apt install python3.9-venv
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
# on WSL there is an oddity that creating a venv trips over a PowerShell permissions issue
# and of course:
# sudo apt update
# sudo apt dist-upgrade
# On a clean debian 11 (bullseye) installation with Xfce & ssh, # On a clean debian 11 (bullseye) installation with Xfce & ssh,
# as debian does not install everything that ubuntu does, you need: # as debian does not install everything that ubuntu does, you need:
# sudo usermod -a -G sudo expo # to put expo in sudoers group, re-login required # sudo usermod -a -G sudo expo # to put expo in sudoers group, re-login required
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 # sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
# sudo apt install python3-pip # sudo apt install python3-pip
# sudo apt piinstall python3-venv # sudo apt install python3-venv
# copy this file and requirements.txt into the directory above where you want to install the VENV # copy this file and requirements.txt into the directory above where you want to install the VENV
VENAME=d4 # python3.9 and django 4 VENAME=dj32 # python3.9 and django 3.2
if [ -d requirements.txt ]; then if [ -d requirements.txt ]; then
echo "No requirements.txt found. Copy it from your most recent installation." echo "No requirements.txt found. Copy it from your most recent installation."
exit 1 exit 1
fi fi
python --version
# LOOK HERE: we go up a level so that /$VENAME is parallel to /troggle
cd .. cd ..
if [ ! -d $VENAME ]; then if [ ! -d $VENAME ]; then
echo "### Creating venv $VENAME" echo "### Creating venv $VENAME"
python3.9 -m venv $VENAME sudo python -m venv $VENAME
else else
echo "/$VENAME/ already exists ! Delete it first." echo "/$VENAME/ already exists ! Delete it first."
exit 1 exit 1
@ -39,8 +51,10 @@ fi
echo "### Activating $VENAME" echo "### Activating $VENAME"
cd $VENAME cd $VENAME
source bin/activate source bin/activate
echo "### Activated."
# update local version of pip, more recent than OS version # update local version of pip, more recent than OS version
# debian bullseye installs pip 20.3.4 which barfs, we want >22.0.3 # debian bullseye installs pip 20.3.4 which barfs, we want >22.0.3
echo "### installing later version of pip inside $VENAME"
python -m pip install --upgrade pip python -m pip install --upgrade pip
PIP=pip PIP=pip
@ -52,8 +66,7 @@ ln -s ../expoweb expoweb
ln -s ../troggle troggle ln -s ../troggle troggle
ln -s ../loser loser ln -s ../loser loser
ln -s ../drawings drawings ln -s ../drawings drawings
ln -s /mnt/f/expofiles expofiles ln -s ../expofiles expofiles
ln -s ../expowebcache expowebcache
# Package Version # Package Version
# ------------- ---------- # ------------- ----------