]> git.openstreetmap.org Git - nominatim.git/commitdiff
introduce paths module which contains the data paths
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 26 Nov 2022 16:08:51 +0000 (17:08 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 27 Nov 2022 11:02:37 +0000 (12:02 +0100)
This means that nominatim can find its data even when not called
from the command line tool.

CMakeLists.txt
cmake/paths-py.tmpl [new file with mode: 0644]
nominatim/paths.py [new file with mode: 0644]

index 332f1a123b9a1e5197c39c481b3df8566c18d5f1..4fe95f63e03526b385779afcf56acccfbaed3d5c 100644 (file)
@@ -233,7 +233,14 @@ if (BUILD_IMPORTER)
     install(DIRECTORY nominatim
             DESTINATION ${NOMINATIM_LIBDIR}/lib-python
             FILES_MATCHING PATTERN "*.py"
+            PATTERN "paths.py" EXCLUDE
             PATTERN __pycache__ EXCLUDE)
+
+    configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
+    install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
+            DESTINATION ${NOMINATIM_LIBDIR}/lib-python/nominatim
+            RENAME paths.py)
+
     install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
 
     install(FILES ${COUNTRY_GRID_FILE}
diff --git a/cmake/paths-py.tmpl b/cmake/paths-py.tmpl
new file mode 100644 (file)
index 0000000..372a454
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
+"""
+Path settings for extra data used by Nominatim (installed version).
+"""
+from pathlib import Path
+
+PHPLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-php').resolve()
+SQLLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-sql').resolve()
+DATA_DIR = Path('@NOMINATIM_DATADIR@').resolve()
+CONFIG_DIR = Path('@NOMINATIM_CONFIGDIR@').resolve()
diff --git a/nominatim/paths.py b/nominatim/paths.py
new file mode 100644 (file)
index 0000000..a34628d
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
+"""
+Path settings for extra data used by Nominatim.
+"""
+from pathlib import Path
+
+PHPLIB_DIR = (Path(__file__) / '..' / '..' / 'lib-php').resolve()
+SQLLIB_DIR = (Path(__file__) / '..' / '..' / 'lib-sql').resolve()
+DATA_DIR = (Path(__file__) / '..' / '..' / 'data').resolve()
+CONFIG_DIR = (Path(__file__) / '..' / '..' / 'settings').resolve()