Skip to content

Commit

Permalink
add deprecation warnings in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
lonvia committed Aug 9, 2024
1 parent 6527b7c commit fd33ef9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,7 @@ if (INSTALL_MUNIN_PLUGINS)
munin/nominatim_requests
DESTINATION ${NOMINATIM_MUNINDIR})
endif()

message(WARNING "Building with CMake is deprecated and will be removed in Nominatim 5.0."
"Use Nominatim pip packages instead.\n"
"See https://nominatim.org/release-docs/develop/admin/Installation/#downloading-and-building-nominatim")
10 changes: 9 additions & 1 deletion src/nominatim_db/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ def run(self, **kwargs: Any) -> int:
log.warning('Using project directory: %s', str(args.project_dir))

try:
return args.command.run(args)
ret = args.command.run(args)

if args.config.TOKENIZER == 'legacy':
log.warning('WARNING: the "legacy" tokenizer is deprecated '
'and will be removed in Nominatim 5.0.')

return ret
except UsageError as exception:
if log.isEnabledFor(logging.DEBUG):
raise # use Python's exception printing
Expand Down Expand Up @@ -169,6 +175,8 @@ def run(self, args: NominatimArgs) -> int:
if args.engine == 'php':
if args.config.lib_dir.php is None:
raise UsageError("PHP frontend not configured.")
LOG.warning('\n\nWARNING: the PHP frontend is deprecated '
'and will be removed in Nominatim 5.0.\n\n')
run_php_server(args.server, args.project_dir / 'website')
else:
asyncio.run(self.run_uvicorn(args))
Expand Down
8 changes: 7 additions & 1 deletion src/nominatim_db/tokenizer/legacy_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
def create(dsn: str, data_dir: Path) -> 'LegacyTokenizer':
""" Create a new instance of the tokenizer provided by this module.
"""
LOG.warning('WARNING: the legacy tokenizer is deprecated '
'and will be removed in Nominatim 5.0.')
return LegacyTokenizer(dsn, data_dir)


def _install_module(config_module_path: str, src_dir: Path, module_dir: Path) -> str:
def _install_module(config_module_path: str, src_dir: Optional[Path], module_dir: Path) -> str:
""" Copies the PostgreSQL normalisation module into the project
directory if necessary. For historical reasons the module is
saved in the '/module' subdirectory and not with the other tokenizer
Expand All @@ -55,6 +57,10 @@ def _install_module(config_module_path: str, src_dir: Path, module_dir: Path) ->
LOG.info("Using custom path for database module at '%s'", config_module_path)
return config_module_path

# Otherwise a source dir must be given.
if src_dir is None:
raise UsageError("The legacy tokenizer cannot be used with the Nominatim pip module.")

# Compatibility mode for builddir installations.
if module_dir.exists() and src_dir.samefile(module_dir):
LOG.info('Running from build directory. Leaving database module as is.')
Expand Down

0 comments on commit fd33ef9

Please sign in to comment.