mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-12-18 06:22:22 +00:00
now using uv not pip everywhere - online edit of handbook/troggle/troglaptop.html [PosixPath('/home/philip/expo/expoweb/handbook/troggle/troglaptop.html')]
This commit is contained in:
parent
84229b8241
commit
7816689a73
@ -38,7 +38,8 @@ $ git clone http://expo.survex.com/repositories/troggle/.git</code></pre>
|
||||
This will create <var>~/expo/troggle/</var> and get you a copy of the configuration scripts
|
||||
<ul><var>
|
||||
<li>troggle/_deploy/wsl/os-trog24.04.sh
|
||||
<li>troggle/_deploy/wsl/venv-trog24.04.sh
|
||||
<li>troggle/_deploy/wsl/os-survey.sh
|
||||
<li>troggle/_deploy/wsl/venv-trog.sh
|
||||
</var>
|
||||
</ul>
|
||||
but you need to make them executable before they will work:
|
||||
@ -100,7 +101,7 @@ which you can read without installing by looking in:<br>
|
||||
<p>You will run <var>os-trog24.04.sh</var> just once to install all the basics,and you will run <var>venv-trog.sh</var> just once initially.
|
||||
<p>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.] <var>venv-trog.sh</var> deals with all this python-specific stuff, libraries and Django plug-ins.
|
||||
|
||||
<p><var>os-trog.sh</var> takes a few minutes: it installs the subset of /expofiles/ you need to work with troggle. If you now want to install survex, therion etc. then run <var>os-survey.sh</var>as these drag in a huge number of dependencies.
|
||||
<p><var>os-trog.sh</var> takes a few minutes: it installs the subset of /expofiles/ you need to work with troggle. If you now want to install survex, therion etc. then run <var>os-survey.sh</var>, and go away for an hour, as these drag in a huge number of dependencies and installs all of /expofiles/ except the photos and Martin's mapapp.
|
||||
|
||||
<h3>Why no Docker container?</h3>
|
||||
<p>Yes, it is true that this would greatly speed up on-boarding new programmers. Or <a href="https://podman.io/">podman</a>.
|
||||
@ -116,20 +117,6 @@ provisioning so that systems are rebuilt cleanly. <a href="http://www.cuyc.org.u
|
||||
~$ <var>bash os-trog24.04.sh</var>
|
||||
<br>copy it from the .git repo online to get hold of it. Run it in <var>/home/username</var> and it will create a folder <var>expo</var> and clone all the repositories into it after installing the software you need. It installs some of <var>expofiles</var> but not <var>expofiles/photos/</var>.
|
||||
|
||||
<!--
|
||||
<pre><code>sudo apt install python3 python3-pip -y
|
||||
sudo apt install sqlite3 sqlite3-doc -y
|
||||
sudo apt install survex -y
|
||||
sudo apt install git gitk -y
|
||||
</code></pre>
|
||||
Martin Green is not sure why, but historically we may have also installed:
|
||||
<pre><code>
|
||||
sudo apt install software-properties-common -y
|
||||
sudo apt install default-jdk -y
|
||||
sudo apt install binutils binfmt-support -y
|
||||
</code></pre>
|
||||
-->
|
||||
|
||||
<h4>key exchange</h4>
|
||||
<p>You need this so that you can upload your edited code to the git repo on the server.
|
||||
<p>Follow this link to <a href="../computing/keyexchange.html">register a key with the expo server</a> to get git access if you have
|
||||
@ -159,44 +146,29 @@ confusing and apparently inconsistent behaviour: e.g. you will upload a file but
|
||||
|
||||
|
||||
|
||||
<h2 id="python">Installing python libraries</h2>
|
||||
<a href="https://xkcd.com/1987/"><img src="https://imgs.xkcd.com/comics/python_environment.png" align="right" hspace="20" width="230" alt='XKCD python install'></a>
|
||||
<h2 id="python">Installing python, packages and Django</h2>
|
||||
<a href="https://xkcd.com/1987/"><img src="https://imgs.xkcd.com/comics/python_environment.png" align="right" hspace="20" width="280" alt='XKCD python install'></a>
|
||||
|
||||
|
||||
<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.
|
||||
|
||||
<p>We do <em>not</em> install Django at the system level using <var>sudo apt install django</var>. We will be installing two variants of Django and python in a separate virtual
|
||||
environment (a 'venv'); not in the main linux system. The reasons why are indicated in the cartoon to the right and explained in <a href="https://nielscautaerts.xyz/python-dependency-management-is-a-dumpster-fire.html">"python dependency management is a dumpster fire".</a>
|
||||
|
||||
|
||||
|
||||
<h3 id="venv">Installing a venv</h3>
|
||||
<p>[We are revising this process. We are now (December 2024) using uv instead of pip, see
|
||||
<a href="https://nielscautaerts.xyz/python-dependency-management-is-a-dumpster-fire.html">"dumpster fire".</a>. DOCUMENTATION HERE NEEDS UPDATING URGENTLY, we do NOT use REQUIREMENTS.TXT
|
||||
]
|
||||
<p>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.</p>
|
||||
<p>[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.]
|
||||
<p>
|
||||
<strike>
|
||||
Create and activate the virtual enviroment:
|
||||
|
||||
<pre><code>cd ~/expo
|
||||
python3 -m venv venvexpo
|
||||
source venvexpo/bin/activate
|
||||
</code></pre>
|
||||
<p>To prevent compatibility issues when deploying our code, we test using the same libraries that run on expo.survex.com. In December 2024 expo.survex.com uses Python 3.11.2 and Django 3.2. However on our laptops we develop with Python 3.13 and Django 5 to get plenty of warning of future incompatibilities. Additionally, these newer versions are faster.
|
||||
|
||||
Install the python libraries
|
||||
|
||||
<pre><code>pip install -r requirements.txt</code></pre>
|
||||
<p>Do this:
|
||||
|
||||
|
||||
|
||||
<p>In case you have python version problems with venv, look at the instructions for <a href="/handbook/computing/wsllaptop.html_edit">python3.11 on WSL2</a>.
|
||||
|
||||
</strike>
|
||||
<pre><code>cd ~/expo
|
||||
<pre><code>cd ~/expo/troggle
|
||||
uv sync
|
||||
source .venv/bin/activate
|
||||
</code></pre>
|
||||
will mean that you can start checking that the development version of the system (Django 5, python 3.13 etc.) is working.
|
||||
which resolves the dependences for the packages used with the 'dev' (development) configuration, installs anything missing (including python interpreters), and sets up links to the correct versions of python and django.
|
||||
|
||||
|
||||
<p>To swap to the server mimic environment, do:
|
||||
|
||||
<pre><code>deactivate
|
||||
@ -213,8 +185,26 @@ cp <font color=red>dev.toml</font> pyproject.toml
|
||||
uv sync
|
||||
source .venv/bin/activate
|
||||
</code></pre>
|
||||
boh of these are extremely quick because they us <var>uv</var> and everything is cached.
|
||||
|
||||
These scripts are extremely quick because they use <var>uv</var> and everything is cached.
|
||||
The first time you run <var>uv sync</var> it may take a little while as it will install the
|
||||
appropriate version of python.
|
||||
<pre><code><font color="fuchsia">(troggle) philip@Mohawk:~/expo/troggle$</font> cp dev.toml pyproject.toml
|
||||
<font color="fuchsia">(troggle) philip@Mohawk:~/expo/troggle$</font> uv sync
|
||||
Using CPython 3.13.1
|
||||
Removed virtual environment at: .venv
|
||||
Creating virtual environment at: .venv
|
||||
Resolved 11 packages in 25ms
|
||||
Installed 9 packages in 545ms
|
||||
+ asgiref==3.8.1
|
||||
+ beautifulsoup4==4.12.3
|
||||
+ coverage==7.6.9
|
||||
+ django==5.1.4
|
||||
+ piexif==1.1.3
|
||||
+ pillow==11.0.0
|
||||
+ soupsieve==2.6
|
||||
+ sqlparse==0.5.3
|
||||
+ unidecode==1.3.8</code></pre>
|
||||
but it's still extremely quick.
|
||||
|
||||
<h4>do the basic Django health checks</h4>
|
||||
<p>This all checks that the installation has completed properly.
|
||||
@ -251,7 +241,7 @@ We have at one time made localsettings in /_deploy/ appropriate for
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
WARNING: only the WSL and debian variants are current in December 2021. All the others are so old that
|
||||
WARNING: only the WSL (12/2024) and debian (12/2023) variants are in any way current . All the others are so old that
|
||||
they will need serious work to be useable. Copy what you need from WSL and debian variants of
|
||||
localsettings.py
|
||||
|
||||
@ -421,8 +411,13 @@ You will find it very, very useful to see what is going on if you look directly
|
||||
and browse the data in the tables. This is vital when doing Django migrations between Django versions. A light-weight, simple db browser is <a href=
|
||||
"https://sqlitebrowser.org/">DB Browser for SQLite</a>. Connecting directly the the MariaDB database with a control panel or <a href=
|
||||
"https://www.mysql.com/products/workbench/">workbench</a> gives even more tools and documentation capabilities. See the <a href="serverconfig.html">
|
||||
|
||||
troggle server documentation</a> for how to install MariaDB.
|
||||
<p>When Ubuntu is running on WSL, it does not use systemctl. So you need specific instructions for installing MariaDB under WSL,
|
||||
<p>When Ubuntu was running on WSL1, it did not use systemctl. Now Ubuntu24.04 does ue systemctl so we should be able to use the same configuration as the server.. [untried as yet].
|
||||
|
||||
<div style="margin-left:15%">
|
||||
<h4>Previously..</h4>
|
||||
<p>So under WSL1 you needed specific instructions for installing MariaDB under WSL,
|
||||
do what it says in these instructions first (sudo apt install ...etc.):
|
||||
<ul>
|
||||
<li><a href="https://segmentfault.com/a/1190000040671057/en">Ubuntu-20.04 (WSL) install MySQL (MariaDB)</a>.
|
||||
@ -453,7 +448,7 @@ DATABASE = {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h4>But it still does not work</h4>
|
||||
<h4>But it still did not work</h4>
|
||||
<p>That is because we need to install the python tools that talk to mariadb. And while it 'will just work' for python3.9, the standard installed on the distro, with python3.10 it is a bit more work.
|
||||
|
||||
but note that there is a problem with using python 3.10 in that some bits of pip are not correct and you will get a
|
||||
@ -471,6 +466,7 @@ sudo apt install libmariadbclient-dev
|
||||
pip install mariadb
|
||||
</pre>
|
||||
wwhich now has installed mariadb python stuff, but seems to have trashed my django installattion. Hmph. And pip.
|
||||
</div>
|
||||
|
||||
<h2>Getting a copy of live javascript libraries</h2>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user