]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/tools/exec_utils.py
add Python package configuration
[nominatim.git] / nominatim / tools / exec_utils.py
index db89c38947d35a17f6e75a0964ea3b48a5aaa4ce..9bf28a03c3f924ee58e801803d40f527bafc1f74 100644 (file)
@@ -11,6 +11,7 @@ from typing import Any, Mapping, IO
 import logging
 import os
 import subprocess
+import shutil
 import urllib.request as urlrequest
 
 from nominatim.typing import StrPath
@@ -30,7 +31,14 @@ def run_osm2pgsql(options: Mapping[str, Any]) -> None:
     """ Run osm2pgsql with the given options.
     """
     env = get_pg_env(options['dsn'])
-    cmd = [str(options['osm2pgsql']),
+
+    osm2pgsql_cmd = options['osm2pgsql']
+    if osm2pgsql_cmd is None:
+        osm2pgsql_cmd = shutil.which('osm2pgsql')
+        if osm2pgsql_cmd is None:
+            raise RuntimeError('osm2pgsql executable not found. Please install osm2pgsql first.')
+
+    cmd = [str(osm2pgsql_cmd),
            '--slim',
            '--log-progress', 'true',
            '--number-processes', '1' if options['append'] else str(options['threads']),