diff --git a/handbook/troggle/troglaptop.html b/handbook/troggle/troglaptop.html index f4a71c371..9b57c312f 100644 --- a/handbook/troggle/troglaptop.html +++ b/handbook/troggle/troglaptop.html @@ -88,70 +88,41 @@ File permissions are a big issue. provisioning so that systems are rebuilt cleanly. CUYC (who also use Django) have a bash script which sets up a new django development system. We should copy that in the first instance. Alas, we haven't got around to doing any of this yet. -
On a new machine you need to configure your git identity: -
git config --global user.email "you@example.com"
-git config --global user.name "Your Name"
-git config --global pull.rebase true
-
-
-We use pull.rebase as this seems to work best with our repos and the way we work. - -
Python is not installed by default on Debian, and in any case we need specific versions to be installed. For Ubuntu 20.04 the - default installation is python3.9 whereas Ubuntu 22.04 gives you python3.10 (but it may not if using WSL, depending on your history. See the Expo WSL page for more). -
If you are planning on eventually helping the migration of troggle from debian Bullseye (v11) to -Bookworm (v12) to then you will also want the appropriate later versions of python e.g. 3.10 on Ubuntu 20.04 like this: +
sudo apt install python3 python3-pip -y
sudo apt install sqlite3 sqlite3-doc -y
sudo apt install survex -y
-sudo apt install software-properties-common -y
sudo apt install git gitk -y
+
+Martin Green is not sure why, but historically we may have also installed:
+
+sudo apt install software-properties-common -y
sudo apt install default-jdk -y
sudo apt install binutils binfmt-support -y
+
-#sudo add-apt-repository ppa:deadsnakes/ppa
-#sudo apt install python3.10 python3.10-venv python3.10-doc
-#sudo apt --fix-broken install
+You need this so that you can upload your edited code to the git repo on the server. +
Follow this link to register a key with the expo server to get git access if you have +not already cloned the :troggle: repo. -cd /usr/bin -sudo ln -s python3 python -sudo ln -s pip3 pip +
On a new machine you need to configure your git identity: +
git config --global user.email "you@example.com"
+git config --global user.name "Your Name"
+git config --global pull.rebase true
+
-You will also definitely need sqlite3 even if you are planning to use another -database. Sqlite3 is used by the test harness system. -
Note that when you install survex it installs a shed load of packages that it needs. -
We do not install Django at this point. We will be installing Django in a separate virtual -environment (a 'venv'), not in the main linux system. - -
Buggeration #1: The sudo add-apt-repository ppa:deadsnakes/ppa line won't work after Debian 11 or Ubuntu 22.04. So this handbook page will need to be changed to use the new method. And this way of installing python3.10 is fine on Ubuntu but not on Debian, where you are stuck with 3.9 on Debian 11 (Bullseye). -
Buggeration #2: In Ubuntu 23.04 you can’t run pip install outside a virtual environment. SO use venv, see Pip Install Error (but not, don't use pipx unless you have used it before). - -
In case you have python version problems with venv, look at the instructions for python3.11 on WSL2. -
Note that default-jre is Java which is used by tunnel and gpsprune. - -
We need to have the folder structure that troggle expects. On your own machine -you will have your own logon id, and you do not need to create an 'expo' user, but -you do need to create folders where an 'expo' user would have them. Make links there -to wherever you have actually installed the repos. So if you have installed all your repos -in /mnt/c/EXPO/, then you would need to do this: -
cd ~
-cd ..
-sudo mkdir expo
-cd expo
-sudo ln -s /mnt/c/EXPO/expoweb expoweb
-sudo ln -s /mnt/c/EXPO/troggle troggle
-sudo ln -s /mnt/c/EXPO/loser loser
-sudo ln -s /mnt/c/EXPO/drawings drawings
-sudo ln -s /mnt/c/EXPO/expofiles expofiles
-sudo ln -s /mnt/c/EXPO/expowebcache expowebcache
-sudo mkdir expowebcache/3d
-cd ..
-ls -tlA expo
+cd ~/expo
+git clone ssh://expo@expo.survex.com/home/expo/troggle
+git clone ssh://expo@expo.survex.com/home/expo/loser
+git clone ssh://expo@expo.survex.com/home/expo/expoweb
+git clone ssh://expo@expo.survex.com/home/expo/drawings
+
If you do not have a local copy of the 40GB /expofiles/, don't worry. Later on we can set 'EXPOFILESREMOTE = True' in the @@ -165,103 +136,39 @@ confusing and apparently inconsistent behaviour: e.g. you will upload a file but
You can, if you like, have the expo photo archive collection somewhere else, not inside expofiles, on a troggle development machine. To do this set the PHOTOS_ROOT appropriately in troggle/localsettings.py. By default it is PHOTOS_ROOT = EXPOFILES / 'photos'. This is handy if you want everything else in expofiles in your Linux home drive for speed, but don't care about speed for the 29GB of photos which can sit on an SDdrive. -
The important point to note - here is that unless you are doing something fairly trivial, or you are a git genius, - it is sensible to set up a python virtual environments to hold duplicate copies of both troggle and Django code. - Then you will be able to check very quickly that your edited version of troggle runs with old, current - and pre-release versions of python and of Django; - and you will more easily be able to manage problems with incompatible versions of Django plugins as installing and upgrading the dependent packages is very fast. - + + +
We do not install Django at this point. We will be installing Django in a separate virtual +environment (a 'venv'), not in the main linux system. + + + +
We set up a venv specifically for python 3.9 (which is the standard version on our server which is running unmodified -Bullseye (debian v11) and Django 3.2.12. See the standard python documentation on venv for python 3.9.10. -Create a new venv for each version of python you are using. Get that venv installed right by explicitly stating the -python version to create it python3.9 -m venv py39d32. Note that we are creating it as a sibling folder to /expoweb/ . -Note also that up to now we have been using 'sudo ..' but for installing things inside the venv we do not use 'sudo ..': -
cd ~
-cd ../expo
-python3.9 -m venv py39d32
-cd py39d32
-source bin/activate
-pip list -o
-The last command lists the default packages installed in the venv. This is for comparison later, after we -have installed troggle, Django and dependencies. You will get a warning that you have an out of date version of pipbut this is as we want: we are using a version of pip appropriate for the older version of python within -the venv. - +
In over to avoid compatability issues when deploying our code, we should develop using the same libraries that will be used in prduction of expo.survex.com. Expo.survex.com currently uses python3.9.2, python 3.x is backwardly compatable as long as you do not use any new fuctions it should be fine. Venv allows us to specify which python libraries to use.
-The first time you do this on a new machine you can't complete the pip installation of Django as you have not yet got the -dependencies appropriate for troggle - because you have not yet cloned the troggle repo. So the first time it is easiest to just create requirements.txt yourself with a text editor. Without using git yourself, you can get the file from the website at requirements.txt. If you have already cloned all the repos, then just copy it. -
cp ../troggle/requirements.txt .
-where requirements.txt (note the capitalisation of the listed packages) is:
-asgiref==3.3.4
-confusable-homoglyphs==3.2.0
-coverage==5.5
-Django==3.2
-docutils==0.14
-gunicorn==20.1.0
-pytz==2019.1
-sqlparse==0.2.4
-typing-extensions==3.7.4.3
-Unidecode==1.0.23
-This will pick up the latest Django 3.2.x available, but all the other dependencies are pinned. These
-dependencies are as-standard on debian Buster (10) and you will want to experiment with upgrading them
-for Bullseye (v11).
-Once you have the file, install the listed dependencies like this: -
pip install -r requirements.txt
-pip list -o
+Create and activate the virtual enviroment:
+
+cd ~/expo
+python3 -m venv venvexpo
+source venvexpo/bin/activate
+
+
+Install the python libraries
+
+pip install -r requirements.txt
-Pillow (not currently in that package list) is an image handling package used to make
-the prospecting map (currently disabled,
-see /prospecting_guide/).
-tinymce is the wysiwyg in-browser
-editor (disabled pending reinstatement)
-
-
This is also documented in the updating Django for troggle page -where it describes upgrading and testing with later versions of Django. - -
If you have not used pip before, read this +
In case you have python version problems with venv, look at the instructions for python3.11 on WSL2. -
The :troggle: repo is the python source code for troggle. This is what you will be editing. There are over 9,000 lines -of python code (excluding comments and blank lines) and nearly 3,000 lines of HTML/Django template code. This is over 600 files in -over 400 folders, but only 49MB in size (plus a .git repo of 32MB). - -
You need this so that you can upload your edited code to the git repo on the server. -
Follow this link to register a key with the expo server to get git access if you have -not already cloned the :troggle: repo. - -
You will do a git clone to create a folder /troggle/ containing all the troggle code. You need to clone the 'python-3' branch, if -you an see multiple branches.
- -cd ~
-cd ../expo
-git clone ssh://expo@expo.survex.com/home/expo/troggle
-
-
-Now we create soft links within the venv to all the repo folders and wherever you have a local copy of /expofiles/ and /expowebcache/: -
cd py39d32
-sudo ln -s /mnt/c/EXPO/expoweb expoweb
-sudo ln -s /mnt/c/EXPO/troggle troggle
-sudo ln -s /mnt/c/EXPO/loser loser
-sudo ln -s /mnt/c/EXPO/drawings drawings
-sudo ln -s /mnt/c/EXPO/expofiles expofiles
-sudo ln -s /mnt/c/EXPO/expowebcache expowebcache
-
-If you have not been using git on this machine until now, you will need to identify yourself before you go any further. -
git config --global user.email "you@example.com"
-git config --global user.name "Your Name"
-
This all checks that the installation has completed properly.
django-admin
@@ -269,19 +176,13 @@ git config --global user.name "Your Name"
See django-admin initial output for what you should expect to see at this point.
If it crashes though, you have not managed to install the software completely.
If you get an error when running
-django-admin
-Then run django-admin like this (using the python version you have installed in the folder underneath /lib/):
-python /usr/local/lib/python3.8/dist-packages/django/bin/django-admin.py
-which should fix the paths, but this means that you installed Django directly on your machine and not in a venv. From now on you should be able to run django-admin
-from within any folder on your machine.
-Now try
django-admin --version
The version number is the version of Django you have installed. Double check that it is the one you meant to install and check with our Django versions page.
Now try -
python manage.py
+python manage.py
You will get an error: No module named 'localsettings'. Fixing this is described below, but for now try: