]> git.openstreetmap.org Git - nominatim.git/commitdiff
reduce from 3 to 2 packages
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 27 Jun 2024 19:26:12 +0000 (21:26 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 28 Jun 2024 07:13:22 +0000 (09:13 +0200)
149 files changed:
CMakeLists.txt
Makefile
docs/admin/Installation.md
docs/library/Configuration.md
packaging/nominatim-api/extra_src/paths.py [new file with mode: 0644]
packaging/nominatim-api/pyproject.toml
packaging/nominatim-api/settings [moved from packaging/nominatim-core/settings with 100% similarity]
packaging/nominatim-core/COPYING [deleted symlink]
packaging/nominatim-core/README.md [deleted file]
packaging/nominatim-core/data [deleted symlink]
packaging/nominatim-core/pyproject.toml [deleted file]
packaging/nominatim-core/src [deleted symlink]
packaging/nominatim-db/data [new symlink]
packaging/nominatim-db/extra_src/nominatim_db/paths.py [moved from packaging/nominatim-core/extra_src/nominatim_core/paths.py with 100% similarity]
packaging/nominatim-db/lib-sql [moved from packaging/nominatim-core/lib-sql with 100% similarity]
packaging/nominatim-db/pyproject.toml
packaging/nominatim-db/settings [new symlink]
src/nominatim_api/__init__.py
src/nominatim_api/config.py [new file with mode: 0644]
src/nominatim_api/connection.py
src/nominatim_api/core.py
src/nominatim_api/errors.py [moved from src/nominatim_core/errors.py with 100% similarity]
src/nominatim_api/lookup.py
src/nominatim_api/results.py
src/nominatim_api/reverse.py
src/nominatim_api/search/db_search_fields.py
src/nominatim_api/search/db_search_lookups.py
src/nominatim_api/search/db_searches.py
src/nominatim_api/search/icu_tokenizer.py
src/nominatim_api/search/legacy_tokenizer.py
src/nominatim_api/server/falcon/server.py
src/nominatim_api/server/starlette/server.py
src/nominatim_api/sql/async_core_library.py [moved from src/nominatim_core/db/async_core_library.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_functions.py
src/nominatim_api/sql/sqlalchemy_schema.py [moved from src/nominatim_core/db/sqlalchemy_schema.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_types/__init__.py [moved from src/nominatim_core/db/sqlalchemy_types/__init__.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_types/geometry.py [moved from src/nominatim_core/db/sqlalchemy_types/geometry.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_types/int_array.py [moved from src/nominatim_core/db/sqlalchemy_types/int_array.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_types/json.py [moved from src/nominatim_core/db/sqlalchemy_types/json.py with 100% similarity]
src/nominatim_api/sql/sqlalchemy_types/key_value.py [moved from src/nominatim_core/db/sqlalchemy_types/key_value.py with 100% similarity]
src/nominatim_api/status.py
src/nominatim_api/types.py
src/nominatim_api/typing.py [new file with mode: 0644]
src/nominatim_api/utils/__init__.py [moved from src/nominatim_core/__init__.py with 100% similarity]
src/nominatim_api/utils/json_writer.py [moved from src/nominatim_core/utils/json_writer.py with 100% similarity]
src/nominatim_api/v1/format.py
src/nominatim_api/v1/format_json.py
src/nominatim_api/v1/server_glue.py
src/nominatim_api/version.py
src/nominatim_core/py.typed [deleted file]
src/nominatim_core/version.py [deleted file]
src/nominatim_db/cli.py
src/nominatim_db/clicmd/admin.py
src/nominatim_db/clicmd/api.py
src/nominatim_db/clicmd/args.py
src/nominatim_db/clicmd/convert.py
src/nominatim_db/clicmd/export.py
src/nominatim_db/clicmd/freeze.py
src/nominatim_db/clicmd/index.py
src/nominatim_db/clicmd/refresh.py
src/nominatim_db/clicmd/replication.py
src/nominatim_db/clicmd/setup.py
src/nominatim_db/clicmd/special_phrases.py
src/nominatim_db/config.py [moved from src/nominatim_core/config.py with 98% similarity]
src/nominatim_db/data/country_info.py
src/nominatim_db/data/postcode_format.py
src/nominatim_db/db/__init__.py [moved from src/nominatim_core/db/__init__.py with 100% similarity]
src/nominatim_db/db/async_connection.py [moved from src/nominatim_core/db/async_connection.py with 100% similarity]
src/nominatim_db/db/connection.py [moved from src/nominatim_core/db/connection.py with 100% similarity]
src/nominatim_db/db/properties.py [moved from src/nominatim_core/db/properties.py with 100% similarity]
src/nominatim_db/db/sql_preprocessor.py [moved from src/nominatim_core/db/sql_preprocessor.py with 100% similarity]
src/nominatim_db/db/status.py [moved from src/nominatim_core/db/status.py with 100% similarity]
src/nominatim_db/db/utils.py [moved from src/nominatim_core/db/utils.py with 100% similarity]
src/nominatim_db/errors.py [new file with mode: 0644]
src/nominatim_db/indexer/indexer.py
src/nominatim_db/indexer/runners.py
src/nominatim_db/paths.py [moved from src/nominatim_core/paths.py with 100% similarity]
src/nominatim_db/tokenizer/base.py
src/nominatim_db/tokenizer/factory.py
src/nominatim_db/tokenizer/icu_rule_loader.py
src/nominatim_db/tokenizer/icu_tokenizer.py
src/nominatim_db/tokenizer/legacy_tokenizer.py
src/nominatim_db/tokenizer/place_sanitizer.py
src/nominatim_db/tokenizer/sanitizers/base.py
src/nominatim_db/tokenizer/sanitizers/config.py
src/nominatim_db/tokenizer/token_analysis/base.py
src/nominatim_db/tokenizer/token_analysis/config_variants.py
src/nominatim_db/tokenizer/token_analysis/generic.py
src/nominatim_db/tokenizer/token_analysis/generic_mutation.py
src/nominatim_db/tools/add_osm_data.py
src/nominatim_db/tools/admin.py
src/nominatim_db/tools/check_database.py
src/nominatim_db/tools/collect_os_info.py
src/nominatim_db/tools/convert_sqlite.py
src/nominatim_db/tools/database_import.py
src/nominatim_db/tools/exec_utils.py
src/nominatim_db/tools/freeze.py
src/nominatim_db/tools/migration.py
src/nominatim_db/tools/postcodes.py
src/nominatim_db/tools/refresh.py
src/nominatim_db/tools/replication.py
src/nominatim_db/tools/special_phrases/sp_csv_loader.py
src/nominatim_db/tools/special_phrases/sp_importer.py
src/nominatim_db/tools/special_phrases/sp_wiki_loader.py
src/nominatim_db/tools/tiger_data.py
src/nominatim_db/typing.py [moved from src/nominatim_core/typing.py with 65% similarity]
src/nominatim_db/utils/__init__.py [moved from src/nominatim_core/utils/__init__.py with 100% similarity]
src/nominatim_db/utils/centroid.py [moved from src/nominatim_core/utils/centroid.py with 100% similarity]
src/nominatim_db/utils/url_utils.py [moved from src/nominatim_core/utils/url_utils.py with 87% similarity]
src/nominatim_db/version.py
test/bdd/steps/nominatim_environment.py
test/python/api/conftest.py
test/python/api/fake_adaptor.py
test/python/api/test_api_status.py
test/python/api/test_api_types.py
test/python/cli/test_cmd_import.py
test/python/cli/test_cmd_replication.py
test/python/config/test_config.py
test/python/config/test_config_load_module.py
test/python/conftest.py
test/python/db/test_async_connection.py
test/python/db/test_connection.py
test/python/db/test_properties.py
test/python/db/test_sql_preprocessor.py
test/python/db/test_status.py
test/python/db/test_utils.py
test/python/dummy_tokenizer.py
test/python/mocks.py
test/python/tokenizer/sanitizers/test_sanitizer_config.py
test/python/tokenizer/sanitizers/test_split_name_list.py
test/python/tokenizer/test_factory.py
test/python/tokenizer/test_icu.py
test/python/tokenizer/test_icu_rule_loader.py
test/python/tokenizer/test_legacy.py
test/python/tokenizer/test_place_sanitizer.py
test/python/tokenizer/token_analysis/test_analysis_postcodes.py
test/python/tokenizer/token_analysis/test_generic.py
test/python/tokenizer/token_analysis/test_generic_mutation.py
test/python/tools/test_admin.py
test/python/tools/test_database_import.py
test/python/tools/test_exec_utils.py
test/python/tools/test_import_special_phrases.py
test/python/tools/test_migration.py
test/python/tools/test_replication.py
test/python/tools/test_sp_csv_loader.py
test/python/tools/test_tiger_data.py
test/python/utils/test_centroid.py
test/python/utils/test_json_writer.py
vagrant/Install-on-Ubuntu-24.sh

index 1fa4d1b47eaed223e5123b2000b1de17dd2cee0b..01a71a3c59f6fe99bd52ba87525461398a3d76ab 100644 (file)
@@ -221,23 +221,23 @@ if (BUILD_IMPORTER)
             DESTINATION ${CMAKE_INSTALL_BINDIR}
             RENAME nominatim)
 
-    foreach (submodule nominatim_core nominatim_db nominatim_api)
+    if (EXISTS ${PHP_BIN})
+        configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
+    else()
+        configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py-no-php.tmpl paths-py.installed)
+    endif()
+
+    foreach (submodule nominatim_db nominatim_api)
         install(DIRECTORY src/${submodule}
                 DESTINATION ${NOMINATIM_LIBDIR}/lib-python
                 FILES_MATCHING PATTERN "*.py"
                 PATTERN "paths.py" EXCLUDE
                 PATTERN __pycache__ EXCLUDE)
+        install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
+                DESTINATION ${NOMINATIM_LIBDIR}/lib-python/${submodule}
+                RENAME paths.py)
     endforeach()
 
-    if (EXISTS ${PHP_BIN})
-        configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
-    else()
-        configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py-no-php.tmpl paths-py.installed)
-    endif()
-    install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
-            DESTINATION ${NOMINATIM_LIBDIR}/lib-python/nominatim_core
-            RENAME paths.py)
-
     install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
 
     install(FILES ${COUNTRY_GRID_FILE}
index 0e09a884fff15c877a170e08c4734cea88e67fe3..dae45322a0410980af4f2419065429c5ca065786 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,10 +2,10 @@ all:
 
 # Building of wheels
 
-build: build-core build-db build-api
+build: clean-build build-db build-api
 
-build-core:
-       python3 -m build packaging/nominatim-core --outdir dist/
+clean-build:
+       rm -f dist/*
 
 build-db:
        python3 -m build packaging/nominatim-db --outdir dist/
@@ -29,4 +29,4 @@ lint:
 bdd:
        cd test/bdd; behave -DREMOVE_TEMPLATE=1
 
-.PHONY: tests mypy pytest lint bdd build build-core build-db build-api
+.PHONY: tests mypy pytest lint bdd build clean-build build-db build-api
index cb0df5c140f94a79cf1157244043e8fcd1a9f161..a2f1a084c5678a0d997dc02e4abf2a3298f364d4 100644 (file)
@@ -162,7 +162,7 @@ Nominatim is easiest to run from its own virtual environment. To create one, run
 
 To install Nominatim directly from the source tree into the virtual environment, run:
 
-    /srv/nominatim-venv/bin/pip install packaging/nominatim-{core,db,api}
+    /srv/nominatim-venv/bin/pip install packaging/nominatim-{db,api}
 
 #### Building in legacy CMake mode
 
index bf093166b74efdf513c253939410436fec112f10..e13470e9fceb5a0d5a45f26cd46d2c8d46e55b39 100644 (file)
@@ -20,7 +20,7 @@ configuration parameters, see the [Configuration page](../customize/Settings.md)
 
 ## `Configuration` class
 
-::: nominatim_core.config.Configuration
+::: nominatim_api.Configuration
     options:
         members:
             - get_bool
diff --git a/packaging/nominatim-api/extra_src/paths.py b/packaging/nominatim-api/extra_src/paths.py
new file mode 100644 (file)
index 0000000..6131319
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2024 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 = None
+DATA_DIR = None
+SQLLIB_DIR = None
+CONFIG_DIR = (Path(__file__) / '..' / 'resources' / 'settings').resolve()
index 7d270021c2914d28cdec84892cbc23611f96b89e..4b268b1653661766e4cd2738e8a7558a2ba5a64e 100644 (file)
@@ -14,7 +14,8 @@ classifiers = [
     "Operating System :: OS Independent",
 ]
 dependencies = [
-    "nominatim-core",
+    "python-dotenv",
+    "pyYAML>=5.1",
     "SQLAlchemy>=1.4.31",
     "psycopg",
     "PyICU"
@@ -34,8 +35,21 @@ path = "src/nominatim_api/version.py"
 pattern = "NOMINATIM_API_VERSION = '(?P<version>[^']+)'"
 
 [tool.hatch.build.targets.sdist]
-include = ["src/nominatim_api"]
+include = [
+    "src/nominatim_api",
+    "src/nominatim_db/config.py",
+    "settings",
+    "extra_src/paths.py"
+]
+
+exclude = [
+  "src/nominatim_api/config.py"
+]
 
 [tool.hatch.build.targets.wheel]
 packages = ["src/nominatim_api"]
 
+[tool.hatch.build.targets.wheel.force-include]
+"src/nominatim_db/config.py" = "nominatim_api/config.py"
+"extra_src/paths.py" = "nominatim_api/paths.py"
+"settings" = "nominatim_api/resources/settings"
diff --git a/packaging/nominatim-core/COPYING b/packaging/nominatim-core/COPYING
deleted file mode 120000 (symlink)
index 7d29222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../COPYING
\ No newline at end of file
diff --git a/packaging/nominatim-core/README.md b/packaging/nominatim-core/README.md
deleted file mode 100644 (file)
index 127303f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-Nominatim - Core Package
-=========
-
-Nominatim is a tool to search OpenStreetMap data
-by name and address (geocoding) and to generate synthetic addresses of
-OSM points (reverse geocoding).
-
-This is the core pacakage containing resources and code shared by
-Nominatim's frontend `nominatim-api` and backend `nominatim-db`. You
-usually don't want to install this package directly.
-
-Documentation
-=============
-
-The documentation of the latest development version is in the
-`docs/` subdirectory. A HTML version can be found at
-https://nominatim.org/release-docs/develop/ .
-
-License
-=======
-
-The Python source code is available under a GPL license version 3 or later.
-The Lua configuration files for osm2pgsql are released under the
-Apache License, Version 2.0. All other files are under a GPLv2 license.
diff --git a/packaging/nominatim-core/data b/packaging/nominatim-core/data
deleted file mode 120000 (symlink)
index e67b455..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../data
\ No newline at end of file
diff --git a/packaging/nominatim-core/pyproject.toml b/packaging/nominatim-core/pyproject.toml
deleted file mode 100644 (file)
index 9c7af65..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-[project]
-name = "nominatim-core"
-description = "A tool for building a database of OpenStreetMap for geocoding and for searching the database. Base package for common resources for the project."
-readme = "README.md"
-requires-python = ">=3.7"
-license = 'GPL-3.0-or-later'
-maintainers = [
-  { name = "Sarah Hoffmann", email = "lonvia@denofr.de" }
-]
-keywords = [ "geocoding", "OpenStreetMap", "search" ]
-classifiers = [
-    "Programming Language :: Python :: 3",
-    "License :: OSI Approved :: GNU General Public License (GPL)",
-    "Operating System :: OS Independent",
-]
-dependencies = [
-    "python-dotenv",
-    "jinja2",
-    "pyYAML>=5.1",
-    "datrie"
-]
-dynamic = ["version"]
-
-[project.urls]
-Homepage = "https://nominatim.org"
-Issues = "https://github.com/osm-search/Nominatim/issues"
-
-[build-system]
-requires = ["hatchling"]
-build-backend = "hatchling.build"
-
-[tool.hatch.version]
-source = "code"
-path = "src/nominatim_core/version.py"
-expression = "NOMINATIM_CORE_VERSION"
-
-[tool.hatch.build.targets.sdist]
-include = [
-  "src/nominatim_core",
-  "lib-sql/**.sql",
-  "settings",
-  "data/words.sql",
-  "extra_src/nominatim_core/paths.py"
-]
-artifacts = [
-  "data/country_osm_grid.sql.gz"
-]
-exclude = [
-  "src/nominatim_core/paths.py"
-]
-
-[tool.hatch.build.targets.wheel]
-packages = ["src/nominatim_core"]
-
-[tool.hatch.build.targets.wheel.force-include]
-"lib-sql" = "nominatim_core/resources/lib-sql"
-"settings" = "nominatim_core/resources/settings"
-"data/country_osm_grid.sql.gz" = "nominatim_core/resources/country_osm_grid.sql.gz"
-"data/words.sql" = "nominatim_core/resources/words.sql"
-"extra_src/nominatim_core/paths.py" = "nominatim_core/paths.py"
diff --git a/packaging/nominatim-core/src b/packaging/nominatim-core/src
deleted file mode 120000 (symlink)
index 929cb3d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../src
\ No newline at end of file
diff --git a/packaging/nominatim-db/data b/packaging/nominatim-db/data
new file mode 120000 (symlink)
index 0000000..b8fb52e
--- /dev/null
@@ -0,0 +1 @@
+../../data/
\ No newline at end of file
index 312f1c8126903ab3d394e88e9e7a75a4c5546d85..69b863c2a907f0f12b808557ba1c7754552e3c9f 100644 (file)
@@ -14,8 +14,11 @@ classifiers = [
     "Operating System :: OS Independent",
 ]
 dependencies = [
-    "nominatim-core",
     "psycopg2-binary",
+    "python-dotenv",
+    "jinja2",
+    "pyYAML>=5.1",
+    "datrie",
     "psutil",
     "PyICU"
 ]
@@ -24,6 +27,7 @@ dynamic = ["version"]
 [project.urls]
 Homepage = "https://nominatim.org"
 Issues = "https://github.com/osm-search/Nominatim/issues"
+Documentation = "https://nominatim.org/release-docs/latest/"
 
 [build-system]
 requires = ["hatchling"]
@@ -34,10 +38,32 @@ path = "src/nominatim_db/version.py"
 pattern = "NOMINATIM_VERSION = parse_version.'(?P<version>[^-]+)"
 
 [tool.hatch.build.targets.sdist]
-include = ["src/nominatim_db", "scripts"]
+include = [
+    "src/nominatim_db",
+    "scripts",
+    "lib-sql/**/*.sql",
+    "settings",
+    "data/words.sql",
+    "extra_src/nominatim_db/paths.py"
+]
+
+artifacts = [
+  "data/country_osm_grid.sql.gz"
+]
+
+exclude = [
+  "src/nominatim_db/paths.py"
+]
 
 [tool.hatch.build.targets.wheel]
 packages = ["src/nominatim_db"]
 
 [tool.hatch.build.targets.wheel.shared-scripts]
 "scripts" = "/"
+
+[tool.hatch.build.targets.wheel.force-include]
+"lib-sql" = "nominatim_db/resources/lib-sql"
+"settings" = "nominatim_db/resources/settings"
+"data/country_osm_grid.sql.gz" = "nominatim_db/resources/country_osm_grid.sql.gz"
+"data/words.sql" = "nominatim_db/resources/words.sql"
+"extra_src/nominatim_db/paths.py" = "nominatim_db/paths.py"
diff --git a/packaging/nominatim-db/settings b/packaging/nominatim-db/settings
new file mode 120000 (symlink)
index 0000000..51326e6
--- /dev/null
@@ -0,0 +1 @@
+../../settings/
\ No newline at end of file
index 0f02f979d6e1c4a159d5b8bf38ecaa4af10d81ed..4f4714479a811974a7d5d290bf864c01bf81b59d 100644 (file)
@@ -14,8 +14,8 @@ import from this file, not from the source files directly.
 # See also https://github.com/PyCQA/pylint/issues/6006
 # pylint: disable=useless-import-alias
 
-from nominatim_core.errors import (UsageError as UsageError)
-from nominatim_core.config import (Configuration as Configuration)
+from .errors import (UsageError as UsageError)
+from .config import (Configuration as Configuration)
 
 from .core import (NominatimAPI as NominatimAPI,
                    NominatimAPIAsync as NominatimAPIAsync)
diff --git a/src/nominatim_api/config.py b/src/nominatim_api/config.py
new file mode 100644 (file)
index 0000000..18afda6
--- /dev/null
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2024 by the Nominatim developer community.
+# For a full list of authors see the git log.
+
+# This file is just a placeholder to make the config module available
+# during development. It will be replaced by nominatim_db/config.py on
+# installation.
+# pylint: skip-file
+from nominatim_db.config import *
index 66b00ac8138f955056d523fc23f9764f93a62b2b..167ffaa45492e9943d2f755ce3509331ebf9dd42 100644 (file)
@@ -14,9 +14,9 @@ import asyncio
 import sqlalchemy as sa
 from sqlalchemy.ext.asyncio import AsyncConnection
 
-from nominatim_core.typing import SaFromClause
-from nominatim_core.db.sqlalchemy_schema import SearchTables
-from nominatim_core.db.sqlalchemy_types import Geometry
+from .typing import SaFromClause
+from .sql.sqlalchemy_schema import SearchTables
+from .sql.sqlalchemy_types import Geometry
 from .logging import log
 
 T = TypeVar('T')
index 6f91e7a8e4a1574f8cc44d2975a9f57e609d2cf3..632c97a7a6af93d387a28bc070f22d41f67d3f33 100644 (file)
@@ -16,10 +16,10 @@ from pathlib import Path
 import sqlalchemy as sa
 import sqlalchemy.ext.asyncio as sa_asyncio
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db.sqlalchemy_schema import SearchTables
-from nominatim_core.db.async_core_library import PGCORE_LIB, PGCORE_ERROR
-from nominatim_core.config import Configuration
+from .errors import UsageError
+from .sql.sqlalchemy_schema import SearchTables
+from .sql.async_core_library import PGCORE_LIB, PGCORE_ERROR
+from .config import Configuration
 from .sql import sqlite_functions, sqlalchemy_functions #pylint: disable=unused-import
 from .connection import SearchConnection
 from .status import get_status, StatusResult
index e451edbee0a4af36e53bee3687082d1a6f6e803c..34739171d81c4ed1df37ce3c9d6a406897462b4b 100644 (file)
@@ -12,7 +12,7 @@ import datetime as dt
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaColumn, SaRow, SaSelect
+from .typing import SaColumn, SaRow, SaSelect
 from .connection import SearchConnection
 from .logging import log
 from . import types as ntyp
index 4256e0b7f8b09f770d38c944bcfd5380dfca544e..805527a7b590ba9b80c1315536fc125abd6c9051 100644 (file)
@@ -18,8 +18,8 @@ import datetime as dt
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaSelect, SaRow
-from nominatim_core.db.sqlalchemy_types import Geometry
+from .typing import SaSelect, SaRow
+from .sql.sqlalchemy_types import Geometry
 from .types import Point, Bbox, LookupDetails
 from .connection import SearchConnection
 from .logging import log
index 83b0983af62958c25f8628b90c116bdbbe091da9..20270656f949944a2a8fca6dc0b8590a8c3ec8d3 100644 (file)
@@ -12,9 +12,9 @@ import functools
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaColumn, SaSelect, SaFromClause, SaLabel, SaRow,\
-                                  SaBind, SaLambdaSelect
-from nominatim_core.db.sqlalchemy_types import Geometry
+from .typing import SaColumn, SaSelect, SaFromClause, SaLabel, SaRow,\
+                    SaBind, SaLambdaSelect
+from .sql.sqlalchemy_types import Geometry
 from .connection import SearchConnection
 from . import results as nres
 from .logging import log
index 8f674ecc9f35420d3aa15f9c6a48085b0ab78b05..95b2b4a7d8921b3daf1540db72072535c0488719 100644 (file)
@@ -12,8 +12,8 @@ import dataclasses
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaFromClause, SaColumn, SaExpression
-from nominatim_core.utils.json_writer import JsonWriter
+from ..typing import SaFromClause, SaColumn, SaExpression
+from ..utils.json_writer import JsonWriter
 from .query import Token
 from . import db_search_lookups as lookups
 
index faabd82794c0ac1979e464809815da569ab9a1ad..712cd8944706a0ec442c3763c2fa7b90c3807a14 100644 (file)
@@ -12,8 +12,8 @@ from typing import List, Any
 import sqlalchemy as sa
 from sqlalchemy.ext.compiler import compiles
 
-from nominatim_core.typing import SaFromClause
-from nominatim_core.db.sqlalchemy_types import IntArray
+from ..typing import SaFromClause
+from ..sql.sqlalchemy_types import IntArray
 
 # pylint: disable=consider-using-f-string
 
index f5c431460d6a34677d37c645e32c047c60c753ac..35c063fc937701dc4086eb677e826c671a3b7ac4 100644 (file)
@@ -12,9 +12,9 @@ import abc
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaFromClause, SaScalarSelect, SaColumn, \
-                                  SaExpression, SaSelect, SaLambdaSelect, SaRow, SaBind
-from nominatim_core.db.sqlalchemy_types import Geometry, IntArray
+from ..typing import SaFromClause, SaScalarSelect, SaColumn, \
+                     SaExpression, SaSelect, SaLambdaSelect, SaRow, SaBind
+from ..sql.sqlalchemy_types import Geometry, IntArray
 from ..connection import SearchConnection
 from ..types import SearchDetails, DataLayer, GeometryFormat, Bbox
 from .. import results as nres
index 426656797c873b2a4419c3913d4ac3f66d5c4610..971e95beec1a6935b58e7c9cc4879d9797a73f1b 100644 (file)
@@ -16,8 +16,8 @@ from icu import Transliterator
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaRow
-from nominatim_core.db.sqlalchemy_types import Json
+from ..typing import SaRow
+from ..sql.sqlalchemy_types import Json
 from ..connection import SearchConnection
 from ..logging import log
 from ..search import query as qmod
index b49d3ae6b200832b2fcce1f81f997c16d7776827..ecb0bbfe50def7d1cb632a417df57df498d709a7 100644 (file)
@@ -14,7 +14,7 @@ import dataclasses
 
 import sqlalchemy as sa
 
-from nominatim_core.typing import SaRow
+from ..typing import SaRow
 from ..connection import SearchConnection
 from ..logging import log
 from . import query as qmod
index 851b096437d4d5730ed2e7c4f5da9f60d1caf8c6..bc9850b242e9fb9545aeadbf2b16b76bf36d0274 100644 (file)
@@ -14,7 +14,7 @@ import asyncio
 
 from falcon.asgi import App, Request, Response
 
-from nominatim_core.config import Configuration
+from ...config import Configuration
 from ...core import NominatimAPIAsync
 from ... import v1 as api_impl
 from ... import logging as loglib
index dd35cd6e9e55072408bd77ed23636ed1c3d90fd0..5f5cf055072a4250c4adf619e86570f55901019b 100644 (file)
@@ -21,7 +21,7 @@ from starlette.middleware import Middleware
 from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
 from starlette.middleware.cors import CORSMiddleware
 
-from nominatim_core.config import Configuration
+from ...config import Configuration
 from ...core import NominatimAPIAsync
 from ... import v1 as api_impl
 from ... import logging as loglib
index 402027493f086645e1b572411127e08f33f509db..7abe7d3f33ac12dd9e89a6dabcebd812ece6d6d5 100644 (file)
@@ -13,7 +13,7 @@ from typing import Any
 import sqlalchemy as sa
 from sqlalchemy.ext.compiler import compiles
 
-from nominatim_core.typing import SaColumn
+from ..typing import SaColumn
 
 # pylint: disable=all
 
index 614789ed4ec568e4f0b8b4511ec62f2e97435d55..ea88a467d08b0646a0c3a1226309a9284326d2f1 100644 (file)
@@ -14,7 +14,7 @@ import dataclasses
 import sqlalchemy as sa
 
 from .connection import SearchConnection
-from .version import NOMINATIM_API_VERSION, NominatimVersion, parse_version
+from .version import NOMINATIM_API_VERSION
 
 @dataclasses.dataclass
 class StatusResult:
@@ -24,7 +24,7 @@ class StatusResult:
     message: str
     software_version = NOMINATIM_API_VERSION
     data_updated: Optional[dt.datetime] = None
-    database_version: Optional[NominatimVersion] = None
+    database_version: Optional[str] = None
 
 
 async def get_status(conn: SearchConnection) -> StatusResult:
@@ -44,7 +44,7 @@ async def get_status(conn: SearchConnection) -> StatusResult:
 
     # Database version
     try:
-        status.database_version = parse_version(await conn.get_property('database_version'))
+        status.database_version = await conn.get_property('database_version')
     except ValueError:
         pass
 
index f2ad4f356e0c5c8e2ecf0029d4da4b234dd76250..6c8adeb82603dda3845b80584c10a5babfdd9da7 100644 (file)
@@ -16,7 +16,7 @@ import math
 from struct import unpack
 from binascii import unhexlify
 
-from nominatim_core.errors import UsageError
+from .errors import UsageError
 from .localization import Locales
 
 # pylint: disable=no-member,too-many-boolean-expressions,too-many-instance-attributes
diff --git a/src/nominatim_api/typing.py b/src/nominatim_api/typing.py
new file mode 100644 (file)
index 0000000..ba0d95b
--- /dev/null
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2024 by the Nominatim developer community.
+# For a full list of authors see the git log.
+"""
+Type definitions for typing annotations.
+
+Complex type definitions are moved here, to keep the source files readable.
+"""
+from typing import Union, TYPE_CHECKING
+
+# pylint: disable=missing-class-docstring,useless-import-alias
+
+# SQLAlchemy introduced generic types in version 2.0 making typing
+# incompatible with older versions. Add wrappers here so we don't have
+# to litter the code with bare-string types.
+
+if TYPE_CHECKING:
+    from typing import Any
+    import sqlalchemy as sa
+    import os
+    from typing_extensions import (TypeAlias as TypeAlias)
+else:
+    TypeAlias = str
+
+StrPath = Union[str, 'os.PathLike[str]']
+
+SaLambdaSelect: TypeAlias = 'Union[sa.Select[Any], sa.StatementLambdaElement]'
+SaSelect: TypeAlias = 'sa.Select[Any]'
+SaScalarSelect: TypeAlias = 'sa.ScalarSelect[Any]'
+SaRow: TypeAlias = 'sa.Row[Any]'
+SaColumn: TypeAlias = 'sa.ColumnElement[Any]'
+SaExpression: TypeAlias = 'sa.ColumnElement[bool]'
+SaLabel: TypeAlias = 'sa.Label[Any]'
+SaFromClause: TypeAlias = 'sa.FromClause'
+SaSelectable: TypeAlias = 'sa.Selectable'
+SaBind: TypeAlias = 'sa.BindParameter[Any]'
+SaDialect: TypeAlias = 'sa.Dialect'
index d8faa482c3cbf609c1b0e11c78d2b8d9a648f42e..e74b61e1cc7fd92a0b505163abc5f07980e5b52e 100644 (file)
@@ -11,7 +11,7 @@ from typing import List, Dict, Mapping, Any
 import collections
 import datetime as dt
 
-from nominatim_core.utils.json_writer import JsonWriter
+from ..utils.json_writer import JsonWriter
 from ..status import StatusResult
 from ..results import DetailedResult, ReverseResults, SearchResults, \
                       AddressLines, AddressLine
index 2c50dec42578d144fe794be67b31045c554c7b92..34bb777a2f206de64c55ca36c07dbb94819ed26f 100644 (file)
@@ -9,7 +9,7 @@ Helper functions for output of results in json formats.
 """
 from typing import Mapping, Any, Optional, Tuple, Union
 
-from nominatim_core.utils.json_writer import JsonWriter
+from ..utils.json_writer import JsonWriter
 from ..results import AddressLines, ReverseResults, SearchResults
 from . import classtypes as cl
 
index 67def74e135adbcf5a6c515560af1620dca01be6..c00b580bde0d9cb722144856ec10fb5d6b50b4b7 100644 (file)
@@ -17,8 +17,8 @@ from urllib.parse import urlencode
 
 import sqlalchemy as sa
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
+from ..errors import UsageError
+from ..config import Configuration
 from .. import logging as loglib
 from ..core import NominatimAPIAsync
 from .format import dispatch as formatting
index 5dd084c7f8f1913426b7cfe3bd221f50f14c2c32..d275f4fc314d741daf12bc619305c81950274efc 100644 (file)
@@ -8,10 +8,4 @@
 Version information for the Nominatim API.
 """
 
-# See also https://github.com/PyCQA/pylint/issues/6006
-# pylint: disable=useless-import-alias,unused-import
-
-from nominatim_core.version import (NominatimVersion as NominatimVersion,
-                                    parse_version as parse_version)
-
 NOMINATIM_API_VERSION = '4.4.99'
diff --git a/src/nominatim_core/py.typed b/src/nominatim_core/py.typed
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/nominatim_core/version.py b/src/nominatim_core/version.py
deleted file mode 100644 (file)
index 91193fa..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# This file is part of Nominatim. (https://nominatim.org)
-#
-# Copyright (C) 2024 by the Nominatim developer community.
-# For a full list of authors see the git log.
-"""
-Version information for the Nominatim core package.
-"""
-from typing import NamedTuple, Optional
-
-__version__ = '4.4.99'
-NOMINATIM_CORE_VERSION = __version__
-
-class NominatimVersion(NamedTuple):
-    """ Version information for Nominatim. We follow semantic versioning.
-
-        Major, minor and patch_level refer to the last released version.
-        The database patch level tracks important changes between releases
-        and must always be increased when there is a change to the database or code
-        that requires a migration.
-
-        When adding a migration on the development branch, raise the patch level
-        to 99 to make sure that the migration is applied when updating from a
-        patch release to the next minor version. Patch releases usually shouldn't
-        have migrations in them. When they are needed, then make sure that the
-        migration can be reapplied and set the migration version to the appropriate
-        patch level when cherry-picking the commit with the migration.
-    """
-
-    major: int
-    minor: int
-    patch_level: int
-    db_patch_level: Optional[int]
-
-    def __str__(self) -> str:
-        if self.db_patch_level is None:
-            return f"{self.major}.{self.minor}.{self.patch_level}"
-
-        return f"{self.major}.{self.minor}.{self.patch_level}-{self.db_patch_level}"
-
-    def release_version(self) -> str:
-        """ Return the release version in semantic versioning format.
-
-            The release version does not include the database patch version.
-        """
-        return f"{self.major}.{self.minor}.{self.patch_level}"
-
-
-def parse_version(version: str) -> NominatimVersion:
-    """ Parse a version string into a version consisting of a tuple of
-        four ints: major, minor, patch level, database patch level
-
-        This is the reverse operation of `version_str()`.
-    """
-    parts = version.split('.')
-    return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])
index 8a85e0e25b9c92fe8efeab272df1a5ae9091c8c2..41684fa1dbe9e37bf9c1d3e1a2c9ded9e7767715 100644 (file)
@@ -16,8 +16,8 @@ import sys
 import argparse
 from pathlib import Path
 
-from nominatim_core.config import Configuration
-from nominatim_core.errors import UsageError
+from .config import Configuration
+from .errors import UsageError
 from .tools.exec_utils import run_php_server
 from . import clicmd
 from . import version
index 7b97557d5925187ab795dca0e43d110f2690e0bf..7744595bbd3f99b449e0ea09a1e4ba2840edf710 100644 (file)
@@ -11,8 +11,8 @@ import logging
 import argparse
 import random
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db.connection import connect
+from ..errors import UsageError
+from ..db.connection import connect
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index 25b4bff35a33d7f8e7c294f9ba1491e23ef5f8cc..fac88bdd34a2684683e0313465699cab5af9bd7e 100644 (file)
@@ -14,12 +14,12 @@ import json
 import sys
 from functools import reduce
 
-from nominatim_core.errors import UsageError
 import nominatim_api as napi
 import nominatim_api.v1 as api_output
 from nominatim_api.v1.helpers import zoom_to_rank, deduplicate_results
 from nominatim_api.v1.format import dispatch as formatting
 import nominatim_api.logging as loglib
+from ..errors import UsageError
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index 857cb55efbf197b2523e243c9876e1027d9888ec..6a11b089eb40e5650cdb2409a012d0a049ed8221 100644 (file)
@@ -12,9 +12,9 @@ import argparse
 import logging
 from pathlib import Path
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
-from nominatim_core.typing import Protocol
+from ..errors import UsageError
+from ..config import Configuration
+from ..typing import Protocol
 
 LOG = logging.getLogger()
 
index 51db848c068711d739b902d64f18e3e451ff38dd..1468b7829f560356736c9fe3687c133e2edb7b17 100644 (file)
@@ -12,7 +12,7 @@ import argparse
 import asyncio
 from pathlib import Path
 
-from nominatim_core.errors import UsageError
+from ..errors import UsageError
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index 460d27d656a533374e85d81dbf262fc1c948f5dd..93f63980b9dec111a99fd4d9c29b65b4642c0dca 100644 (file)
@@ -14,12 +14,13 @@ import asyncio
 import csv
 import sys
 
-import sqlalchemy as sa
-
 import nominatim_api as napi
 from nominatim_api.results import create_from_placex_row, ReverseResult, add_result_details
 from nominatim_api.types import LookupDetails
-from nominatim_core.errors import UsageError
+
+import sqlalchemy as sa # pylint: disable=C0411
+
+from ..errors import UsageError
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index 83b84b17fd498d4ce904664fbb89038e5b90378d..27562ccc81802efbecfcd75131321b7bf4fde50f 100644 (file)
@@ -9,7 +9,7 @@ Implementation of the 'freeze' subcommand.
 """
 import argparse
 
-from nominatim_core.db.connection import connect
+from ..db.connection import connect
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index 7766a1d10b4f3a7e9cb968194495bba1092aedac..87e0fc0333270d586140b9e255ee27fe737cfb86 100644 (file)
@@ -11,8 +11,8 @@ import argparse
 
 import psutil
 
-from nominatim_core.db import status
-from nominatim_core.db.connection import connect
+from ..db import status
+from ..db.connection import connect
 from .args import NominatimArgs
 
 # Do not repeat documentation of subcommand classes.
index ceead2583f82d9563ee38fd1ee6dfefde8c46ba7..d5acf54b3a36a0e8b0832081a436ed4ce62c586f 100644 (file)
@@ -12,8 +12,8 @@ import argparse
 import logging
 from pathlib import Path
 
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect
+from ..config import Configuration
+from ..db.connection import connect
 from ..tokenizer.base import AbstractTokenizer
 from .args import NominatimArgs
 
index 6fc4dc302a0921cb86fd844a8d52aca0dda65329..f04c730f2d5d917d8bb113930e03a3b68531e1c1 100644 (file)
@@ -14,9 +14,9 @@ import logging
 import socket
 import time
 
-from nominatim_core.db import status
-from nominatim_core.db.connection import connect
-from nominatim_core.errors import UsageError
+from ..db import status
+from ..db.connection import connect
+from ..errors import UsageError
 from .args import NominatimArgs
 
 LOG = logging.getLogger()
index af586d49f17eaf3b6c36df205dda66897c0df5af..f516ba0c0db7248bdc09d0c2a014ed7081c9b050 100644 (file)
@@ -14,10 +14,10 @@ from pathlib import Path
 
 import psutil
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect
-from nominatim_core.db import status, properties
+from ..errors import UsageError
+from ..config import Configuration
+from ..db.connection import connect
+from ..db import status, properties
 from ..tokenizer.base import AbstractTokenizer
 from ..version import NOMINATIM_VERSION
 from .args import NominatimArgs
index 1e0f2d764c75bf797253af9978eeec1c7f8d33ad..660859421b28ba000a4ae977afda6bd60bd6d61b 100644 (file)
@@ -11,8 +11,8 @@ import argparse
 import logging
 from pathlib import Path
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db.connection import connect
+from ..errors import UsageError
+from ..db.connection import connect
 from ..tools.special_phrases.sp_importer import SPImporter, SpecialPhraseLoader
 from ..tools.special_phrases.sp_wiki_loader import SPWikiLoader
 from ..tools.special_phrases.sp_csv_loader import SPCsvLoader
similarity index 98%
rename from src/nominatim_core/config.py
rename to src/nominatim_db/config.py
index f4c925eb48636a2bf37ec693655646bcadb0cfa3..c4264f0d68ef17c0a182a1063c0a970862cf5aec 100644 (file)
@@ -17,7 +17,11 @@ import json
 import yaml
 
 from dotenv import dotenv_values
-from psycopg2.extensions import parse_dsn
+
+try:
+    from psycopg2.extensions import parse_dsn
+except ModuleNotFoundError:
+    from psycopg.conninfo import conninfo_to_dict as parse_dsn # type: ignore[assignment]
 
 from .typing import StrPath
 from .errors import UsageError
index 35943a50d3ed08cf0a46a7658fafeffac0db2674..c8002ee7023ca27a9e680003e92a66e3d8f0b428 100644 (file)
@@ -11,10 +11,10 @@ from typing import Dict, Any, Iterable, Tuple, Optional, Container, overload
 from pathlib import Path
 import psycopg2.extras
 
-from nominatim_core.db import utils as db_utils
-from nominatim_core.db.connection import connect, Connection
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
+from ..db import utils as db_utils
+from ..db.connection import connect, Connection
+from ..errors import UsageError
+from ..config import Configuration
 from ..tokenizer.base import AbstractTokenizer
 
 def _flatten_name_list(names: Any) -> Dict[str, str]:
index 670827ee4cf7e42e5f8a55b1e802385156dc761a..0d04826d944692992b84bbdde260a27a31bf168f 100644 (file)
@@ -11,7 +11,7 @@ format.
 from typing import Any, Mapping, Optional, Set, Match
 import re
 
-from nominatim_core.errors import UsageError
+from ..errors import UsageError
 from . import country_info
 
 class CountryPostcodeMatcher:
diff --git a/src/nominatim_db/errors.py b/src/nominatim_db/errors.py
new file mode 100644 (file)
index 0000000..c7331a8
--- /dev/null
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2024 by the Nominatim developer community.
+# For a full list of authors see the git log.
+"""
+Custom exception and error classes for Nominatim.
+"""
+
+class UsageError(Exception):
+    """ An error raised because of bad user input. This error will usually
+        not cause a stack trace to be printed unless debugging is enabled.
+    """
index 4f9c05755414f123ac619df0a17002decbce3855..5a219f6b2ecc3904b1129c9b4f9cff92c12132a5 100644 (file)
@@ -13,9 +13,9 @@ import time
 
 import psycopg2.extras
 
-from nominatim_core.typing import DictCursorResults
-from nominatim_core.db.async_connection import DBConnection, WorkerPool
-from nominatim_core.db.connection import connect, Connection, Cursor
+from ..typing import DictCursorResults
+from ..db.async_connection import DBConnection, WorkerPool
+from ..db.connection import connect, Connection, Cursor
 from ..tokenizer.base import AbstractTokenizer
 from .progress import ProgressLogger
 from . import runners
index 4d6a28e4de64540f72fd68e748d46362bee89c01..7b98e2401beab3b820941d76218b1137f8afb97f 100644 (file)
@@ -14,8 +14,8 @@ import functools
 from psycopg2 import sql as pysql
 import psycopg2.extras
 
-from nominatim_core.typing import Query, DictCursorResult, DictCursorResults, Protocol
-from nominatim_core.db.async_connection import DBConnection
+from ..typing import Query, DictCursorResult, DictCursorResults, Protocol
+from ..db.async_connection import DBConnection
 from ..data.place_info import PlaceInfo
 from ..tokenizer.base import AbstractAnalyzer
 
index 0ca7e1d19f6723af08af9f0c561aad84f31453df..d3aeeacac628afd19fdd5cff9e6bc3dbb61419a9 100644 (file)
@@ -12,9 +12,9 @@ from abc import ABC, abstractmethod
 from typing import List, Tuple, Dict, Any, Optional, Iterable
 from pathlib import Path
 
-from nominatim_core.typing import Protocol
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import Connection
+from ..typing import Protocol
+from ..config import Configuration
+from ..db.connection import Connection
 from ..data.place_info import PlaceInfo
 
 class AbstractAnalyzer(ABC):
index 1193f49919b3c7209b7476ef9681760adf86db26..b9022d8d0105f3234f7283b0fa9c89286021da1f 100644 (file)
@@ -24,10 +24,10 @@ import logging
 import importlib
 from pathlib import Path
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db import properties
-from nominatim_core.db.connection import connect
-from nominatim_core.config import Configuration
+from ..errors import UsageError
+from ..db import properties
+from ..db.connection import connect
+from ..config import Configuration
 from ..tokenizer.base import AbstractTokenizer, TokenizerModule
 
 LOG = logging.getLogger()
index 500683e549aa3c290cba1f101c501d183d8c65b0..0aca2921b966848d87a9e30146592fbe1f104a42 100644 (file)
@@ -14,10 +14,10 @@ import logging
 
 from icu import Transliterator
 
-from nominatim_core.config import flatten_config_list, Configuration
-from nominatim_core.db.properties import set_property, get_property
-from nominatim_core.db.connection import Connection
-from nominatim_core.errors import UsageError
+from ..config import flatten_config_list, Configuration
+from ..db.properties import set_property, get_property
+from ..db.connection import Connection
+from ..errors import UsageError
 from .place_sanitizer import PlaceSanitizer
 from .icu_token_analysis import ICUTokenAnalysis
 from .token_analysis.base import AnalysisModule, Analyzer
index af03bd39811a7ce327f5b154c17e21b0b6698b6c..22e2d048291bcaa6d566e0f5fd3cf92fe9fcf870 100644 (file)
@@ -16,10 +16,10 @@ import logging
 from pathlib import Path
 from textwrap import dedent
 
-from nominatim_core.db.connection import connect, Connection, Cursor
-from nominatim_core.config import Configuration
-from nominatim_core.db.utils import CopyBuffer
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from ..db.connection import connect, Connection, Cursor
+from ..config import Configuration
+from ..db.utils import CopyBuffer
+from ..db.sql_preprocessor import SQLPreprocessor
 from ..data.place_info import PlaceInfo
 from ..data.place_name import PlaceName
 from .icu_rule_loader import ICURuleLoader
index 5c6ba7434d45c66f719af254a7cf895dfe5dd9fb..136a733159cd3180e2e0558e48b97141887165c1 100644 (file)
@@ -20,12 +20,12 @@ from icu import Transliterator
 import psycopg2
 import psycopg2.extras
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db.connection import connect, Connection
-from nominatim_core.config import Configuration
-from nominatim_core.db import properties
-from nominatim_core.db import utils as db_utils
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from ..errors import UsageError
+from ..db.connection import connect, Connection
+from ..config import Configuration
+from ..db import properties
+from ..db import utils as db_utils
+from ..db.sql_preprocessor import SQLPreprocessor
 from ..data.place_info import PlaceInfo
 from .base import AbstractAnalyzer, AbstractTokenizer
 
index 546d0da33c4b9ecb16844f099179c935f3ce5fa0..68322f9fd5cdf5c488d0f2dca322d31d7ba1c5f6 100644 (file)
@@ -10,8 +10,8 @@ is handed to the token analysis.
 """
 from typing import Optional, List, Mapping, Sequence, Callable, Any, Tuple
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
+from ..errors import UsageError
+from ..config import Configuration
 from .sanitizers.config import SanitizerConfig
 from .sanitizers.base import SanitizerHandler, ProcessInfo
 from ..data.place_name import PlaceName
index a28f86b503ac047fa555a2d4a78a73d1c2bcbe58..2dbc4482556f75b0df691b819675ae5540a23c35 100644 (file)
@@ -9,7 +9,7 @@ Common data types and protocols for sanitizers.
 """
 from typing import Optional, List, Mapping, Callable
 
-from nominatim_core.typing import Protocol, Final
+from ...typing import Protocol, Final
 from ...data.place_info import PlaceInfo
 from ...data.place_name import PlaceName
 from .config import SanitizerConfig
index 1ce1a1b72a995095f35e2cb930d67025fa3b552a..034d0791ed56ef6e22c6b72f99ce23bc3953b1b5 100644 (file)
@@ -11,7 +11,7 @@ from typing import Sequence, Union, Optional, Pattern, Callable, Any, TYPE_CHECK
 from collections import UserDict
 import re
 
-from nominatim_core.errors import UsageError
+from ...errors import UsageError
 
 # working around missing generics in Python < 3.8
 # See https://github.com/python/typing/issues/60#issuecomment-869757075
index fc6734911f42dd2e1dc53343c2ef5dbb6bd2504b..9435edb3b562442a6c5369888390453137bdd828 100644 (file)
@@ -9,7 +9,7 @@ Common data types and protocols for analysers.
 """
 from typing import Mapping, List, Any
 
-from nominatim_core.typing import Protocol
+from ...typing import Protocol
 from ...data.place_name import PlaceName
 
 class Analyzer(Protocol):
index b455a8a5dfdbaa8d8081f9db96ca08dafe6ffb62..aff360afa62f917d80afadb7786cf1f55d2441eb 100644 (file)
@@ -12,8 +12,8 @@ from collections import defaultdict
 import itertools
 import re
 
-from nominatim_core.config import flatten_config_list
-from nominatim_core.errors import UsageError
+from ...config import flatten_config_list
+from ...errors import UsageError
 
 class ICUVariant(NamedTuple):
     """ A single replacement rule for variant creation.
index cd649e62f54a4fd37a430a7d1822b99d89aeba40..30f1944e569bc732bcdb282012ee0dda4042a846 100644 (file)
@@ -12,7 +12,7 @@ import itertools
 
 import datrie
 
-from nominatim_core.errors import UsageError
+from ...errors import UsageError
 from ...data.place_name import PlaceName
 from .config_variants import get_variant_config
 from .generic_mutation import MutationVariantGenerator
index 03cc63db0a7acbbdfce2cd22e75ecb86f8e6f490..be70b49dcd89841a86e9f3ac6f001309d7554a37 100644 (file)
@@ -12,7 +12,7 @@ import itertools
 import logging
 import re
 
-from nominatim_core.errors import UsageError
+from ...errors import UsageError
 
 LOG = logging.getLogger()
 
index 44ff21975d6e60332ba28c3e85dcad61e23040a6..f9e2e6486f400814a2553aa40942fae49a22f061 100644 (file)
@@ -12,8 +12,8 @@ from pathlib import Path
 import logging
 import urllib
 
-from nominatim_core.db.connection import connect
-from nominatim_core.utils.url_utils import get_url
+from ..db.connection import connect
+from ..utils.url_utils import get_url
 from .exec_utils import run_osm2pgsql
 
 LOG = logging.getLogger()
index 7cc0f04794e306b076f36ea4a6ba6683a1b16248..cea2ad664a7e339c2c66dd23790ab517dcd7b338 100644 (file)
@@ -13,10 +13,10 @@ import logging
 from psycopg2.extras import Json, register_hstore
 from psycopg2 import DataError
 
-from nominatim_core.typing import DictCursorResult
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect, Cursor
-from nominatim_core.errors import UsageError
+from ..typing import DictCursorResult
+from ..config import Configuration
+from ..db.connection import connect, Cursor
+from ..errors import UsageError
 from ..tokenizer import factory as tokenizer_factory
 from ..data.place_info import PlaceInfo
 
index d2659877c50ca93e922d5e83ce6732b28f251168..ef28a0e5a61653b6a2f2c250137050130caff084 100644 (file)
@@ -11,10 +11,10 @@ from typing import Callable, Optional, Any, Union, Tuple, Mapping, List
 from enum import Enum
 from textwrap import dedent
 
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect, Connection
-from nominatim_core.db import properties
-from nominatim_core.errors import UsageError
+from ..config import Configuration
+from ..db.connection import connect, Connection
+from ..db import properties
+from ..errors import UsageError
 from ..tokenizer import factory as tokenizer_factory
 from . import freeze
 from ..version import NOMINATIM_VERSION, parse_version
index 5096ce69ebcfabbe406e178c0907d08cd47b64c8..e1f8b16637a4cd02de87fb582f8932b8695cd1b1 100644 (file)
@@ -17,8 +17,8 @@ from typing import List, Optional, Tuple, Union
 import psutil
 from psycopg2.extensions import make_dsn, parse_dsn
 
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect
+from ..config import Configuration
+from ..db.connection import connect
 from ..version import NOMINATIM_VERSION
 
 
index 47ab63b718f872a121cffd2ca5173915c64d93da..2377abc0b2be5dde5913a742eb5d5af7eac118f1 100644 (file)
@@ -16,8 +16,8 @@ import sqlalchemy as sa
 
 import nominatim_api as napi
 from nominatim_api.search.query_analyzer_factory import make_query_analyzer
-from nominatim_core.typing import SaSelect, SaRow
-from nominatim_core.db.sqlalchemy_types import Geometry, IntArray
+from nominatim_api.typing import SaSelect, SaRow
+from nominatim_api.sql.sqlalchemy_types import Geometry, IntArray
 
 LOG = logging.getLogger()
 
index 84f2f32542680d5510373ebfd3bffc36c14a259a..d07febc8a3da97fc5e41b8b243e3e8ba0f703de1 100644 (file)
@@ -17,11 +17,11 @@ from pathlib import Path
 import psutil
 from psycopg2 import sql as pysql
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect, get_pg_env, Connection
-from nominatim_core.db.async_connection import DBConnection
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from ..errors import UsageError
+from ..config import Configuration
+from ..db.connection import connect, get_pg_env, Connection
+from ..db.async_connection import DBConnection
+from ..db.sql_preprocessor import SQLPreprocessor
 from .exec_utils import run_osm2pgsql
 from ..version import POSTGRESQL_REQUIRED_VERSION, POSTGIS_REQUIRED_VERSION
 
index 467347f87127f57089540216630c4f916c113e24..406e2511e80b18741279f59069d10398b48139a2 100644 (file)
@@ -13,8 +13,8 @@ import os
 import subprocess
 import shutil
 
-from nominatim_core.typing import StrPath
-from nominatim_core.db.connection import get_pg_env
+from ..typing import StrPath
+from ..db.connection import get_pg_env
 
 LOG = logging.getLogger()
 
index 2023bb8ac44833664afcfec87535f38041cecba6..bd52ba9a5a7ad194c353a721d1529ea4cefa20cb 100644 (file)
@@ -12,7 +12,7 @@ from pathlib import Path
 
 from psycopg2 import sql as pysql
 
-from nominatim_core.db.connection import Connection
+from ..db.connection import Connection
 
 UPDATE_TABLES = [
     'address_levels',
index 0712f187ff51dd1b659b2995c3789387d5b2b75b..e6803c7dea23521a805aa939584d028f66b4a7b5 100644 (file)
@@ -12,10 +12,10 @@ import logging
 
 from psycopg2 import sql as pysql
 
-from nominatim_core.errors import UsageError
-from nominatim_core.config import Configuration
-from nominatim_core.db import properties
-from nominatim_core.db.connection import connect, Connection
+from ..errors import UsageError
+from ..config import Configuration
+from ..db import properties
+from ..db.connection import connect, Connection
 from ..version import NominatimVersion, NOMINATIM_VERSION, parse_version
 from ..tokenizer import factory as tokenizer_factory
 from . import refresh
index 772651b37d49de89ace4453f11577f9ed0ae3567..8dc5bdbdb43cacb46fec70a86d553734a4ef92d7 100644 (file)
@@ -18,8 +18,8 @@ from math import isfinite
 
 from psycopg2 import sql as pysql
 
-from nominatim_core.db.connection import connect, Connection
-from nominatim_core.utils.centroid import PointsCentroid
+from ..db.connection import connect, Connection
+from ..utils.centroid import PointsCentroid
 from ..data.postcode_format import PostcodeFormatter, CountryPostcodeMatcher
 from ..tokenizer.base import AbstractAnalyzer, AbstractTokenizer
 
index 966080976febd42b35ef8dee293aa52df4a72628..6946a41a441ad7447cab6e0c405e8e45b8bae063 100644 (file)
@@ -16,10 +16,10 @@ from pathlib import Path
 
 from psycopg2 import sql as pysql
 
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import Connection, connect
-from nominatim_core.db.utils import execute_file, CopyBuffer
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from ..config import Configuration
+from ..db.connection import Connection, connect
+from ..db.utils import execute_file, CopyBuffer
+from ..db.sql_preprocessor import SQLPreprocessor
 from ..version import NOMINATIM_VERSION
 
 LOG = logging.getLogger()
index f9421bb88e2cd5b5023aa2ebdffb0fc2308c4a26..bf1189df032a85a40a985c20e783edfd74410e29 100644 (file)
@@ -18,9 +18,9 @@ import urllib.request as urlrequest
 
 import requests
 
-from nominatim_core.errors import UsageError
-from nominatim_core.db import status
-from nominatim_core.db.connection import Connection, connect
+from ..errors import UsageError
+from ..db import status
+from ..db.connection import Connection, connect
 from .exec_utils import run_osm2pgsql
 
 try:
index 9f472e682f37085775bd73b7fb1d3dbdebe1083b..db4806cdd034838065b5da62ed4864663345d4ac 100644 (file)
@@ -13,7 +13,7 @@ from typing import Iterable
 import csv
 import os
 
-from nominatim_core.errors import UsageError
+from ...errors import UsageError
 from .special_phrase import SpecialPhrase
 
 class SPCsvLoader:
index 9749db3e69761b9e0517eb1f17528b00ca9f9332..1bdcdaf133d5d3db10fdb18e23c2b3f6ea24abce 100644 (file)
@@ -19,9 +19,9 @@ import re
 
 from psycopg2.sql import Identifier, SQL
 
-from nominatim_core.typing import Protocol
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import Connection
+from ...typing import Protocol
+from ...config import Configuration
+from ...db.connection import Connection
 from .importer_statistics import SpecialPhrasesImporterStatistics
 from .special_phrase import SpecialPhrase
 from ...tokenizer.base import AbstractTokenizer
index c7e383360639f2b435973edf52588fb1da6fd873..0fe7c0aa4ff9b69fb7e400bfbf54e09398297db7 100644 (file)
@@ -11,8 +11,8 @@ from typing import Iterable
 import re
 import logging
 
-from nominatim_core.config import Configuration
-from nominatim_core.utils.url_utils import get_url
+from ...config import Configuration
+from ...utils.url_utils import get_url
 from .special_phrase import SpecialPhrase
 
 LOG = logging.getLogger()
index 6030a38aef8fdf63f73a699a59bf00fa7647bb83..7c52b7102a68707f4764a129957e84b71aab2f69 100644 (file)
@@ -16,11 +16,11 @@ import tarfile
 
 from psycopg2.extras import Json
 
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import connect
-from nominatim_core.db.async_connection import WorkerPool
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
-from nominatim_core.errors import UsageError
+from ..config import Configuration
+from ..db.connection import connect
+from ..db.async_connection import WorkerPool
+from ..db.sql_preprocessor import SQLPreprocessor
+from ..errors import UsageError
 from ..data.place_info import PlaceInfo
 from ..tokenizer.base import AbstractAnalyzer, AbstractTokenizer
 from . import freeze
similarity index 65%
rename from src/nominatim_core/typing.py
rename to src/nominatim_db/typing.py
index 1f4f1fd7d2b8ba6c432001f4e3b57b6adab59f9b..f1abee8280691ea9e5737a9a46553b81e2edc01b 100644 (file)
@@ -50,26 +50,3 @@ else:
     Protocol = object
     Final = 'Final'
     TypedDict = dict
-
-
-# SQLAlchemy introduced generic types in version 2.0 making typing
-# incompatible with older versions. Add wrappers here so we don't have
-# to litter the code with bare-string types.
-
-if TYPE_CHECKING:
-    import sqlalchemy as sa
-    from typing_extensions import (TypeAlias as TypeAlias)
-else:
-    TypeAlias = str
-
-SaLambdaSelect: TypeAlias = 'Union[sa.Select[Any], sa.StatementLambdaElement]'
-SaSelect: TypeAlias = 'sa.Select[Any]'
-SaScalarSelect: TypeAlias = 'sa.ScalarSelect[Any]'
-SaRow: TypeAlias = 'sa.Row[Any]'
-SaColumn: TypeAlias = 'sa.ColumnElement[Any]'
-SaExpression: TypeAlias = 'sa.ColumnElement[bool]'
-SaLabel: TypeAlias = 'sa.Label[Any]'
-SaFromClause: TypeAlias = 'sa.FromClause'
-SaSelectable: TypeAlias = 'sa.Selectable'
-SaBind: TypeAlias = 'sa.BindParameter[Any]'
-SaDialect: TypeAlias = 'sa.Dialect'
similarity index 87%
rename from src/nominatim_core/utils/url_utils.py
rename to src/nominatim_db/utils/url_utils.py
index d7689187a1d209ecaf093c423c867f9583306a0e..eb56f72ed3a9cf92c02619040e1a0801e12df9ee 100644 (file)
@@ -11,7 +11,7 @@ from typing import IO
 import logging
 import urllib.request as urlrequest
 
-from ..version import NOMINATIM_CORE_VERSION
+from ..version import NOMINATIM_VERSION
 
 LOG = logging.getLogger()
 
@@ -20,7 +20,7 @@ def get_url(url: str) -> str:
 
         This version makes sure that an appropriate user agent is sent.
     """
-    headers = {"User-Agent": f"Nominatim/{NOMINATIM_CORE_VERSION!s}"}
+    headers = {"User-Agent": f"Nominatim/{NOMINATIM_VERSION!s}"}
 
     try:
         request = urlrequest.Request(url, headers=headers)
index 34e3b432e37e4623c52ab1fece54078f62ccd1ab..70e1ac14ac9a6bc13969ea0e0f059ceb0b078f6c 100644 (file)
@@ -7,13 +7,55 @@
 """
 Version information for Nominatim.
 """
-from typing import Optional
+from typing import NamedTuple, Optional
 
 # See also https://github.com/PyCQA/pylint/issues/6006
 # pylint: disable=useless-import-alias,unused-import
 
-from nominatim_core.version import (NominatimVersion as NominatimVersion,
-                                    parse_version as parse_version)
+class NominatimVersion(NamedTuple):
+    """ Version information for Nominatim. We follow semantic versioning.
+
+        Major, minor and patch_level refer to the last released version.
+        The database patch level tracks important changes between releases
+        and must always be increased when there is a change to the database or code
+        that requires a migration.
+
+        When adding a migration on the development branch, raise the patch level
+        to 99 to make sure that the migration is applied when updating from a
+        patch release to the next minor version. Patch releases usually shouldn't
+        have migrations in them. When they are needed, then make sure that the
+        migration can be reapplied and set the migration version to the appropriate
+        patch level when cherry-picking the commit with the migration.
+    """
+
+    major: int
+    minor: int
+    patch_level: int
+    db_patch_level: Optional[int]
+
+    def __str__(self) -> str:
+        if self.db_patch_level is None:
+            return f"{self.major}.{self.minor}.{self.patch_level}"
+
+        return f"{self.major}.{self.minor}.{self.patch_level}-{self.db_patch_level}"
+
+    def release_version(self) -> str:
+        """ Return the release version in semantic versioning format.
+
+            The release version does not include the database patch version.
+        """
+        return f"{self.major}.{self.minor}.{self.patch_level}"
+
+
+def parse_version(version: str) -> NominatimVersion:
+    """ Parse a version string into a version consisting of a tuple of
+        four ints: major, minor, patch level, database patch level
+
+        This is the reverse operation of `version_str()`.
+    """
+    parts = version.split('.')
+    return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])
+
 
 NOMINATIM_VERSION = parse_version('4.4.99-1')
 
index 46559720d3da5d262c5b63a642fccce8a678664f..dfbbee2874f56cf3918982aa45201b0ede3c1557 100644 (file)
@@ -15,8 +15,8 @@ import psycopg2.extras
 sys.path.insert(1, str((Path(__file__) / '..' / '..' / '..' / '..'/ 'src').resolve()))
 
 from nominatim_db import cli
-from nominatim_core.config import Configuration
-from nominatim_core.db.connection import Connection
+from nominatim_db.config import Configuration
+from nominatim_db.db.connection import Connection
 from nominatim_db.tools import refresh
 from nominatim_db.tokenizer import factory as tokenizer_factory
 from steps.utils import run_script
index 08b7422c9c38bc8d0a8dc31cd3fb8f1547460ce3..a902e2640a7996a5cedbbd3765cb25f593e0f3a3 100644 (file)
@@ -15,7 +15,7 @@ import datetime as dt
 import sqlalchemy as sa
 
 import nominatim_api as napi
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from nominatim_db.db.sql_preprocessor import SQLPreprocessor
 from nominatim_api.search.query_analyzer_factory import make_query_analyzer
 from nominatim_db.tools import convert_sqlite
 import nominatim_api.logging as loglib
index 50fbbbbea7cf8f702984e2a1837017a93855e68e..9caa922665de15ced0fa326b7f9443753a7008d1 100644 (file)
@@ -10,7 +10,7 @@ Provides dummy implementations of ASGIAdaptor for testing.
 from collections import namedtuple
 
 import nominatim_api.v1.server_glue as glue
-from nominatim_core.config import Configuration
+from nominatim_api.config import Configuration
 
 class FakeError(BaseException):
 
index 2b211611a71dda84607ae2b0e9951a3c5a0cd902..5412ca6e334fad5f8932379a274a7f65284182d2 100644 (file)
@@ -39,7 +39,7 @@ def test_status_full(apiobj, frontend):
     assert result.status == 0
     assert result.message == 'OK'
     assert result.software_version == NOMINATIM_API_VERSION
-    assert result.database_version == NominatimVersion(99, 5, 4, 2)
+    assert result.database_version == '99.5.4-2'
     assert result.data_updated == import_date
 
 
index 2faba33dac7f4191a2df2a52f258370b836c5b77..fbb9b682f499943c503041c61c1ff4d82bddabe2 100644 (file)
@@ -9,7 +9,7 @@ Tests for loading of parameter dataclasses.
 """
 import pytest
 
-from nominatim_core.errors import UsageError
+from nominatim_api.errors import UsageError
 import nominatim_api.types as typ
 
 def test_no_params_defaults():
index 9c2400c5c2e65e561f816719292a6d712ff4cfd9..85235e1e2e1e123ed132d7a3c81a6f211fe20706 100644 (file)
@@ -14,7 +14,7 @@ import nominatim_db.data.country_info
 import nominatim_db.tools.refresh
 import nominatim_db.tools.postcodes
 import nominatim_db.indexer.indexer
-import nominatim_core.db.properties
+import nominatim_db.db.properties
 
 
 class TestCliImportWithDb:
@@ -81,7 +81,7 @@ class TestCliImportWithDb:
             mock_func_factory(nominatim_db.tools.postcodes, 'update_postcodes'),
             mock_func_factory(nominatim_db.indexer.indexer.Indexer, 'index_full'),
             mock_func_factory(nominatim_db.tools.refresh, 'setup_website'),
-            mock_func_factory(nominatim_core.db.properties, 'set_property')
+            mock_func_factory(nominatim_db.db.properties, 'set_property')
         ]
 
         assert self.call_nominatim('import', '--continue', 'load-data') == 0
@@ -98,7 +98,7 @@ class TestCliImportWithDb:
             mock_func_factory(nominatim_db.data.country_info, 'create_country_names'),
             mock_func_factory(nominatim_db.indexer.indexer.Indexer, 'index_full'),
             mock_func_factory(nominatim_db.tools.refresh, 'setup_website'),
-            mock_func_factory(nominatim_core.db.properties, 'set_property')
+            mock_func_factory(nominatim_db.db.properties, 'set_property')
         ]
 
         assert self.call_nominatim('import', '--continue', 'indexing') == 0
@@ -115,7 +115,7 @@ class TestCliImportWithDb:
             mock_func_factory(nominatim_db.tools.database_import, 'create_search_indices'),
             mock_func_factory(nominatim_db.data.country_info, 'create_country_names'),
             mock_func_factory(nominatim_db.tools.refresh, 'setup_website'),
-            mock_func_factory(nominatim_core.db.properties, 'set_property')
+            mock_func_factory(nominatim_db.db.properties, 'set_property')
         ]
 
         assert self.call_nominatim('import', '--continue', 'db-postprocess') == 0
index ff900e58bbc988842fd0f66dcf98ddd77f32af54..8c1e8ea6440a5d74da03084d57b6543458d89507 100644 (file)
@@ -16,7 +16,7 @@ import nominatim_db.cli
 import nominatim_db.indexer.indexer
 import nominatim_db.tools.replication
 import nominatim_db.tools.refresh
-from nominatim_core.db import status
+from nominatim_db.db import status
 
 @pytest.fixture
 def tokenizer_mock(monkeypatch):
index bb649d23289e4be75c73dcc373fad712c9b6be50..5c9393ecfde56f76be876cebb6d5c68ff90a70cc 100644 (file)
@@ -10,8 +10,8 @@ Test for loading dotenv configuration.
 from pathlib import Path
 import pytest
 
-from nominatim_core.config import Configuration, flatten_config_list
-from nominatim_core.errors import UsageError
+from nominatim_db.config import Configuration, flatten_config_list
+from nominatim_db.errors import UsageError
 
 @pytest.fixture
 def make_config():
index 06bfff065f4673c54ae7fe4bdc4c5df91f7933eb..c29121802c2dd69291a97dd8042502a7dc159873 100644 (file)
@@ -12,7 +12,7 @@ import sys
 
 import pytest
 
-from nominatim_core.config import Configuration
+from nominatim_db.config import Configuration
 
 @pytest.fixture
 def test_config(src_dir, tmp_path):
index c9e8f0487f2e1aba0ffd1cff90105946a757eb1b..d301c9736eb68c9f616a635c92693e2e7335b282 100644 (file)
@@ -15,9 +15,9 @@ import pytest
 SRC_DIR = (Path(__file__) / '..' / '..' / '..').resolve()
 sys.path.insert(0, str(SRC_DIR / 'src'))
 
-from nominatim_core.config import Configuration
-from nominatim_core.db import connection
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from nominatim_db.config import Configuration
+from nominatim_db.db import connection
+from nominatim_db.db.sql_preprocessor import SQLPreprocessor
 import nominatim_db.tokenizer.factory
 
 import dummy_tokenizer
index 019f53c15d0ce59fd0ba392f775eafc3b12edb6f..fff695e53ebc97520ba9893f6fff470846bf7269 100644 (file)
@@ -13,7 +13,7 @@ import concurrent.futures
 import pytest
 import psycopg2
 
-from nominatim_core.db.async_connection import DBConnection, DeadlockHandler
+from nominatim_db.db.async_connection import DBConnection, DeadlockHandler
 
 
 @pytest.fixture
index 7ecf3bb4e27d3a37a7b78a4f2528ade19f20e2fb..8b4cc62f0c46e6f8bd46db49bc5d3f3ab58cae58 100644 (file)
@@ -10,7 +10,7 @@ Tests for specialised connection and cursor classes.
 import pytest
 import psycopg2
 
-from nominatim_core.db.connection import connect, get_pg_env
+from nominatim_db.db.connection import connect, get_pg_env
 
 @pytest.fixture
 def db(dsn):
index aca1b1f8a92ba859412519283225c84d8863fb36..e55bb973467611022791699aa6ad755955a4bdbb 100644 (file)
@@ -9,7 +9,7 @@ Tests for property table manpulation.
 """
 import pytest
 
-from nominatim_core.db import properties
+from nominatim_db.db import properties
 
 @pytest.fixture
 def property_factory(property_table, temp_db_cursor):
index 1ef6bc88ce9798def52c8ce99b909da669e35ff9..114c5244e14f77c040434c127c6ecf20ae743ec7 100644 (file)
@@ -9,7 +9,7 @@ Tests for SQL preprocessing.
 """
 import pytest
 
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from nominatim_db.db.sql_preprocessor import SQLPreprocessor
 
 @pytest.fixture
 def sql_factory(tmp_path):
index 67cd22e91d536d7f8281f18ff242e824676d6fee..77135a8c7f943c13df96632aa9901e50b9aabed7 100644 (file)
@@ -11,8 +11,8 @@ import datetime as dt
 
 import pytest
 
-import nominatim_core.db.status
-from nominatim_core.errors import UsageError
+import nominatim_db.db.status
+from nominatim_db.errors import UsageError
 
 OSM_NODE_DATA = """\
 <osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
@@ -22,7 +22,7 @@ OSM_NODE_DATA = """\
 """
 
 def iso_date(date):
-    return dt.datetime.strptime(date, nominatim_core.db.status.ISODATE_FORMAT)\
+    return dt.datetime.strptime(date, nominatim_db.db.status.ISODATE_FORMAT)\
                .replace(tzinfo=dt.timezone.utc)
 
 
@@ -36,7 +36,7 @@ def test_compute_database_date_from_osm2pgsql(table_factory, temp_db_conn, offli
     table_factory('osm2pgsql_properties', 'property TEXT, value TEXT',
                   content=(('current_timestamp', '2024-01-03T23:45:54Z'), ))
 
-    date = nominatim_core.db.status.compute_database_date(temp_db_conn, offline=offline)
+    date = nominatim_db.db.status.compute_database_date(temp_db_conn, offline=offline)
     assert date == iso_date('2024-01-03T23:45:54')
 
 
@@ -44,12 +44,12 @@ def test_compute_database_date_from_osm2pgsql_nodata(table_factory, temp_db_conn
     table_factory('osm2pgsql_properties', 'property TEXT, value TEXT')
 
     with pytest.raises(UsageError, match='Cannot determine database date from data in offline mode'):
-        nominatim_core.db.status.compute_database_date(temp_db_conn, offline=True)
+        nominatim_db.db.status.compute_database_date(temp_db_conn, offline=True)
 
 
 def test_compute_database_date_place_empty(place_table, temp_db_conn):
     with pytest.raises(UsageError):
-        nominatim_core.db.status.compute_database_date(temp_db_conn)
+        nominatim_db.db.status.compute_database_date(temp_db_conn)
 
 
 def test_compute_database_date_valid(monkeypatch, place_row, temp_db_conn):
@@ -60,9 +60,9 @@ def test_compute_database_date_valid(monkeypatch, place_row, temp_db_conn):
         requested_url.append(url)
         return OSM_NODE_DATA
 
-    monkeypatch.setattr(nominatim_core.db.status, "get_url", mock_url)
+    monkeypatch.setattr(nominatim_db.db.status, "get_url", mock_url)
 
-    date = nominatim_core.db.status.compute_database_date(temp_db_conn)
+    date = nominatim_db.db.status.compute_database_date(temp_db_conn)
 
     assert requested_url == ['https://www.openstreetmap.org/api/0.6/node/45673/1']
     assert date == iso_date('2006-01-27T22:09:10')
@@ -76,15 +76,15 @@ def test_compute_database_broken_api(monkeypatch, place_row, temp_db_conn):
         requested_url.append(url)
         return '<osm version="0.6" generator="OpenStre'
 
-    monkeypatch.setattr(nominatim_core.db.status, "get_url", mock_url)
+    monkeypatch.setattr(nominatim_db.db.status, "get_url", mock_url)
 
     with pytest.raises(UsageError):
-        nominatim_core.db.status.compute_database_date(temp_db_conn)
+        nominatim_db.db.status.compute_database_date(temp_db_conn)
 
 
 def test_set_status_empty_table(temp_db_conn, temp_db_cursor):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date)
 
     assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
              {(date, None, True)}
@@ -92,12 +92,12 @@ def test_set_status_empty_table(temp_db_conn, temp_db_cursor):
 
 def test_set_status_filled_table(temp_db_conn, temp_db_cursor):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date)
 
     assert temp_db_cursor.table_rows('import_status') == 1
 
     date = dt.datetime.fromordinal(1000100).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date, seq=456, indexed=False)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date, seq=456, indexed=False)
 
     assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
              {(date, 456, False)}
@@ -105,25 +105,25 @@ def test_set_status_filled_table(temp_db_conn, temp_db_cursor):
 
 def test_set_status_missing_date(temp_db_conn, temp_db_cursor):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date)
 
     assert temp_db_cursor.table_rows('import_status') == 1
 
-    nominatim_core.db.status.set_status(temp_db_conn, date=None, seq=456, indexed=False)
+    nominatim_db.db.status.set_status(temp_db_conn, date=None, seq=456, indexed=False)
 
     assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
              {(date, 456, False)}
 
 
 def test_get_status_empty_table(temp_db_conn):
-    assert nominatim_core.db.status.get_status(temp_db_conn) == (None, None, None)
+    assert nominatim_db.db.status.get_status(temp_db_conn) == (None, None, None)
 
 
 def test_get_status_success(temp_db_conn):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date, seq=667, indexed=False)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date, seq=667, indexed=False)
 
-    assert nominatim_core.db.status.get_status(temp_db_conn) == \
+    assert nominatim_db.db.status.get_status(temp_db_conn) == \
              (date, 667, False)
 
 
@@ -131,14 +131,14 @@ def test_get_status_success(temp_db_conn):
 @pytest.mark.parametrize("new_state", [True, False])
 def test_set_indexed(temp_db_conn, temp_db_cursor, old_state, new_state):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
-    nominatim_core.db.status.set_status(temp_db_conn, date=date, indexed=old_state)
-    nominatim_core.db.status.set_indexed(temp_db_conn, new_state)
+    nominatim_db.db.status.set_status(temp_db_conn, date=date, indexed=old_state)
+    nominatim_db.db.status.set_indexed(temp_db_conn, new_state)
 
     assert temp_db_cursor.scalar("SELECT indexed FROM import_status") == new_state
 
 
 def test_set_indexed_empty_status(temp_db_conn, temp_db_cursor):
-    nominatim_core.db.status.set_indexed(temp_db_conn, True)
+    nominatim_db.db.status.set_indexed(temp_db_conn, True)
 
     assert temp_db_cursor.table_rows("import_status") == 0
 
@@ -147,8 +147,8 @@ def test_log_status(temp_db_conn, temp_db_cursor):
     date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
     start = dt.datetime.now() - dt.timedelta(hours=1)
 
-    nominatim_core.db.status.set_status(temp_db_conn, date=date, seq=56)
-    nominatim_core.db.status.log_status(temp_db_conn, start, 'index')
+    nominatim_db.db.status.set_status(temp_db_conn, date=date, seq=56)
+    nominatim_db.db.status.log_status(temp_db_conn, start, 'index')
 
     temp_db_conn.commit()
 
index 2eef1bd949b0b7577ed66244f0c04d40148306b2..b4335ab039d6dc473b7f0cd24ad51c98ec922569 100644 (file)
@@ -11,8 +11,8 @@ import json
 
 import pytest
 
-import nominatim_core.db.utils as db_utils
-from nominatim_core.errors import UsageError
+import nominatim_db.db.utils as db_utils
+from nominatim_db.errors import UsageError
 
 def test_execute_file_success(dsn, temp_db_cursor, tmp_path):
     tmpfile = tmp_path / 'test.sql'
index d78eaeb421d72221189ff039426c2354fcc0d556..4739e3f0af831303f4860f601b802537e781d898 100644 (file)
@@ -8,7 +8,7 @@
 Tokenizer for testing.
 """
 from nominatim_db.data.place_info import PlaceInfo
-from nominatim_core.config import Configuration
+from nominatim_db.config import Configuration
 
 def create(dsn, data_dir):
     """ Create a new instance of the tokenizer provided by this module.
index a1020c8677eb72b5ced751824e03d5e4cfde5fd5..82e700bd4456f71fc8c839f0741d450decdc958c 100644 (file)
@@ -11,7 +11,7 @@ import itertools
 
 import psycopg2.extras
 
-from nominatim_core.db import properties
+from nominatim_db.db import properties
 
 # This must always point to the mock word table for the default tokenizer.
 from mock_icu_word_table import MockIcuWordTable as MockWordTable
index 37ed07f4cc56eabd51e2cc57d880a182bf267afc..0497f21df70e9907348730b21ce22c5700c984d3 100644 (file)
@@ -9,7 +9,7 @@ Tests for sanitizer configuration helper functions.
 """
 import pytest
 
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 from nominatim_db.tokenizer.sanitizers.config import SanitizerConfig
 
 def test_string_list_default_empty():
index cd10b5c6cb27b025a75b20b8c030ffede259609b..fbfd72da514e974b2523c7fc869ed3625af44f7f 100644 (file)
@@ -12,7 +12,7 @@ import pytest
 from nominatim_db.tokenizer.place_sanitizer import PlaceSanitizer
 from nominatim_db.data.place_info import PlaceInfo
 
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 class TestSplitName:
 
index e723625d6fa3f95bb9301a692a7f27d1bad6020a..632dea88f831561fe711f26a9e535e27b6310c05 100644 (file)
@@ -9,9 +9,9 @@ Tests for creating new tokenizers.
 """
 import pytest
 
-from nominatim_core.db import properties
+from nominatim_db.db import properties
 from nominatim_db.tokenizer import factory
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 from dummy_tokenizer import DummyTokenizer
 
 
index 0d51bfc4e33006afef1830fc7170332e4318b942..357b7d4ae4cde571315c2a7d8109595911e343f4 100644 (file)
@@ -14,8 +14,8 @@ import pytest
 
 from nominatim_db.tokenizer import icu_tokenizer
 import nominatim_db.tokenizer.icu_rule_loader
-from nominatim_core.db import properties
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from nominatim_db.db import properties
+from nominatim_db.db.sql_preprocessor import SQLPreprocessor
 from nominatim_db.data.place_info import PlaceInfo
 
 from mock_icu_word_table import MockIcuWordTable
index e2997659f65352c603d1ad04fe144f558beb6fb3..a3fae75815d4a1d0dad629b00a547c7d77efc1bb 100644 (file)
@@ -13,7 +13,7 @@ import pytest
 import yaml
 
 from nominatim_db.tokenizer.icu_rule_loader import ICURuleLoader
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 from icu import Transliterator
 
index be33b3b1195b5eadd4c7706642c061b685a52663..bf208c92dc8684eb346f8b1f129614978494f1a3 100644 (file)
@@ -14,8 +14,8 @@ import pytest
 
 from nominatim_db.data.place_info import PlaceInfo
 from nominatim_db.tokenizer import legacy_tokenizer
-from nominatim_core.db import properties
-from nominatim_core.errors import UsageError
+from nominatim_db.db import properties
+from nominatim_db.errors import UsageError
 
 from mock_legacy_word_table import MockLegacyWordTable
 
index b424c5ef8157a10ea982fc553da418e438488fb8..25844459f907f2801432e8eec1e0111fb676d894 100644 (file)
@@ -9,7 +9,7 @@ Tests for execution of the sanitztion step.
 """
 import pytest
 
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 import nominatim_db.tokenizer.place_sanitizer as sanitizer
 from nominatim_db.data.place_info import PlaceInfo
 
index 245dc43d71fb76ad7c5680b61b4ff76cc180ff44..870c8a5d76f81346d291a2cd348f4431e65fbb6f 100644 (file)
@@ -13,7 +13,7 @@ from icu import Transliterator
 
 import nominatim_db.tokenizer.token_analysis.postcodes as module
 from nominatim_db.data.place_name import PlaceName
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 DEFAULT_NORMALIZATION = """ :: NFD ();
                             '🜳' > ' ';
index 277758e1ff9b064827795496b614ad0fb0cde57a..191f551f86debcef7d011a102b5adf60803030f6 100644 (file)
@@ -12,7 +12,7 @@ import pytest
 from icu import Transliterator
 
 import nominatim_db.tokenizer.token_analysis.generic as module
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 DEFAULT_NORMALIZATION = """ :: NFD ();
                             '🜳' > ' ';
index ea813bdc7f996e17c42ed1c90ae255d349fa0288..7d0db9258246cea0017dec0ada0418d9c508fd74 100644 (file)
@@ -12,7 +12,7 @@ import pytest
 from icu import Transliterator
 
 import nominatim_db.tokenizer.token_analysis.generic as module
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 DEFAULT_NORMALIZATION = """ '🜳' > ' ';
                             [[:Nonspacing Mark:] [:Cf:]] >;
index a59f3d9da10aaacd0fb2b4a773fa8c018893d244..1e1f0e294736c23826f94adbda5a380a8a12c8a8 100644 (file)
@@ -9,10 +9,10 @@ Tests for maintenance and analysis functions.
 """
 import pytest
 
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 from nominatim_db.tools import admin
 from nominatim_db.tokenizer import factory
-from nominatim_core.db.sql_preprocessor import SQLPreprocessor
+from nominatim_db.db.sql_preprocessor import SQLPreprocessor
 
 @pytest.fixture(autouse=True)
 def create_placex_table(project_env, tokenizer_mock, temp_db_cursor, placex_table):
index a95f3d9804a8f0853aac744482a009f38863250b..548ec800b6b8f966427911dd2d91a90d19c8cb64 100644 (file)
@@ -14,7 +14,7 @@ import pytest
 import psycopg2
 
 from nominatim_db.tools import database_import
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 class TestDatabaseSetup:
     DBNAME = 'test_nominatim_python_unittest'
index 50bec7e6eaa775fd9f95f3dc39876228ed4322df..666ef0b8b65e74d1418bd6d3c8807b2217306f35 100644 (file)
@@ -12,7 +12,7 @@ import subprocess
 
 import pytest
 
-from nominatim_core.config import Configuration
+from nominatim_db.config import Configuration
 import nominatim_db.tools.exec_utils as exec_utils
 
 def test_run_osm2pgsql(osm2pgsql_options):
index 91c9fc1536b114ca27be6aff38c19064830b2f94..64eb7b1856b0996c3958ae71e51b3ecd3fbbdbb4 100644 (file)
@@ -13,7 +13,7 @@ import pytest
 from nominatim_db.tools.special_phrases.sp_importer import SPImporter
 from nominatim_db.tools.special_phrases.sp_wiki_loader import SPWikiLoader
 from nominatim_db.tools.special_phrases.special_phrase import SpecialPhrase
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 from cursor import CursorForTesting
 
index d33ff4223613a8d4d4280fab346cdf135c9e22b3..3a849adbf956ed8469730c9cb6eb2d2d377eff0c 100644 (file)
@@ -11,7 +11,7 @@ import pytest
 import psycopg2.extras
 
 from nominatim_db.tools import migration
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 import nominatim_db.version
 
 from mock_legacy_word_table import MockLegacyWordTable
index 4cd53ae3aa24a62b8330129fedf14a4cae23c815..392ea0750b6f50c11c5006e4ef6eb09ceb7763f3 100644 (file)
@@ -14,8 +14,8 @@ import pytest
 from osmium.replication.server import OsmosisState
 
 import nominatim_db.tools.replication
-import nominatim_core.db.status as status
-from nominatim_core.errors import UsageError
+import nominatim_db.db.status as status
+from nominatim_db.errors import UsageError
 
 OSM_NODE_DATA = """\
 <osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
index e6185fd61a0698fc36dafddc723eee23ac6af906..9d0ad9cc8e81c8782819fa2c54cd1bffdd0082fb 100644 (file)
@@ -9,7 +9,7 @@
 """
 import pytest
 
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 from nominatim_db.tools.special_phrases.sp_csv_loader import SPCsvLoader
 from nominatim_db.tools.special_phrases.special_phrase import SpecialPhrase
 
index 396fe069f012a10a436e57bbf4640c08381bb783..7ef6a1e63306020f41d1dcb91863a4a01be6c51e 100644 (file)
@@ -13,7 +13,7 @@ from textwrap import dedent
 import pytest
 
 from nominatim_db.tools import tiger_data, freeze
-from nominatim_core.errors import UsageError
+from nominatim_db.errors import UsageError
 
 class MockTigerTable:
 
index d91edae2d44c5a85aaf39f71f10a3cac0a9fc207..bac0edb3c406fd9ab45b74fb4d0e410ddfc982b2 100644 (file)
@@ -9,7 +9,7 @@ Tests for centroid computation.
 """
 import pytest
 
-from nominatim_core.utils.centroid import PointsCentroid
+from nominatim_db.utils.centroid import PointsCentroid
 
 def test_empty_set():
     c = PointsCentroid()
index ff542f045e236e6a7ce964df1042ed9f616bfedd..53e3f4d3073ca01bcc1ad0bdc89f90c4a8c92234 100644 (file)
@@ -11,7 +11,7 @@ import json
 
 import pytest
 
-from nominatim_core.utils.json_writer import JsonWriter
+from nominatim_api.utils.json_writer import JsonWriter
 
 @pytest.mark.parametrize("inval,outstr", [(None, 'null'),
                                           (True, 'true'), (False, 'false'),
index 3411c2ba0524d9a88c1560abef98b3e534ade0a3..05dc38a4cf6df3c6eb6415789e099d2da9763829 100644 (file)
@@ -119,7 +119,7 @@ fi                                 #DOCS:
 # Now install Nominatim using pip:
 
     cd $USERHOME/Nominatim
-    $USERHOME/nominatim-venv/bin/pip install packaging/nominatim-{core,db}
+    $USERHOME/nominatim-venv/bin/pip install packaging/nominatim-db
 
 # Nominatim is now ready to use. The nominatim binary is available at
 # `$USERHOME/venv/bin/nominatim`. If you want to have 'nominatim' in your