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

fixes for WSL1 on new machine

This commit is contained in:
Philip Sargent 2022-10-27 16:29:11 +01:00
parent 275ce87e30
commit 73e57a19df
7 changed files with 86 additions and 32 deletions

View File

@ -1,6 +1,4 @@
/home/philip/p10d3/lib/python3.10/site-packages/django/utils/version.py:6: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives /home/philip/zp310d3/lib/python3.10/site-packages/django/utils/asyncio.py:19: DeprecationWarning: There is no current event loop
from distutils.version import LooseVersion
/home/philip/p10d3/lib/python3.10/site-packages/django/utils/asyncio.py:19: DeprecationWarning: There is no current event loop
event_loop = asyncio.get_event_loop() event_loop = asyncio.get_event_loop()
/home/philip/p10d3/lib/python3.10/site-packages/django/utils/asyncio.py:19: DeprecationWarning: There is no current event loop /home/philip/zp310d3/lib/python3.10/site-packages/django/utils/asyncio.py:19: DeprecationWarning: There is no current event loop
event_loop = asyncio.get_event_loop() event_loop = asyncio.get_event_loop()

View File

@ -4,6 +4,8 @@
#Make sure you have the WSL permissions system working, or you will push unsanitized files as this will fail #Make sure you have the WSL permissions system working, or you will push unsanitized files as this will fail
# Philip Sargent 2022/04/12 # Philip Sargent 2022/04/12
echo "** This copies file to _deploy/wsl/ !"
echo
echo deprecations. echo deprecations.
python -Wall manage.py check -v 3 2>deprecations.txt >/dev/null python -Wall manage.py check -v 3 2>deprecations.txt >/dev/null
echo diffsettings. echo diffsettings.

View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Do these before final testing, *not* just before pushing: # Do these before final testing, *not* just before pushing:
# Philip Sargent 2020/06/20 # Philip Sargent 2020/06/20
echo Run inspectdb: echo "** Run inspectdb:"
python3 manage.py inspectdb > troggle-inspectdb.py python3 manage.py inspectdb > troggle-inspectdb.py
# egrep -in "unable|error" troggle-inspectdb.py # egrep -in "unable|error" troggle-inspectdb.py
echo "" echo ""
@ -14,14 +14,19 @@ find . -name \*.py -print0 | xargs -0 egrep -vc "#|^\s*$" | grep -v ":0$" | gr
# This deletes the database so must run after generating troggle-inspectdb.py # This deletes the database so must run after generating troggle-inspectdb.py
python3 reset-django.py python3 reset-django.py
echo After cleanup deletion, remake all migrations. echo "** After cleanup deletion, remake all migrations."
python3 manage.py makemigrations >/dev/null python3 manage.py makemigrations >/dev/null
python3 manage.py migrate python3 manage.py migrate
python3 manage.py test
echo "** Now running self check"
python3 manage.py check -v 3 --deploy 2>security-warnings.txt >/dev/null python3 manage.py check -v 3 --deploy 2>security-warnings.txt >/dev/null
python3 manage.py check -v 3 --deploy python3 manage.py check -v 3 --deploy
echo "** Now running test suite"
python3 manage.py test
echo "" echo ""
echo `tail -1 lines-of-python.txt` non-comment lines of python. echo `tail -1 lines-of-python.txt` non-comment lines of python.
echo `tail -1 lines-of-templates.txt` non-comment lines of HTML templates. echo `tail -1 lines-of-templates.txt` non-comment lines of HTML templates.
echo 'If you have an error running manage.py, maybe you are not in an activated venv ?' echo '** If you have an error running manage.py, maybe you are not in an activated venv ?'

View File

@ -1,16 +1,15 @@
asgiref==3.5.0 asgiref==3.5.2
confusable-homoglyphs==3.2.0 confusable-homoglyphs==3.2.0
coverage==6.4 coverage==6.4
Django==3.2 Django==3.2
docutils==0.18 docutils==0.18
gunicorn==20.1.0
mariadb==1.0.11 mariadb==1.0.11
mysql-connector-python==8.0.29 mysql-connector-python==8.0.29
mysqlclient==2.1.0 mysqlclient==2.1.0
Pillow==9.1.0 Pillow==9.2.0
protobuf==4.21.2 protobuf==4.21.2
pytz==2022.1 pytz==2022.5
reportlab==3.6.0 reportlab==3.6.0
sqlparse==0.4.0 sqlparse==0.4.0
typing_extensions==4.2.0 typing_extensions==4.2.0
Unidecode==1.3.0 Unidecode==1.3.6

View File

@ -4,7 +4,14 @@ Django==3.2
docutils==0.14 docutils==0.14
gunicorn==20.1.0 gunicorn==20.1.0
Pillow==5.4.1 Pillow==5.4.1
pytz==2019.1
sqlparse==0.2.4 sqlparse==0.2.4
typing-extensions==3.7.4.3 typing-extensions==3.7.4.3
Unidecode==1.0.23 Unidecode==1.0.23
mariadb==1.0.11
mysql-connector-python==8.0.29
mysqlclient==2.1.0
Pillow==9.1.0
pytz==2022.5
asgiref==3.5.0
gunicorn==20.1.0

View File

@ -2,8 +2,9 @@ System check identified some issues:
WARNINGS: WARNINGS:
?: (security.W001) You do not have 'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SECURE_REFERRER_POLICY, and SECURE_SSL_REDIRECT settings will have no effect. ?: (security.W001) You do not have 'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SECURE_REFERRER_POLICY, and SECURE_SSL_REDIRECT settings will have no effect.
?: (security.W009) Your SECRET_KEY has less than 50 characters, less than 5 unique characters, or it's prefixed with 'django-insecure-' indicating that it was generated automatically by Django. Please generate a long and random SECRET_KEY, otherwise many of Django's security-critical features will be vulnerable to attack.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions. ?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token. ?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token.
?: (security.W018) You should not have DEBUG set to True in deployment. ?: (security.W018) You should not have DEBUG set to True in deployment.
System check identified 4 issues (0 silenced). System check identified 5 issues (0 silenced).

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# footled lots to make this work with python 3.10 and WSL1 on Ubuntu 22.04
# Run this in a terminal in the troggle directory: 'bash venv-trog.sh' # Run this in a terminal in the troggle directory: 'bash venv-trog.sh'
echo 'Run this in a terminal in the troggle directory: "bash venv-trog.sh"' echo '-- Run this in a terminal in the troggle directory: "bash venv-trog.sh"'
# Expects an Ubuntu 22.04 relatively clean install. # Expects an Ubuntu 22.04 relatively clean install.
# Running using SQLite version 3.37.2 2022-01-06 13:25:41 # Running using SQLite version 3.37.2 2022-01-06 13:25:41
@ -8,6 +9,7 @@ echo 'Run this in a terminal in the troggle directory: "bash venv-trog.sh"'
# 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
# use the script os-trog.sh # use the script os-trog.sh
# which does the following:
# python --version : ensure python is an alias for python3 not python2.7 # python --version : ensure python is an alias for python3 not python2.7
# sudo apt install sqlite3 # sudo apt install sqlite3
@ -31,55 +33,93 @@ echo 'Run this in a terminal in the troggle directory: "bash venv-trog.sh"'
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 # sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
# #
# NOW we set up troggle
# 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=p10d3 # python3.10 and django 3.2 VENAME=zp310d3 # python3.10 and django 3.2
echo "-- Script executed from: ${PWD}"
TROGDIR=$(cd $(dirname $0) && pwd)
sudo echo "-- Troggle folder (this script location): ${TROGDIR}"
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 python --version
# NOW set up link from expo user folder
# needed for WSL2
echo Creating links from Linux filesystem user
# These links only need making once, for many venv
cd ~
# cd ..
# mkdir expo
# cd expo
# ln -s ${TROGDIR}../$VENAME $VENAME
if [ -d troggle ]; then
echo "-- No /troggle/ found. Creating links."
ln -s ${TROGDIR} troggle
ln -s ${TROGDIR}/../expoweb expoweb
ln -s ${TROGDIR}/../loser loser
ln -s ${TROGDIR}/../drawings drawings
ln -s ${TROGDIR}/../expofiles expofiles
fi
# LOOK HERE: we go up a level so that /$VENAME is parallel to /troggle # 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. (If this fails with a pip error, you need to use a Ubuntu window)"
python -m venv $VENAME python -m venv $VENAME
else else
echo "/$VENAME/ already exists ! Delete it first." echo "## /$VENAME/ already exists ! Delete it first."
exit 1 exit 1
fi fi
# seems to create infinite loop for tests
# echo "-- Make link from EXPO folder to venv $VENAME"
# sudo ln -s $VENAME ${TROGDIR}/../$VENAME
# Activate the virtual env and see what the default packages are # Activate the virtual env and see what the default packages are
echo "### Activating $VENAME" echo "### Activating $VENAME"
cd $VENAME cd $VENAME
echo "-- now in: ${PWD}"
source bin/activate source bin/activate
echo "### Activated." 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
#This fails when using python3.10 (which has installed pip 22.0.2) and is attempting to upgrade to 22.3
# WARNING: No metadata found in ./lib/python3.10/site-packages
# and then the rollback fails to roll back successfully.
echo "### installing later version of pip inside $VENAME" echo "### installing later version of pip inside $VENAME"
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
PIP=pip PIP=pip
$PIP list > original-pip.list $PIP list > original-pip.list
$PIP freeze >original.txt $PIP freeze >original.txt
ln -s ../expoweb expoweb
ln -s ../troggle troggle ln -s ${TROGDIR} troggle
ln -s ../loser loser ln -s ${TROGDIR}/../expoweb expoweb
ln -s ../drawings drawings ln -s ${TROGDIR}/../loser loser
ln -s ../expofiles expofiles ln -s ${TROGDIR}/../drawings drawings
ln -s ${TROGDIR}/../expofiles expofiles
# Package Version # Package Version
# ------------- ---------- # ------------- ----------
echo '### links to expoweb, troggle etc. complete' echo '### links to expoweb, troggle etc. complete'
echo '###' echo '###'
echo '### now installing requirements.txt' echo '### now installing ${TROGDIR}/requirements.txt'
echo '###' echo '###'
$PIP install -r troggle/requirements.txt $PIP install -r ${TROGDIR}/requirements.txt
echo '### install from requirements.txt completed.' echo '### install from requirements.txt completed.'
echo '### ' echo '### '
@ -106,7 +146,7 @@ REQ=installation-record
mkdir $REQ mkdir $REQ
mv requirements-$VENAME.txt $REQ mv requirements-$VENAME.txt $REQ
mv original.txt $REQ mv original.txt $REQ
#mv requirements.txt $REQ mv requirements.txt $REQ
mv original-pip.list $REQ mv original-pip.list $REQ
mv installed-pip.list $REQ mv installed-pip.list $REQ
mv installed-pip-o.list $REQ mv installed-pip-o.list $REQ
@ -114,15 +154,17 @@ cp fresh-requirements.txt ../requirements.txt
mv fresh-requirements.txt $REQ mv fresh-requirements.txt $REQ
cp troggle/`basename "$0"` $REQ cp troggle/`basename "$0"` $REQ
python --version python --version
echo "Django version:" echo "Django version:`django-admin --version`"
django-admin --version
echo "### Now do echo "### Now do
'sudo service mysql start' 'sudo service mysql start'
'sudo service mariadb restart' 'sudo service mariadb restart'
'sudo mysql_secure_installation' 'sudo mysql_secure_installation'
'cd ../$VENAME' 'cd ~/$VENAME'
'source bin/activate' 'source bin/activate'
'cd troggle' 'cd troggle'
'python manage.py check' 'python manage.py check'
'./pre-run.sh'
'python manage.py test -v 3' " 'python manage.py test -v 3' "