]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_db/tools/exec_utils.py
use word_token length when penalizing against postcodes
[nominatim.git] / src / nominatim_db / tools / exec_utils.py
index 1adcc777b053bf7507ffaf8f6bff8fd8e84e8977..2d048bcb7bdfbc502f6178e557a832ffa042acf0 100644 (file)
@@ -2,7 +2,7 @@
 #
 # This file is part of Nominatim. (https://nominatim.org)
 #
-# Copyright (C) 2024 by the Nominatim developer community.
+# Copyright (C) 2025 by the Nominatim developer community.
 # For a full list of authors see the git log.
 """
 Helper functions for executing external programs.
@@ -14,19 +14,12 @@ import re
 import subprocess
 import shutil
 
-from ..typing import StrPath
 from ..db.connection import get_pg_env
 from ..errors import UsageError
 from ..version import OSM2PGSQL_REQUIRED_VERSION
 
 LOG = logging.getLogger()
 
-def run_php_server(server_address: str, base_dir: StrPath) -> None:
-    """ Run the built-in server from the given directory.
-    """
-    subprocess.run(['/usr/bin/env', 'php', '-S', server_address],
-                   cwd=str(base_dir), check=True)
-
 
 def run_osm2pgsql(options: Mapping[str, Any]) -> None:
     """ Run osm2pgsql with the given options.
@@ -42,11 +35,14 @@ def run_osm2pgsql(options: Mapping[str, Any]) -> None:
            '--number-processes', '1' if options['append'] else str(options['threads']),
            '--cache', str(options['osm2pgsql_cache']),
            '--style', str(options['osm2pgsql_style'])
-          ]
+           ]
 
     if str(options['osm2pgsql_style']).endswith('.lua'):
         env['LUA_PATH'] = ';'.join((str(options['osm2pgsql_style_path'] / '?.lua'),
-                                    os.environ.get('LUAPATH', ';')))
+                                    os.environ.get('LUA_PATH', ';')))
+        env['THEMEPARK_PATH'] = str(options['osm2pgsql_style_path'] / 'themes')
+        if 'THEMEPARK_PATH' in os.environ:
+            env['THEMEPARK_PATH'] += ':' + os.environ['THEMEPARK_PATH']
         cmd.extend(('--output', 'flex'))
 
         for flavour in ('data', 'index'):
@@ -57,7 +53,6 @@ def run_osm2pgsql(options: Mapping[str, Any]) -> None:
         cmd.extend(('--output', 'gazetteer', '--hstore', '--latlon'))
         cmd.extend(_mk_tablespace_options('main', options))
 
-
     if options['flatnode_file']:
         cmd.extend(('--flat-nodes', options['flatnode_file']))
 
@@ -90,7 +85,7 @@ def _mk_tablespace_options(ttype: str, options: Mapping[str, Any]) -> List[str]:
 
 
 def _find_osm2pgsql_cmd(cmdline: Optional[str]) -> str:
-    if cmdline is not None:
+    if cmdline:
         return cmdline
 
     in_path = shutil.which('osm2pgsql')