1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Version information for Nominatim.
10 from typing import NamedTuple, Optional
12 # See also https://github.com/PyCQA/pylint/issues/6006
13 # pylint: disable=useless-import-alias,unused-import
15 class NominatimVersion(NamedTuple):
16 """ Version information for Nominatim. We follow semantic versioning.
18 Major, minor and patch_level refer to the last released version.
19 The database patch level tracks important changes between releases
20 and must always be increased when there is a change to the database or code
21 that requires a migration.
23 When adding a migration on the development branch, raise the patch level
24 to 99 to make sure that the migration is applied when updating from a
25 patch release to the next minor version. Patch releases usually shouldn't
26 have migrations in them. When they are needed, then make sure that the
27 migration can be reapplied and set the migration version to the appropriate
28 patch level when cherry-picking the commit with the migration.
36 def __str__(self) -> str:
37 if self.db_patch_level is None:
38 return f"{self.major}.{self.minor}.{self.patch_level}"
40 return f"{self.major}.{self.minor}.{self.patch_level}-{self.db_patch_level}"
42 def release_version(self) -> str:
43 """ Return the release version in semantic versioning format.
45 The release version does not include the database patch version.
47 return f"{self.major}.{self.minor}.{self.patch_level}"
51 def parse_version(version: str) -> NominatimVersion:
52 """ Parse a version string into a version consisting of a tuple of
53 four ints: major, minor, patch level, database patch level
55 This is the reverse operation of `version_str()`.
57 parts = version.split('.')
58 return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])
61 NOMINATIM_VERSION = parse_version('4.5.0-0')
63 POSTGRESQL_REQUIRED_VERSION = (9, 6)
64 POSTGIS_REQUIRED_VERSION = (2, 2)
65 OSM2PGSQL_REQUIRED_VERSION = (1, 8)
67 # Cmake sets a variable @GIT_HASH@ by executing 'git --log'. It is not run
68 # on every execution of 'make'.
69 # cmake/tool-installed.tmpl is used to build the binary 'nominatim'. Inside
70 # there is a call to set the variable value below.
71 GIT_COMMIT_HASH : Optional[str] = None