mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
add Python package configuration
The global configuration builds one large package.
This commit is contained in:
4
nominatim/__main__.py
Normal file
4
nominatim/__main__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
if __name__ == '__main__':
|
||||
from nominatim import cli
|
||||
|
||||
exit(cli.nominatim(module_dir=None, osm2pgsql_path=None))
|
||||
@@ -83,7 +83,7 @@ class Configuration:
|
||||
""" Set paths to library functions and data.
|
||||
"""
|
||||
for key, value in kwargs.items():
|
||||
setattr(self.lib_dir, key, Path(value))
|
||||
setattr(self.lib_dir, key, None if value is None else Path(value))
|
||||
|
||||
|
||||
def __getattr__(self, name: str) -> str:
|
||||
|
||||
@@ -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']),
|
||||
|
||||
@@ -33,6 +33,12 @@ class NominatimVersion(NamedTuple):
|
||||
def __str__(self) -> str:
|
||||
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}"
|
||||
|
||||
NOMINATIM_VERSION = NominatimVersion(4, 4, 99, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user