Skip to content

Commit 6ea0ef5

Browse files
committed
#510 fixes to allow install in plain Python venv
1 parent 980b79c commit 6ea0ef5

5 files changed

Lines changed: 95 additions & 44 deletions

File tree

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ See also the [full GHC documentation](http://docs.geohealthcheck.org/).
1010

1111
Easiest is [to run GHC using Docker](https://github.com/geopython/GeoHealthCheck/blob/master/docker/README.md).
1212

13-
## Manual Install
14-
Below a quick overview of a manual install on Unix-based systems like Apple MacOS and Linux.
13+
## Standard Install
14+
15+
Below an overview of an installation on Unix-based systems like Apple MacOS and Linux with just plain Python.
16+
NB works with Python 3.12.*, other Python versions need tweaking [pyproject.toml](pyproject.toml).
1517

1618
```bash
17-
virtualenv GeoHealthCheck && cd $_
19+
20+
python -m venv ghc && cd ghc
1821
. bin/activate
1922
git clone https://github.com/geopython/GeoHealthCheck.git
2023
cd GeoHealthCheck
21-
pip3 install Invoke
24+
pip install --no-cache-dir -U pip setuptools wheel Invoke
25+
pip install --no-cache-dir -e .
26+
2227
# setup installation
2328
invoke setup
2429
# generate secret key
@@ -27,6 +32,7 @@ invoke create-secret-key
2732
vi instance/config_site.py
2833
# edit at least secret key:
2934
# - SECRET_KEY # copy/paste result string from `invoke create-secret-key`
35+
# - SQLALCHEMY_DATABASE_URI = 'sqlite:///../instance/data.db' - put in instance dir
3036

3137
# Optional: edit other settings or leave defaults
3238
# - SQLALCHEMY_DATABASE_URI
@@ -38,32 +44,32 @@ vi instance/config_site.py
3844
# - GHC_MAP (or use default settings)
3945

4046
# setup database and superuser account interactively
41-
invoke create
47+
invoke create -u admin -p admin -e a@a.com
4248

4349
# start webserver with healthcheck runner daemon inside
4450
# (default is 0.0.0.0:8000)
45-
python3 GeoHealthCheck/app.py
51+
python GeoHealthCheck/app.py
4652
# or start webserver on another port
47-
python3 GeoHealthCheck/app.py 0.0.0.0:8881
53+
python GeoHealthCheck/app.py 0.0.0.0:8881
4854
# or start webserver on another IP
49-
python3 GeoHealthCheck/app.py 192.168.0.105:8001
55+
python GeoHealthCheck/app.py 192.168.0.105:8001
5056

5157
# OR start webserver and separate runner daemon (scheduler) process
5258
vi instance/config_site.py
5359
# GHC_RUNNER_IN_WEBAPP = False
54-
python3 GeoHealthCheck/scheduler.py &
55-
python3 GeoHealthCheck/app.py
60+
python GeoHealthCheck/scheduler.py &
61+
python GeoHealthCheck/app.py
5662

5763
# next: use a real webserver or preferably Docker for production
5864

5965
# other commands
6066
#
6167
# drop database
62-
python3 GeoHealthCheck/models.py drop
68+
python GeoHealthCheck/models.py drop
6369

6470
# load data in database (WARN: deletes existing data!)
6571
# See example data .json files in tests/data
66-
python3 GeoHealthCheck/models.py load <.json data file> [y/n]
72+
python GeoHealthCheck/models.py load <.json data file> [y/n]
6773

6874
```
6975

@@ -72,7 +78,8 @@ python3 GeoHealthCheck/models.py load <.json data file> [y/n]
7278
[Pixi](https://pixi.sh) manages the environment; tasks run via `pixi run`,
7379
so no shell activation is needed.
7480

75-
```
81+
```bash
82+
7683
git clone https://github.com/geopython/GeoHealthCheck.git
7784
cd GeoHealthCheck
7885

@@ -92,7 +99,7 @@ vi instance/config_site.py
9299
# Optional: edit other settings or leave defaults (see above)
93100

94101
# setup superuser account password and email directly
95-
pixi run -e prod create -username admin -password admin --email a@a.com
102+
pixi run -e prod create --username admin --password admin --email a@a.com
96103

97104
# or shorter
98105
pixi run -e prod create -u admin -p admin --e a@a.com
@@ -106,7 +113,8 @@ pixi run -e prod run
106113

107114
### Development and tests
108115

109-
```
116+
```bash
117+
110118
# install the dev environment (adds flake8, pytest, ...)
111119
pixi install -e dev
112120

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.0
1+
0.9.1dev

docs/install.rst

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ These dependencies are automatically installed (see below). `Invoke <https://doc
3131
for installation and management. ``Cron`` was used for scheduling the actual
3232
healthchecks before v0.5.0.
3333

34-
Starting from version v0.8.0.0 GeoHealthCheck requires **python3 3**. Previous
34+
Starting from version v0.8.0 GeoHealthCheck requires **python3 3**. Previous
3535
versions require **python3 2**. GeoHealthCheck is at least compatible with Python versions
3636
up to and including `3.12.3`. Higher Python versions may work but are untested.
3737

@@ -40,24 +40,26 @@ Install
4040

4141
.. note::
4242

43-
It is strongly recommended to install GeoHealthCheck in a Python ``virtualenv``.
44-
a ``virtualenv`` is self-contained and provides the flexibility to install /
43+
It is strongly recommended to install GeoHealthCheck in a Python Virtual Environment.
44+
A Virtual Environment is self-contained and provides the flexibility to install /
4545
tear down / whatever packages without affecting system wide packages or
46-
settings.
47-
If installing on Ubuntu, you may need to install the python-dev package for installation to complete successfully.
48-
46+
settings. The installation is driven by the standard config file `pyproject.toml`.
47+
It is recommended to use `pixi <https://pixi.prefix.dev/>`_ to manage the entire installation and
48+
further management.
49+
4950
- Download a GeoHealthCheck release from
5051
https://github.com/geopython/GeoHealthCheck/releases, or clone manually from GitHub.
5152

53+
The following local install works with Python 3.12, other (lower) Python versions may need changes in `pyproject.toml`.
54+
5255
.. code-block:: bash
5356
54-
python3 -m venv ghc && cd ghc
55-
source ./bin/activate
57+
python -m venv ghc && cd ghc
58+
. bin/activate
5659
git clone https://github.com/geopython/GeoHealthCheck.git
5760
cd GeoHealthCheck
58-
59-
# install Invoke dependency for admin tool
60-
pip3 install invoke
61+
pip install --no-cache-dir -U pip setuptools wheel Invoke
62+
pip install --no-cache-dir -e .
6163
6264
# setup app
6365
invoke setup
@@ -68,8 +70,8 @@ Install
6870
# almost there! Customize config
6971
vi instance/config_site.py
7072
# edit:
71-
# - SQLALCHEMY_DATABASE_URI
72-
# - SECRET_KEY # from invoke create-secret-key
73+
# - SQLALCHEMY_DATABASE_URI = 'sqlite:///../instance/data.db' - put in instance dir
74+
# - SECRET_KEY # paste from invoke create-secret-key
7375
# - GHC_RETENTION_DAYS
7476
# - GHC_SELF_REGISTER
7577
# - GHC_NOTIFICATIONS
@@ -84,17 +86,52 @@ Install
8486
# - GHC_MAP # or use default settings
8587
# - GEOIP # or use the default settings
8688
87-
# init database
88-
python3 GeoHealthCheck/models.py create
89+
# setup database and superuser account directly
90+
invoke create -u admin -p admin -e a@a.com
8991
9092
# start web-app
91-
python3 GeoHealthCheck/app.py # http://localhost:8000/
93+
python GeoHealthCheck/app.py # http://localhost:8000/
9294
9395
# when you are done, you can exit the virtualenv
9496
deactivate
9597
9698
NB GHC supports internal scheduling, no cronjobs required.
9799

100+
It is strongly recommended to install `pixi <https://pixi.prefix.dev/>`_ and
101+
handle the GeoHealthCheck installation and further tasks. The GHC Dockerfile also
102+
uses `pixi`.
103+
104+
.. code-block:: bash
105+
106+
git clone https://github.com/geopython/GeoHealthCheck.git
107+
cd GeoHealthCheck
108+
109+
# Install production environment
110+
pixi install -e prod
111+
112+
# bootstrap the app (config, static assets, i18n, local docs, DB)
113+
pixi run -e prod setup
114+
115+
# generate secret key
116+
pixi run -e prod create-secret-key
117+
# setup local configuration (overrides GeoHealthCheck/config_main.py)
118+
vi instance/config_site.py
119+
# edit at least secret key:
120+
# - SECRET_KEY # copy/paste result string from the command above
121+
122+
# Optional: edit other settings or leave defaults (see above)
123+
124+
# setup superuser account password and email directly
125+
pixi run -e prod create --username admin --password admin --email a@a.com
126+
127+
# or shorter
128+
pixi run -e prod create -u admin -p admin --e a@a.com
129+
130+
# run locally
131+
pixi run -e prod run
132+
133+
# open http://localhost:8000 in browser
134+
98135
.. _upgrade:
99136

100137
Upgrade
@@ -269,12 +306,11 @@ See for example the `GHC Docker run.sh <https://github.com/geopython/GeoHealthCh
269306
script to run the GHC Webapp with `gunicorn` and the `GHC Runner run-runner.sh <https://github.com/geopython/GeoHealthCheck/blob/master/docker/scripts/run-runner.sh>`_ script
270307
to run the scheduled healthchecks.
271308

272-
Use virtualenv
273-
..............
309+
Virtual Environment
310+
...................
274311

275-
This is a general Python-recommendation. Save yourself from classpath and library hells by using `virtualenv`! Starting with python3 3.3
276-
a `venv script <https://docs.python.org/3.3/library/venv.html>`_ is provided and from python3 3.6 the `venv module <https://docs.python.org/3/library/venv.html>`_
277-
is included in the standard library.
312+
Use Virtual Environment! This is a general Python-recommendation. Save yourself from classpath and library hells by using Python's built-in `virtualenv`! Starting with python3 3.3
313+
a `venv script <https://docs.python.org/3.12/library/venv.html>`_ is provided in the standard library.
278314

279315
Use SSL (HTTPS)
280316
...............

pyproject.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[project]
22
name = "GeoHealthCheck"
3-
version = "0.9.0"
3+
version = "0.9.1dev"
44
description = "Monitor uptime and availability of OGC web services and REST APIs"
55
readme = "README.md"
6-
requires-python = ">=3.12,<3.13"
7-
license = { text = "MIT" }
6+
requires-python = ">=3.12,<3.14"
7+
license = "MIT"
8+
license-files = ["LICENSE"]
89
authors = [
910
{ name = "Just van den Broecke", email = "just@justobjects.nl" },
1011
{ name = "Tom Kralidis", email = "tomkralidis@gmail.com" },
@@ -49,6 +50,15 @@ Homepage = "https://geohealthcheck.org"
4950
Documentation = "https://docs.geohealthcheck.org"
5051
Repository = "https://github.com/geopython/GeoHealthCheck"
5152

53+
[build-system]
54+
requires = ["setuptools", "pip", "wheel"]
55+
build-backend = "setuptools.build_meta"
56+
57+
[tool.setuptools.packages.find]
58+
where = ["."]
59+
exclude = ["tests*"]
60+
include = ["GeoHealthCheck*"]
61+
5262
# Pixi workspace configuration (replaces pixi.toml)
5363
# No [build-system] on purpose: GeoHealthCheck runs from source
5464
# (via `invoke setup`), so pixi manages the environment but does not

tasks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ def setup(c):
6767
data_dir.chmod(0o777)
6868
shutil.copy2(config_file, config_site)
6969

70-
# setup deps
71-
# c.run('pip3 install -r requirements.txt')
72-
73-
skin = 'http://github.com/BlackrockDigital/startbootstrap-sb-admin-2/archive/v3.3.7+1.zip' # noqa
70+
skin = 'https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/archive/v3.3.7+1.zip' # noqa
7471

7572
skin_dirs = ['dist', 'vendor']
7673
need_to_fetch = False

0 commit comments

Comments
 (0)