Skip to content

Commit 7ab4ad3

Browse files
authored
Merge pull request #5 from apple1417/master
change init script/pyexec dir to be relative to pyunrealsdk.dll
2 parents 6ad7180 + c5ad90c commit 7ab4ad3

File tree

4 files changed

+10
-44
lines changed

4 files changed

+10
-44
lines changed

prepare_release.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Iterator
99
from functools import cache
1010
from io import BytesIO
11+
from os import path
1112
from pathlib import Path
1213
from zipfile import ZIP_DEFLATED, ZipFile
1314

@@ -21,9 +22,6 @@
2122
ZIP_SETTINGS_FOLDER = ZIP_MODS_FOLDER / "settings"
2223
ZIP_EXECUTABLE_FOLDER = Path("Binaries")
2324
ZIP_PLUGINS_FOLDER = ZIP_EXECUTABLE_FOLDER / "Plugins"
24-
ZIP_PROXY_INIT_SCRIPT_FOLDERS = [
25-
ZIP_EXECUTABLE_FOLDER / ZIP_MODS_FOLDER,
26-
]
2725

2826
# The base CMake directories - these need the preset added after
2927
BUILD_DIR_BASE = THIS_FOLDER / "out" / "build"
@@ -40,7 +38,6 @@
4038

4139
# And there are a few extra files which we want which aren't matched by the above
4240
INIT_SCRIPT = MODS_FOLDER / "__main__.py"
43-
PROXY_INIT_SCRIPT = MODS_FOLDER / "proxy__main__.py"
4441
SETTINGS_GITIGNORE = MODS_FOLDER / "settings" / ".gitignore"
4542
STUBS_DIR = THIS_FOLDER / "libs" / "pyunrealsdk" / "stubs"
4643
STUBS_LICENSE = THIS_FOLDER / "libs" / "pyunrealsdk" / "LICENSE"
@@ -222,17 +219,10 @@ def zip_config_file(zip_file: ZipFile) -> None:
222219
Args:
223220
zip_file: The zip file to add the config file to.
224221
"""
225-
# When launching via Steam, the CWD is (sometimes) `<steam>\Borderlands`. When launching via Mod
226-
# Organiser, or by running the exe directly, it's `Borderlands\Binaries`.
227-
# Stick with Steam as the default, since if we're not using Steam, the path this checks will
228-
# still be inside the game folder.
229-
init_script_path = str(ZIP_MODS_FOLDER / INIT_SCRIPT.name)
230-
pyexec_root = str(ZIP_MODS_FOLDER)
231-
232-
# Copy the proxy script to all the spots the relative path might otherwise end up
233-
for path in ZIP_PROXY_INIT_SCRIPT_FOLDERS:
234-
zip_file.write(PROXY_INIT_SCRIPT, path / INIT_SCRIPT.name)
235-
zip_file.writestr(str(path / "Wrong folder, you cannot place sdk mods here!.txt"), "")
222+
# Path.relative_to doesn't work when where's no common base, need to use os.path
223+
# These paths are relative to the plugins folder
224+
init_script_path = path.relpath(ZIP_MODS_FOLDER / INIT_SCRIPT.name, ZIP_PLUGINS_FOLDER)
225+
pyexec_root = path.relpath(ZIP_MODS_FOLDER, ZIP_PLUGINS_FOLDER)
236226

237227
version_number = tomllib.loads(MANAGER_PYPROJECT.read_text())["project"]["version"]
238228
git_version = get_git_repo_version()

src/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ModInfo:
5252
def init_debugpy() -> None:
5353
"""Tries to import and setup debugpy. Does nothing if unable to."""
5454
try:
55-
import debugpy # pyright: ignore[reportMissingImports] # noqa: T100
55+
import debugpy # pyright: ignore[reportMissingImports] # noqa: PLC0415, T100
5656

5757
debugpy.listen( # pyright: ignore[reportUnknownMemberType] # noqa: T100
5858
("localhost", 5678),
@@ -70,13 +70,13 @@ def init_debugpy() -> None:
7070
)
7171

7272
# Make WrappedArrays resolve the same as lists
73-
from _pydevd_bundle.pydevd_resolver import ( # pyright: ignore[reportMissingImports]
73+
from _pydevd_bundle.pydevd_resolver import ( # pyright: ignore[reportMissingImports] # noqa: PLC0415
7474
tupleResolver, # pyright: ignore[reportUnknownVariableType]
7575
)
76-
from _pydevd_bundle.pydevd_xml import ( # pyright: ignore[reportMissingImports]
76+
from _pydevd_bundle.pydevd_xml import ( # pyright: ignore[reportMissingImports] # noqa: PLC0415
7777
_TYPE_RESOLVE_HANDLER, # pyright: ignore[reportUnknownVariableType]
7878
)
79-
from unrealsdk.unreal import WrappedArray
79+
from unrealsdk.unreal import WrappedArray # noqa: PLC0415
8080

8181
if not _TYPE_RESOLVE_HANDLER._initialized: # pyright: ignore[reportUnknownMemberType]
8282
_TYPE_RESOLVE_HANDLER._initialize() # pyright: ignore[reportUnknownMemberType]

src/proxy__main__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)