expoweb/handbook/troggle/troglaptop.html

152 lines
7.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Handbook Troggle Laptop</title>
<link rel="stylesheet" type="text/css" href="../../css/main2.css" />
</head>
<body><style>body { background: #fff url(/images/style/bg-system.png) repeat-x 0 0 }</style>
<h2 id="tophead">CUCC Expedition Handbook</h2>
<h1>Troggle - software development laptop</h1>
<img src="https://www.python.org/favicon.ico" width=64 hspace="20" align="right" alt='python logo'>
<h2>Software development machine</h2>
<p>For troggle itself, you need a linux machine. We all use Debian or Debian-derived machines (Debian itself, Ubuntu, Xubuntu etc.) but other forms of linux may work. Running Debian or Ubuntu under WSL on Windows 10 works fine.
<p>If you want to work on the troggle source code and be able to commit to the server git repo,
your account will need to be added to the troggle project members list. Contact wookey at wookware dot org to get this set up.
<p>This page is a work in progess. Text will be moved here from
<img border="1" class="onright" width="150px" src='tricky-troggle.jpg' alt='troggle logo'/></a>
<pre>
http://expo.survex.com/repositories/troggle/.git/tree/README.txt
handbook/computing/yourlaptop.html
handbook/troggle/trogdjangup.html
</pre>
<h2 id="os">Installing linux</h2>
<p>If you don't already know how to do this, then you should probably not be attempting this. But in case you are an experienced linux user who has always had someone else set up the system for them, then Ubuntu is the easiest and more forgiving to install, either directly on the computer or inside WSL. Because we are using fairly old releases of Django, you will want Ubuntu-20.04
<ul>
<li>Install in <a href="https://docs.microsoft.com/en-us/windows/wsl/install">WSL on Windows 10</a>.
<li>Install <a href="https://ubuntu.com/download/desktop">Ubuntu 20.04 LTS</a>.
</ul>
<p>and familiarise yourself with the directory structure on the expo server, which we will be duplicating (partly) as docmented in <a href="serverconfig.html">The Expo Server</a>. We are not here doing a full install of all the software and scripts on the server, just the minimum to run, test and debug troggle on django.
<h3>WSL on Windows</h3>
<p>The standard documentation for Ubuntu or debian below all works, but you should first skim the
<a href="../computing/winlaptop.html">Windows expo laptop</a> description of WSL1 and WSL2. The default
is that WSL2 will be installed, but all our practical experience so far is with WSL1.
<h2 id="python">Installing python</h2>
<p>Python is not installed by default usually, and in any case we need specific versions to be installed. For Ubuntu 20.04 the default is python3.9 but this is incompatible with standard debian Buster, so we also need python3.7,
and also python3.8 if you are planning on migrating troggle from debian Buster (v10) to Bullseye (v11).
<pre><code>sudo apt install python3 python3-pip
sudo apt install python3.7
sudo apt install python3.8
sudo apt install sqlite3 sqlite3-doc
sudo apt install survex
cd /usr/bin
sudo ln -s python3 python
sudo ln -s pip3 pip </code></pre>
<p>You will also definitely need sqlite3 even if you are planning to use another
database. Sqlite3 is used by the test harness system.
<p>Note that when you install survex it installs a shed load of packages that it needs.
<p>We do <em>not</em> install django at this point. We will be installing django in a separate virtual
environment (a 'venv'), not in the main linux system.
<h2 id="links">Creating folders and soft links</h2>
<p>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 and 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 <var>/mnt/c/EXPO/</var>, then you would need to do this:
<pre><code>cd ~
cd ..
sudo mkdir expo
cd expo
sudo ln -s /mnt/c/EXPO/expofiles expofiles
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/expowebcache expowebcache
sudo mkdir expowebcache/3d
cd ..
ls -tlA expo</pre></code>
<h2>Installing Django and troggle</h2>
<p>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 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.
<h3 id="venv">Installing a venv</h3>
<p>We set up
a <var>venv</var> specifically for python 3.7 (which is the standard version on our server which is running Buster (debian v10) and <a href="https://docs.djangoproject.com/en/3.2/releases/2.2/">django 2.2.19</a>. See the <a href="https://docs.python.org/3.7/library/venv.html">standard python dcoumentation on venv</a> for python 3.7.12. Note that we are creating it as a sibling folder to /troggle/ .
<pre><code>cd ~
cd ../expo
python3.7 -m venv py37d22
cd py37d22
source bin/activate
pip list -o</pre></code>
<p>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.
<p>The first time you do this you can't complete the pip installation of django as you have not yet got the
dependencies - 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.
<pre><code>cp ../troggle/requirements.txt .
pip install -r requirements.txt
pip list -o</pre></code>
where <var>requirements.txt</var> (note the capitalisation of the listed packages) is:
<pre><code>confusable-homoglyphs==3.2.0
Django==2.2
docutils==0.14
gunicorn==20.1.0
Pillow==5.4.1
pytz==2019.1
sqlparse==0.2.4
Unidecode==1.0.23</pre></code>
This will pick up the latest django 2.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).
<p>Pillow is an image handling package used to make
the prospecting map (currently disabled,
see <a href="http://expo.survex.com/prospecting_guide/">/prospecting_guide/</a>).<br>
tinymce is the wysiwyg in-browser
editor (disabled pending reinstatement)
<p>This is also documented in the <a href="trogdjangup.html">updating django for troggle page</a>
where it describes upgrading and testing with later versions of django.
<p>If you have not used pip before, read <a href="https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/">this</a>
<h3 id="troginstall">Installing troggle</h3>
<dl><dt>key exchange</dt><dd>Follow this link to <a href="../computing/keyexchange.html">register a key with the expo server</a> to get git access. </dd>
<dt>troggle</dt><dd>The <var>:troggle:</var> repo is the python code that runs troggle and generates 2,000 webpages of reports and tables. This is what you need for software development.<tt>cd /home/expo/p37d22<br>git clone ssh://expo@expo.survex.com/home/expo/troggle</tt> (read/write)</dd>
</dl>
<hr />
Go on to: <a href="trogarch.html">Troggle architecture</a><br />
Return to: <a href="trognotes.html">Troggle programmers' guide</a><br />
Troggle index:
<a href="trogindex.html">Index of all troggle documents</a><br />
<hr />
</body>
</html>