diff --git a/.efrocachemap b/.efrocachemap index 9389a2aa..8ef58a3e 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4072,26 +4072,26 @@ "build/assets/workspace/ninjafightplug.py": "https://files.ballistica.net/cache/ba1/c5/09/4f10b8a21ba87aa5509cff7a164b", "build/assets/workspace/onslaughtplug.py": "https://files.ballistica.net/cache/ba1/ff/0a/a354984f9c074dab0676ac7e4877", "build/assets/workspace/runaroundplug.py": "https://files.ballistica.net/cache/ba1/2a/1c/9ee5db6d1bceca7fa6638fb8abde", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/4b/7b/656bbbcb41f7b43eeee0d0775d9a", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f4/3e/b48cab42185c07ff6bfc355f3e5e", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d6/9e/c544d5d86c20a42bcee9f7be1cde", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d1/f1/24aaba8bd77035b9d8601eaea3cb", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/39/1f/6a762fd0ccc4ca62a2b7a51f6cc4", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1a/5e/3b08dab2bffd74edbe744d3717a3", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/4f/f146682e88224ba08219b0ebadc4", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/8b/351d1a6de44b45c06e85b39198a1", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c4/55/0328e26e65974ee613eb0ff8a99e", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fc/4e/3ff90a44e988e3db7ea66ca4f073", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4c/b8/5d909139a0fad91c70c6f870feae", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/16/30/16502e5f928405c6d44c0f1a24bd", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/71/bc/546d02a06b6939c3112e155db26c", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/ea/86/eb5c10d57047ee32a82ac3c3790a", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/50/9a/4eef71525e706d4a971c3214422b", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/40/ee/9e6425089e61ff8027871016eeb4", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/7a/b2/d19573e4357cdf109b4e2af43118", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/42/a3/d08f3b7a1594bb1ba4f2ef60dc6e", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/25/45/82f2db0fef5a8df7cb5e71ba4d4c", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/81/14/0121acd7c0cfc62d9c4b51ce60bb", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/2f/be/56cbff27830a18d6d60ef31c1cdd", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f9/e1/344297c240047057658d77dab2c3", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/df/1e/0e166ac6bde0400abf6cf238d4f5", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/cd/5f/62fa669b1054034a39d501ddc8f3", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/a0/c6/17efa1b0fa2d708d6875a57e7d48", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/ef/ea/806a19fe00441dc382954a3f3080", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/93/6e/22f7fc9f33056a672f58bfbe8402", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/40/e8/03cace193459c0635f1342b28b53", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/5a/17/125467b6c2b884e96a5f255466a6", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/23/af/cd64e4cdd02aed0f7c55167fb994", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/11/bc/b5de2f3ea4f68f420efd8e2f8672", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8e/b1/7e170050323d9e08a5387fb61728", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/12/89/996eb56a1eac10bc5eef98ceb307", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/61/3ea177ccbfca5b78faacd6106324", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a0/e8/ec660025b4b61eb3f105fbe3915a", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/87/9e/f60d6c7c8097e91f1b75432a96fd", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/80/59/9f5d6da1bfc7e8502ff8faf98371", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/87/3e/b431a2c8ff6a6ab647772c2874d8", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/1c/09/b6bcc16ecdd3b3bde138a7975f84", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/3c/9e/aae04414e59968b1200e45dc490a", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/4c/5b/e6f257859efef56c7bf8a16efb8c", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/be/ac/470e69d1b87eb9a6bb33d2039c4e", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/91/e9/2fc1d723e470d368a4160ed03f67", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/67/2c/ed2086d173cc6e75bd0df57f430c", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c7/d0/2ed1069a23bc3f2e044e0eb6d493", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/57/5965c82b8374280182436f235aac", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/97/ca/30e53a2369274ab60e4f9f764476", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/b7/16/5bac6aacbe4f663a2ff842338eab", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/cd/49/d11935a48d1d6e2847ab6a51b4fa", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/a1/8a/3b50352ea71fa172f5e32fb60005", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/f0/3c/9e1731eaebd85e6b70ac00113f0a", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/6d/5e/4fa8e18fb7a5e1d41e214a354081", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/25/21/98f151d2018cb4394cf1b533afd8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/23/53/214f66c1cb5aeace50a7ecc94572", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/92/54/9be16e024bf4a6bc1015c487402c", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/42/ae/47ec74d1efe9b02bf7fc88a310fb", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index f26bfc47..1f6d2126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21078, api 8, 2023-06-08) +### 1.7.20 (build 21079, api 8, 2023-06-08) - This seems like a good time for a `refactoring` release in anticipation of changes coming in 1.8. Basically this means that a lot of things will be @@ -309,6 +309,10 @@ windows. Please holler if you are still seeing this. This file gets written for debugging whenever the logic thread remains unresponsive for several seconds. +- (build 21078) Custom system scripts dirs works again (complete copies of app + system scripts living in your mods directory under `sys/$(YOUR_APP_VERSION)`. + Tools for creating/destroying these setups are now at `babase.modutils` (they + had been placed under bauiv1 but that was just silly). ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/src/assets/.asset_manifest_public.json b/src/assets/.asset_manifest_public.json index e1420658..8cb58fba 100644 --- a/src/assets/.asset_manifest_public.json +++ b/src/assets/.asset_manifest_public.json @@ -28,6 +28,7 @@ "ba_data/python/babase/__pycache__/_text.cpython-311.opt-1.pyc", "ba_data/python/babase/__pycache__/_workspace.cpython-311.opt-1.pyc", "ba_data/python/babase/__pycache__/internal.cpython-311.opt-1.pyc", + "ba_data/python/babase/__pycache__/modutils.cpython-311.opt-1.pyc", "ba_data/python/babase/_accountv2.py", "ba_data/python/babase/_app.py", "ba_data/python/babase/_appcomponent.py", @@ -58,6 +59,7 @@ "ba_data/python/babase/_text.py", "ba_data/python/babase/_workspace.py", "ba_data/python/babase/internal.py", + "ba_data/python/babase/modutils.py", "ba_data/python/baclassic/__init__.py", "ba_data/python/baclassic/__pycache__/__init__.cpython-311.opt-1.pyc", "ba_data/python/baclassic/__pycache__/_accountv1.cpython-311.opt-1.pyc", @@ -346,10 +348,8 @@ "ba_data/python/bauiv1/__init__.py", "ba_data/python/bauiv1/__pycache__/__init__.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/__pycache__/_hooks.cpython-311.opt-1.pyc", - "ba_data/python/bauiv1/__pycache__/modutils.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/__pycache__/onscreenkeyboard.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/_hooks.py", - "ba_data/python/bauiv1/modutils.py", "ba_data/python/bauiv1/onscreenkeyboard.py", "ba_data/python/bauiv1/ui/__init__.py", "ba_data/python/bauiv1/ui/__pycache__/__init__.cpython-311.opt-1.pyc", diff --git a/src/assets/Makefile b/src/assets/Makefile index 439718ea..8b389157 100644 --- a/src/assets/Makefile +++ b/src/assets/Makefile @@ -174,6 +174,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/babase/_text.py \ $(BUILD_DIR)/ba_data/python/babase/_workspace.py \ $(BUILD_DIR)/ba_data/python/babase/internal.py \ + $(BUILD_DIR)/ba_data/python/babase/modutils.py \ $(BUILD_DIR)/ba_data/python/baclassic/__init__.py \ $(BUILD_DIR)/ba_data/python/baclassic/_accountv1.py \ $(BUILD_DIR)/ba_data/python/baclassic/_achievement.py \ @@ -310,7 +311,6 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/batemplatefs/_subsystem.py \ $(BUILD_DIR)/ba_data/python/bauiv1/__init__.py \ $(BUILD_DIR)/ba_data/python/bauiv1/_hooks.py \ - $(BUILD_DIR)/ba_data/python/bauiv1/modutils.py \ $(BUILD_DIR)/ba_data/python/bauiv1/onscreenkeyboard.py \ $(BUILD_DIR)/ba_data/python/bauiv1/ui/__init__.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__init__.py \ @@ -446,6 +446,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/_text.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/_workspace.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/internal.cpython-311.opt-1.pyc \ + $(BUILD_DIR)/ba_data/python/babase/__pycache__/modutils.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/_accountv1.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/_achievement.cpython-311.opt-1.pyc \ @@ -582,7 +583,6 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/batemplatefs/__pycache__/_subsystem.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/_hooks.cpython-311.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/modutils.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/onscreenkeyboard.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/ui/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/__init__.cpython-311.opt-1.pyc \ diff --git a/src/assets/ba_data/python/babase/_app.py b/src/assets/ba_data/python/babase/_app.py index 12b17c34..239a5611 100644 --- a/src/assets/ba_data/python/babase/_app.py +++ b/src/assets/ba_data/python/babase/_app.py @@ -482,9 +482,12 @@ class App: from babase import _asyncio from babase import _appconfig from babase._apputils import log_dumped_app_state, AppHealthMonitor + import babase._env assert _babase.in_logic_thread() + babase._env.on_app_launching() + self._aioloop = _asyncio.setup_asyncio() self.health_monitor = AppHealthMonitor() diff --git a/src/assets/ba_data/python/babase/_env.py b/src/assets/ba_data/python/babase/_env.py index 02c225e7..a651dc88 100644 --- a/src/assets/ba_data/python/babase/_env.py +++ b/src/assets/ba_data/python/babase/_env.py @@ -64,8 +64,8 @@ def on_native_module_import() -> None: def setup_env_for_app_run() -> None: """Set stuff such as interrupt handlers for a run of the app.""" import gc - import _babase import baenv + import _babase global _g_babase_app_started # pylint: disable=global-statement @@ -136,6 +136,21 @@ def setup_env_for_app_run() -> None: asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) +def on_app_launching() -> None: + """Called when the app reaches the launching state.""" + import _babase + import baenv + + assert _babase.in_logic_thread() + + # Let the user know if the app python dir is a custom one. + if baenv.g_user_system_scripts_dir is not None: + _babase.screenmessage( + f"Using user system scripts: '{baenv.g_user_system_scripts_dir}'", + color=(0.6, 0.6, 1.0), + ) + + def _feed_logs_to_babase(log_handler: LogHandler) -> None: """Route log/print output to internal ballistica console/etc.""" import _babase diff --git a/src/assets/ba_data/python/bauiv1/modutils.py b/src/assets/ba_data/python/babase/modutils.py similarity index 95% rename from src/assets/ba_data/python/bauiv1/modutils.py rename to src/assets/ba_data/python/babase/modutils.py index b89725b3..2c5d5335 100644 --- a/src/assets/ba_data/python/bauiv1/modutils.py +++ b/src/assets/ba_data/python/babase/modutils.py @@ -7,7 +7,6 @@ from typing import TYPE_CHECKING import os import _babase -import _bauiv1 if TYPE_CHECKING: from typing import Sequence @@ -50,7 +49,7 @@ def _request_storage_permission() -> bool: from babase._mgen.enums import Permission if not _babase.have_permission(Permission.STORAGE): - _bauiv1.getsound('error').play() + _babase.getsimplesound('error').play() _babase.screenmessage( Lstr(resource='storagePermissionAccessText'), color=(1, 0, 0) ) @@ -103,7 +102,7 @@ def show_user_scripts() -> None: # On a few platforms we try to open the dir in the UI. if app.classic is not None and app.classic.platform in ['mac', 'windows']: - _bauiv1.open_dir_externally(app.python_directory_user) + _babase.open_dir_externally(app.python_directory_user) # Otherwise we just print a pretty version of it. else: @@ -111,9 +110,9 @@ def show_user_scripts() -> None: def create_user_system_scripts() -> None: - """Set up a copy of Ballistica system scripts under your user scripts dir. + """Set up a copy of Ballistica app scripts under user scripts dir. - (for editing and experiment with) + (for editing and experimenting) """ import shutil @@ -180,7 +179,7 @@ def delete_user_system_scripts() -> None: f' scripts. (use babase.quit() to exit the game)' ) else: - print('User system scripts not found.') + print(f"User system scripts not found at '{path}'.") # If the sys path is empty, kill it. dpath = app.python_directory_user + '/sys' diff --git a/src/assets/ba_data/python/baclassic/_benchmark.py b/src/assets/ba_data/python/baclassic/_benchmark.py index 3ed6532e..5b36006c 100644 --- a/src/assets/ba_data/python/baclassic/_benchmark.py +++ b/src/assets/ba_data/python/baclassic/_benchmark.py @@ -59,7 +59,7 @@ def run_stress_test( round_duration: int = 30, ) -> None: """Run a stress test.""" - from bauiv1 import modutils + from babase import modutils from babase._general import Call _babase.screenmessage( diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 1696032d..53bee0d5 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,11 +28,12 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21078 +TARGET_BALLISTICA_BUILD = 21079 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None g_paths_set_failed = False # pylint: disable=invalid-name +g_user_system_scripts_dir: str | None = None # pylint: disable=invalid-name @dataclass @@ -43,6 +44,7 @@ class EnvConfig: data_dir: str user_python_dir: str | None app_python_dir: str | None + standard_app_python_dir: str site_python_dir: str | None log_handler: LogHandler | None @@ -76,6 +78,7 @@ def configure( affecting where those modules get loaded from. """ # pylint: disable=too-many-branches + # pylint: disable=too-many-locals global _g_env_config # pylint: disable=global-statement if _g_env_config is not None: @@ -125,6 +128,10 @@ def configure( # Ok now Python paths. + # By default, app-python-dir is simply ba_data/python under + # data-dir. + standard_app_python_dir = str(Path(data_dir, 'ba_data', 'python')) + # If _babase has already been imported, there's not much we can do # at this point aside from complain and inform for next time. if '_babase' in sys.modules: @@ -141,10 +148,8 @@ def configure( # Ok; _babase hasn't been imported yet so we can muck with # Python paths. - # By default, app-python-dir is simply ba_data/python under - # data-dir. if app_python_dir is None: - app_python_dir = str(Path(data_dir, 'ba_data', 'python')) + app_python_dir = standard_app_python_dir # Likewise site-python-dir defaults to ba_data/python-site-packages. if site_python_dir is None: @@ -156,7 +161,18 @@ def configure( if user_python_dir is None: user_python_dir = str(Path(config_dir, 'mods')) - # Ok, now add these to sys.path. + # Wherever our user_python_dir is, if we find a sys/FOO dir + # under it where FOO matches our version, use that as our + # app_python_dir. + check_dir = os.path.join( + user_python_dir, 'sys', TARGET_BALLISTICA_VERSION + ) + if os.path.isdir(check_dir): + global g_user_system_scripts_dir # pylint: disable=global-statement + g_user_system_scripts_dir = check_dir + app_python_dir = check_dir + + # Ok, now apply these to sys.path. # First off, strip out any instances of the path containing this # module. We will probably be re-adding the same path in a @@ -194,6 +210,7 @@ def configure( data_dir=data_dir, user_python_dir=user_python_dir, app_python_dir=app_python_dir, + standard_app_python_dir=standard_app_python_dir, site_python_dir=site_python_dir, log_handler=log_handler, ) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index 38e58c2e..1b3c96d3 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -188,7 +188,7 @@ class AdvancedSettingsWindow(bui.Window): @staticmethod def _preload_modules() -> None: """Preload modules we use (called in bg thread).""" - from bauiv1 import modutils as _unused2 + from babase import modutils as _unused2 from bauiv1lib import config as _unused1 from bauiv1lib.settings import vrtesting as _unused3 from bauiv1lib.settings import nettesting as _unused4 @@ -235,7 +235,7 @@ class AdvancedSettingsWindow(bui.Window): # pylint: disable=too-many-locals from bauiv1lib.config import ConfigCheckBox - from bauiv1.modutils import show_user_scripts + from babase.modutils import show_user_scripts plus = bui.app.plus assert plus is not None diff --git a/src/ballistica/base/python/methods/python_methods_app.cc b/src/ballistica/base/python/methods/python_methods_app.cc index 2e5d562d..fb4f16dd 100644 --- a/src/ballistica/base/python/methods/python_methods_app.cc +++ b/src/ballistica/base/python/methods/python_methods_app.cc @@ -207,6 +207,10 @@ static auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } + if (!g_base->logic->event_loop()) { + throw Exception("pushcall cannot be used before start-app is called."); + } + // 'raw' mode does no thread checking and no context saves/restores. if (raw) { assert(Python::HaveGIL()); diff --git a/src/ballistica/base/python/methods/python_methods_misc.cc b/src/ballistica/base/python/methods/python_methods_misc.cc index 47e553fa..250408b5 100644 --- a/src/ballistica/base/python/methods/python_methods_misc.cc +++ b/src/ballistica/base/python/methods/python_methods_misc.cc @@ -1414,6 +1414,34 @@ static PyMethodDef PyNativeStackTraceDef = { "Only use them for debugging.", }; +// -------------------------- open_dir_externally ------------------------------ + +static auto PyOpenDirExternally(PyObject* self, PyObject* args, + PyObject* keywds) -> PyObject* { + BA_PYTHON_TRY; + char* path = nullptr; + static const char* kwlist[] = {"path", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", + const_cast(kwlist), &path)) { + return nullptr; + } + g_core->platform->OpenDirExternally(path); + Py_RETURN_NONE; + BA_PYTHON_CATCH; +} + +static PyMethodDef PyOpenDirExternallyDef = { + "open_dir_externally", // name + (PyCFunction)PyOpenDirExternally, // method + METH_VARARGS | METH_KEYWORDS, // flags + + "open_dir_externally(path: str) -> None\n" + "\n" + "(internal)\n" + "\n" + "Open the provided dir in the default external app.", +}; + // ----------------------------------------------------------------------------- auto PythonMethodsMisc::GetMethods() -> std::vector { @@ -1468,6 +1496,7 @@ auto PythonMethodsMisc::GetMethods() -> std::vector { PyGetSimpleSoundDef, PyHasTouchScreenDef, PyNativeStackTraceDef, + PyOpenDirExternallyDef, }; } diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index f1ff0f34..28c1c0a8 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -251,32 +251,6 @@ auto CorePlatform::GetDefaultVolatileDataDirectory() -> std::string { auto CorePlatform::GetAppPythonDirectory() -> std::optional { BA_PRECONDITION(have_ba_env_vals_); return ba_env_app_python_dir_; - - // TODO(ericf) - recreate this behavior within baenv. - // // If there is a sys/VERSION in the user-python dir we use that. - // app_python_dir_ = GetUserPythonDirectoryMonolithicDefault() + BA_DIRSLASH - // + "sys" + BA_DIRSLASH + kEngineVersion; - - // // Fall back to our default if that doesn't exist. - // if (FilePathExists(app_python_dir_)) { - // using_custom_app_python_dir_ = true; - // Log(LogLevel::kInfo, - // "Using custom app Python path: '" - // + (GetUserPythonDirectoryMonolithicDefault() + BA_DIRSLASH + - // "sys" - // + BA_DIRSLASH + kEngineVersion) - // + "'."); - - // } else { - // // Special case: if CWD is '.', omit the './' for a prettier path. - // app_python_dir_ = std::string("ba_data") + BA_DIRSLASH + "python"; - // auto data_dir = GetDataDirectoryMonolithicDefault(); - // if (data_dir != ".") { - // app_python_dir_ = data_dir + BA_DIRSLASH + app_python_dir_; - // } - // } - // } - // return app_python_dir_; } auto CorePlatform::GetSitePythonDirectory() -> std::optional { @@ -1250,6 +1224,14 @@ void CorePlatform::SetBaEnvVals(const PythonRef& ref) { ba_env_site_python_dir_ = ref.GetAttr("site_python_dir").ValueAsOptionalString(); + // Consider app-python-dir 'custom' if baenv provided a value + // for it AND that value differs from baenv's default. + auto standard_app_python_dir = + ref.GetAttr("standard_app_python_dir").ValueAsString(); + using_custom_app_python_dir_ = + ba_env_app_python_dir_.has_value() + && *ba_env_app_python_dir_ != standard_app_python_dir; + // Ok, now look for the existence of ba_data in the dir we've got. auto fullpath = ba_env_data_dir_ + BA_DIRSLASH + "ba_data"; if (!FilePathExists(fullpath)) { diff --git a/src/ballistica/core/platform/core_platform.h b/src/ballistica/core/platform/core_platform.h index 24d0fc4a..d9f812cc 100644 --- a/src/ballistica/core/platform/core_platform.h +++ b/src/ballistica/core/platform/core_platform.h @@ -546,7 +546,7 @@ class CorePlatform { private: bool is_stdin_a_terminal_{}; - bool using_custom_app_python_dir_{}; // FIXME not wired up currently. + bool using_custom_app_python_dir_{}; bool have_has_touchscreen_value_{}; bool have_touchscreen_{}; bool is_tegra_k1_{}; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index f532b334..eaca08e5 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 21078; +const int kEngineBuildNumber = 21079; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc index aba4e9c3..f736ac58 100644 --- a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc +++ b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc @@ -2799,34 +2799,6 @@ static PyMethodDef PyOpenFileExternallyDef = { "Open the provided file in the default external app.", }; -// -------------------------- open_dir_externally ------------------------------ - -static auto PyOpenDirExternally(PyObject* self, PyObject* args, - PyObject* keywds) -> PyObject* { - BA_PYTHON_TRY; - char* path = nullptr; - static const char* kwlist[] = {"path", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", - const_cast(kwlist), &path)) { - return nullptr; - } - g_core->platform->OpenDirExternally(path); - Py_RETURN_NONE; - BA_PYTHON_CATCH; -} - -static PyMethodDef PyOpenDirExternallyDef = { - "open_dir_externally", // name - (PyCFunction)PyOpenDirExternally, // method - METH_VARARGS | METH_KEYWORDS, // flags - - "open_dir_externally(path: str) -> None\n" - "\n" - "(internal)\n" - "\n" - "Open the provided dir in the default external app.", -}; - // ----------------------------- console_print --------------------------------- static auto PyConsolePrint(PyObject* self, PyObject* args) -> PyObject* { @@ -2899,7 +2871,6 @@ auto PythonMethodsUIV1::GetMethods() -> std::vector { PyGetQRCodeTextureDef, PyIsPartyIconVisibleDef, PyConsolePrintDef, - PyOpenDirExternallyDef, PyOpenFileExternallyDef, PyOpenURLDef, PyBackPressDef,