]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/version.py
prepare release 4.4.0
[nominatim.git] / nominatim / version.py
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # This file is part of Nominatim. (https://nominatim.org)
4 #
5 # Copyright (C) 2023 by the Nominatim developer community.
6 # For a full list of authors see the git log.
7 """
8 Version information for Nominatim.
9 """
10 from typing import Optional, NamedTuple
11
12 class NominatimVersion(NamedTuple):
13     """ Version information for Nominatim. We follow semantic versioning.
14
15         Major, minor and patch_level refer to the last released version.
16         The database patch level tracks important changes between releases
17         and must always be increased when there is a change to the database or code
18         that requires a migration.
19
20         When adding a migration on the development branch, raise the patch level
21         to 99 to make sure that the migration is applied when updating from a
22         patch release to the next minor version. Patch releases usually shouldn't
23         have migrations in them. When they are needed, then make sure that the
24         migration can be reapplied and set the migration version to the appropriate
25         patch level when cherry-picking the commit with the migration.
26     """
27
28     major: int
29     minor: int
30     patch_level: int
31     db_patch_level: int
32
33     def __str__(self) -> str:
34         return f"{self.major}.{self.minor}.{self.patch_level}-{self.db_patch_level}"
35
36
37 NOMINATIM_VERSION = NominatimVersion(4, 4, 0, 0)
38
39 POSTGRESQL_REQUIRED_VERSION = (9, 6)
40 POSTGIS_REQUIRED_VERSION = (2, 2)
41
42 # Cmake sets a variable @GIT_HASH@ by executing 'git --log'. It is not run
43 # on every execution of 'make'.
44 # cmake/tool-installed.tmpl is used to build the binary 'nominatim'. Inside
45 # there is a call to set the variable value below.
46 GIT_COMMIT_HASH : Optional[str] = None
47
48
49 def parse_version(version: str) -> NominatimVersion:
50     """ Parse a version string into a version consisting of a tuple of
51         four ints: major, minor, patch level, database patch level
52
53         This is the reverse operation of `version_str()`.
54     """
55     parts = version.split('.')
56     return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])