]> git.openstreetmap.org Git - nominatim.git/commitdiff
move lua scripts into a separate directory
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 5 Dec 2024 14:19:36 +0000 (15:19 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 16 Dec 2024 09:26:55 +0000 (10:26 +0100)
17 files changed:
.github/workflows/ci-tests.yml
lib-lua/flex-base.lua [moved from settings/flex-base.lua with 100% similarity]
lib-lua/import-address.lua [moved from settings/import-address.lua with 100% similarity]
lib-lua/import-admin.lua [moved from settings/import-admin.lua with 100% similarity]
lib-lua/import-extratags.lua [moved from settings/import-extratags.lua with 100% similarity]
lib-lua/import-full.lua [moved from settings/import-full.lua with 100% similarity]
lib-lua/import-street.lua [moved from settings/import-street.lua with 100% similarity]
lib-lua/taginfo.lua [moved from settings/taginfo.lua with 95% similarity]
packaging/nominatim-api/extra_src/paths.py
packaging/nominatim-db/extra_src/nominatim_db/paths.py
packaging/nominatim-db/lib-lua [new symlink]
packaging/nominatim-db/pyproject.toml
src/nominatim_db/clicmd/args.py
src/nominatim_db/config.py
src/nominatim_db/paths.py
test/bdd/steps/steps_osm_data.py
test/python/config/test_config.py

index 8b38d3dc77e7ca553d12c22a919dcd33f9a13b5b..f453aefb561048e8037cd9fd09b27e377722ab92 100644 (file)
@@ -185,9 +185,6 @@ jobs:
             - name: Prepare import environment
               run: |
                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
             - name: Prepare import environment
               run: |
                   mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
-                  mv Nominatim/settings/flex-base.lua flex-base.lua
-                  mv Nominatim/settings/import-extratags.lua import-extratags.lua
-                  mv Nominatim/settings/taginfo.lua taginfo.lua
                   rm -rf Nominatim
                   mkdir data-env-reverse
               working-directory: /home/nominatim
                   rm -rf Nominatim
                   mkdir data-env-reverse
               working-directory: /home/nominatim
@@ -205,7 +202,7 @@ jobs:
               working-directory: /home/nominatim/nominatim-project
 
             - name: Print taginfo
               working-directory: /home/nominatim/nominatim-project
 
             - name: Print taginfo
-              run: lua taginfo.lua
+              run: lua ./nominatim-venv/lib/*/site-packages/nominatim_db/resources/lib-lua/taginfo.lua
               working-directory: /home/nominatim
 
             - name: Collect host OS information
               working-directory: /home/nominatim
 
             - name: Collect host OS information
similarity index 100%
rename from settings/flex-base.lua
rename to lib-lua/flex-base.lua
similarity index 95%
rename from settings/taginfo.lua
rename to lib-lua/taginfo.lua
index ef2ad2a60a1094aeee62e3436db6ad0d5de66511..fddaf298f50cd9969a6a0bc20a8eab3fd3b7598b 100644 (file)
@@ -6,7 +6,8 @@ osm2pgsql = {}
 function osm2pgsql.define_table(...) end
 
 -- provide path to flex-style lua file
 function osm2pgsql.define_table(...) end
 
 -- provide path to flex-style lua file
-flex = require('import-extratags')
+package.path = arg[0]:match("(.*/)") .. "?.lua;" .. package.path
+local flex = require('import-extratags')
 local json = require ('dkjson')
 
 
 local json = require ('dkjson')
 
 
index 797acbb55eebccd279cbcc0be9cdec69a66e84fd..7d186da16d77529bff3e4c80b65cd43bf6ff26fe 100644 (file)
@@ -11,4 +11,5 @@ from pathlib import Path
 
 DATA_DIR = None
 SQLLIB_DIR = None
 
 DATA_DIR = None
 SQLLIB_DIR = None
+LUALIB_DIR = None
 CONFIG_DIR = (Path(__file__) / '..' / 'resources' / 'settings').resolve()
 CONFIG_DIR = (Path(__file__) / '..' / 'resources' / 'settings').resolve()
index 796ff08b3519a205b5f8a926a7a46e17c0a89908..02df5047794e3bc8ba013375f08f5a78b79b26f7 100644 (file)
@@ -11,4 +11,5 @@ from pathlib import Path
 
 DATA_DIR = (Path(__file__) / '..' / 'resources').resolve()
 SQLLIB_DIR = (DATA_DIR / 'lib-sql')
 
 DATA_DIR = (Path(__file__) / '..' / 'resources').resolve()
 SQLLIB_DIR = (DATA_DIR / 'lib-sql')
+LUALIB_DIR = (DATA_DIR / 'lib-lua')
 CONFIG_DIR = (DATA_DIR / 'settings')
 CONFIG_DIR = (DATA_DIR / 'settings')
diff --git a/packaging/nominatim-db/lib-lua b/packaging/nominatim-db/lib-lua
new file mode 120000 (symlink)
index 0000000..e4e1bd0
--- /dev/null
@@ -0,0 +1 @@
+../../lib-lua
\ No newline at end of file
index 841845f036f20e3ad5db19ba9f8c62fcfe44b4c4..c34ce937ea6fb457bb5d05d86600ecf02d885f41 100644 (file)
@@ -44,6 +44,7 @@ include = [
     "src/nominatim_db",
     "scripts",
     "lib-sql/**/*.sql",
     "src/nominatim_db",
     "scripts",
     "lib-sql/**/*.sql",
+    "lib-lua/**/*.lua",
     "settings",
     "data/words.sql",
     "extra_src/nominatim_db/paths.py"
     "settings",
     "data/words.sql",
     "extra_src/nominatim_db/paths.py"
@@ -65,6 +66,7 @@ packages = ["src/nominatim_db"]
 
 [tool.hatch.build.targets.wheel.force-include]
 "lib-sql" = "nominatim_db/resources/lib-sql"
 
 [tool.hatch.build.targets.wheel.force-include]
 "lib-sql" = "nominatim_db/resources/lib-sql"
+"lib-lua" = "nominatim_db/resources/lib-lua"
 "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"
 "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"
index 488ecd184adbe48f5f320659f7ec78cd93d27be2..a8ff210a261a90ea52f10ae1547ba73eb92bd57b 100644 (file)
@@ -189,7 +189,7 @@ class NominatimArgs:
         return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.config.lib_dir.osm2pgsql,
                     osm2pgsql_cache=self.osm2pgsql_cache or default_cache,
                     osm2pgsql_style=self.config.get_import_style_file(),
         return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.config.lib_dir.osm2pgsql,
                     osm2pgsql_cache=self.osm2pgsql_cache or default_cache,
                     osm2pgsql_style=self.config.get_import_style_file(),
-                    osm2pgsql_style_path=self.config.config_dir,
+                    osm2pgsql_style_path=self.config.lib_dir.lua,
                     threads=self.threads or default_threads,
                     dsn=self.config.get_libpq_dsn(),
                     flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
                     threads=self.threads or default_threads,
                     dsn=self.config.get_libpq_dsn(),
                     flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
index ad54ab3d3f195e42bd09449eaa58bef64194d5d9..ae59cfd363857e55d76a888b00b09d6792a4adf7 100644 (file)
@@ -75,6 +75,7 @@ class Configuration:
         class _LibDirs:
             osm2pgsql: Path
             sql = paths.SQLLIB_DIR
         class _LibDirs:
             osm2pgsql: Path
             sql = paths.SQLLIB_DIR
+            lua = paths.LUALIB_DIR
             data = paths.DATA_DIR
 
         self.lib_dir = _LibDirs()
             data = paths.DATA_DIR
 
         self.lib_dir = _LibDirs()
@@ -207,7 +208,7 @@ class Configuration:
         style = getattr(self, 'IMPORT_STYLE')
 
         if style in ('admin', 'street', 'address', 'full', 'extratags'):
         style = getattr(self, 'IMPORT_STYLE')
 
         if style in ('admin', 'street', 'address', 'full', 'extratags'):
-            return self.config_dir / f'import-{style}.lua'
+            return self.lib_dir.lua / f'import-{style}.lua'
 
         return self.find_config_file('', 'IMPORT_STYLE')
 
 
         return self.find_config_file('', 'IMPORT_STYLE')
 
index 2614fa1452a620753fa0fe6586fa7681ce71cba0..ab34e4c0caee030a67321973f382489dab3badb3 100644 (file)
@@ -10,5 +10,6 @@ Path settings for extra data used by Nominatim.
 from pathlib import Path
 
 SQLLIB_DIR = (Path(__file__) / '..' / '..' / '..' / 'lib-sql').resolve()
 from pathlib import Path
 
 SQLLIB_DIR = (Path(__file__) / '..' / '..' / '..' / 'lib-sql').resolve()
+LUALIB_DIR = (Path(__file__) / '..' / '..' / '..' / 'lib-lua').resolve()
 DATA_DIR = (Path(__file__) / '..' / '..' / '..' / 'data').resolve()
 CONFIG_DIR = (Path(__file__) / '..' / '..' / '..' / 'settings').resolve()
 DATA_DIR = (Path(__file__) / '..' / '..' / '..' / 'data').resolve()
 CONFIG_DIR = (Path(__file__) / '..' / '..' / '..' / 'settings').resolve()
index 4cee75f7a32186b47ac8604a9d1a7969f0f6d6a4..70cf1515c65c738c6f908935982a5fe943fc1c0d 100644 (file)
@@ -19,7 +19,7 @@ def get_osm2pgsql_options(nominatim_env, fname, append):
                 osm2pgsql='osm2pgsql',
                 osm2pgsql_cache=50,
                 osm2pgsql_style=str(nominatim_env.get_test_config().get_import_style_file()),
                 osm2pgsql='osm2pgsql',
                 osm2pgsql_cache=50,
                 osm2pgsql_style=str(nominatim_env.get_test_config().get_import_style_file()),
-                osm2pgsql_style_path=nominatim_env.get_test_config().config_dir,
+                osm2pgsql_style_path=nominatim_env.get_test_config().lib_dir.lua,
                 threads=1,
                 dsn=nominatim_env.get_libpq_dsn(),
                 flatnode_file='',
                 threads=1,
                 dsn=nominatim_env.get_libpq_dsn(),
                 flatnode_file='',
index 8f90b5da16e3fb266f675612b6432762fe6355d5..9f68fcb9a97e89b2d85058ef6ecccf4d745b3334 100644 (file)
@@ -222,7 +222,7 @@ def test_get_import_style_intern(make_config, src_dir, monkeypatch):
 
     monkeypatch.setenv('NOMINATIM_IMPORT_STYLE', 'street')
 
 
     monkeypatch.setenv('NOMINATIM_IMPORT_STYLE', 'street')
 
-    expected = src_dir / 'settings' / 'import-street.lua'
+    expected = src_dir / 'lib-lua' / 'import-street.lua'
 
     assert config.get_import_style_file() == expected
 
 
     assert config.get_import_style_file() == expected