From d87db3ed82243ec8bf7e2c58c10d8e43f7d69542 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 15 Dec 2024 00:32:40 +0000 Subject: [PATCH] os-trog and venv-trog initial documn. - online edit of handbook/troggle/troglaptop.html [PosixPath('/home/philip/expo/expoweb/handbook/troggle/troglaptop.html')] --- handbook/troggle/troglaptop.html | 59 ++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/handbook/troggle/troglaptop.html b/handbook/troggle/troglaptop.html index 2ed23b939..b6f2488d9 100644 --- a/handbook/troggle/troglaptop.html +++ b/handbook/troggle/troglaptop.html @@ -66,41 +66,38 @@ Windows Subsystem for Linux now packaged as a Microsoft Store app,
  • ~/expo/expoweb
  • ~/expo/drawings
  • ~/expo/loser

    -
  • ~/expo/p13d5/ - python3.13 Django 5 (dev) -
  • ~/expo/p11d3/ - python3.11 Django 3.2 (server mimic) +
  • ~/expo/.venv/ - virtual environment -

    The install script (see below) will create the dev and server-mimic folders which will be virtual environments. +

    The install script (see below) will create the virtual environment.

    Before the install scripts work on a bare Ubuntu installation, you will need to have git installed. This is in-built on Ubuntu 24.04 but on other (and earlier) Linux distros you will need to do:
    sudo apt intall git
    manually.

    There are two scripts in the troggle folder which will do semi-automatically what is described below. Have a look at

    -which you can read without installing by looking at:
    +which you can read without installing by looking in:
    +troggle/.git/tree/_deploy/wsl. -

    You will run os-trog.sh just once to install the basics, but you will run venv-trog.sh every time you fire up a new python version/django version combination or play with the versions of the imported packages as listed in requirements.txt. +

    You will run os-trog24.04.sh just once to install the basics,and you will run venv-trog.sh just once initially. +

    We have two configurations for the virtual environment: 'dev' which uses the latest python and Django for speed, and 'server' which mimics the versions currently running on the server. In December 2024 Django is 5 releases ahead of the version on the server (5.1 versus 3.2). Each has a list of ancilliary packages with the appropriate versions in dev.toml and server.toml. +

    os-trog.sh takes a few minutes initially, but then about an hour when it installs therion and tunnel as these drag in a huge number of dependencies.

    Files and directories

    -

    Do familiarise yourself with the directory structure on the expo server, which we will be duplicating (partly) as docmented in The Expo Server. 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. These will be setup for you by venv-trog.sh. - +

    Do familiarise yourself with the directory structure on the expo server, which we will be duplicating (partly) as docmented in The Expo Server. 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.

    WSL on Windows

    [You will need to read this is you are doing anything even very slightly off the beaten tracke: WSL/Troggle].

    -

    If you are using a very old laptop, you may have to run Ubuntu in WSL1 rather than WSL2. WSL2 requires virtualisation features that your hardware may not support if it is more than about 10 years old. -

    The standard documentation for Ubuntu or debian below all works, but you should first skim the - Windows expo laptop configuration too. So far as expo software is concerned, WSL1 and WSL2 behave identically.

    ...Except for file permissions, which can cost you a day of frustration if you are unlucky. -The trick is to make sure that all the files in your development folders, e.g. C:\expo\ which contains your repos e.g. C:\expo\troggle\ are owned in the Windows system by the default Windows user e.g. MACHINENAME\philip and owned in the Linux system e.g. /mnt/c/expo/ by the default Linux user, e.g. philip:philip using
    sudo chown -Rhv philip:philip * -
    -and then reboot your machine as this doesn't seem to properly take effect until you do that. -

    -See also WSL File Permissions. +

    The standard documentation for Ubuntu or debian below all works, but you should first skim the + Windows expo laptop configuration too. + +

    Why no Docker container?

    Yes, it is true that this would greatly speed up on-boarding new programmers. Or podman. @@ -109,10 +106,14 @@ resulting in configuration drift and a 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. + development system. We should copy that in the first instance. Alas, we haven't got around to doing any of this yet. However uv now makes everything much, much simpler than when were were using pip.

    Configuring ubuntu

    +

    In your home folder run
    +~$ bash os-trog24.04.sh +
    copy it from the .git repo online to get hold of it. + -

    Configuring git

    key exchange

    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 @@ -159,12 +160,7 @@ 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. -

    Getting a copy of live javascript libraries

    -To get the same javascript libraries as the expo server: - -
    scp -r expo@expo.survex.com:/usr/share/javascript/ ~/expo/troggle/javascript/
    -

    Installing python libraries

    @@ -178,8 +174,8 @@ environment (a 'venv'), not in the main linux system.

    Installing a venv

    -

    [We are revising this process. In future we may be using uv instead of pip, see - "dumpster fire". +

    [We are revising this process. We are now (December 2024) using uv instead of pip, see + "dumpster fire".. DOCUMENTATION HERE NEEDS UPDATING URGENTLY, we do NOT use REQUIREMENTS.TXT ]

    In order to avoid compatability issues when deploying our code, we should develop using the same libraries that will be used in production of expo.survex.com. Expo.survex.com currently uses python 3.11.2, python 3.12 (standard with Ubuntu 24.04) is backwardly compatable as long as you do not use any new functions it should be fine. Venv allows us to specify which python libraries to use.

    [We also develop with Django 5 even though the server is still running Django 3.2, but so long as we are carefule, and test code before pushng to the server, this is fine.] @@ -457,6 +453,15 @@ sudo apt install libmariadbclient-dev pip install mariadb wwhich now has installed mariadb python stuff, but seems to have trashed my django installattion. Hmph. And pip. + +

    Getting a copy of live javascript libraries

    + +To get the same javascript libraries as the expo server: + +
    scp -r expo@expo.survex.com:/usr/share/javascript/ ~/expo/troggle/javascript/
    +
    +but you don't need these for most troggle development: copies of what is needed are in the troggle git repo. One example that is not in the troggle git repo is "CaveView". +
    Go on to: Troggle architecture
    @@ -464,5 +469,9 @@ Go on to: Troggle architecture
    Return to: Troggle programmers' guide
    Troggle index: Index of all troggle documents
    +Go to: ※ Basic laptop
    +Go to: ⁂ Survey laptop
    +Go to: ☯ Windows Bulk Update laptop
    +Go to: ⚒ Troggle development laptop