diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b07cf1c..16240d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,7 +69,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: godot-python-${{ matrix.platform }}-${{ matrix.arch }} - path: bin/**/* + path: ${{ github.workspace }}/build/** retention-days: 30 - name: Upload artifacts (Windows) @@ -78,9 +78,9 @@ jobs: with: name: godot-python-${{ matrix.platform }}-${{ matrix.arch }} path: | - bin/**/* - !bin/**/*.lib - !bin/**/*.exp + ${{ github.workspace }}/build/** + !${{ github.workspace }}/build/**/*.lib + !${{ github.workspace }}/build/**/*.exp retention-days: 30 - name: Upload artifacts (macOS) @@ -88,7 +88,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: godot-python-${{ matrix.platform }}-${{ matrix.arch }} - path: bin/**/* + path: ${{ github.workspace }}/build/**/* retention-days: 30 - name: Release artifact diff --git a/.gitignore b/.gitignore index c0ff609..88f0319 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,10 @@ *.so -/bin/ +/build/addons/godot-python/**/* +!/build/addons/godot-python/* +!/build/addons/godot-python/**/ +!/build/addons/godot-python/**/*.plist gdextension_interface.h extension_api.json diff --git a/SConstruct b/SConstruct index cafc9c2..fc89067 100644 --- a/SConstruct +++ b/SConstruct @@ -16,6 +16,8 @@ from tools.build import build_utils EnsureSConsVersion(4, 0) +lib_name = "godot-python" + try: Import("env") @@ -322,7 +324,7 @@ def _prepare_python(target, source, env): prepare_python_alias = env.Alias("prepare_python", [ Builder(action = Action(_prepare_python, "Preparing Python"))( env, - target = f'bin/{prepared_python_config.name}/python312.zip', # XXX: version + target = f'build/addons/{lib_name}/{prepared_python_config.name}/python312.zip', # XXX: version source = [ fetch_python_alias[0].children(), prepare_python.__file__, @@ -366,8 +368,10 @@ env.Append(CPPDEFINES = [f'PYGODOT_ARCH=\\"{env["arch"]}\\"']) def _append_python_config(env, target, **kwargs): - src_dir = generated_path / 'python' / prepared_python_config.name - env['python'] = os.fspath(prepare_python.get_python_for_platform(env['platform'], env['arch'], src_dir)) + python_dir = generated_path / 'python' / prepared_python_config.name / 'python' + env['python'] = os.fspath(prepare_python.get_python_for_platform( + env['platform'], env['arch'], python_dir=python_dir + )) from tools.build import python_config _config_vars = python_config.get_python_config_vars(env) @@ -407,10 +411,10 @@ env["suffix"] = suffix env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] -library_name = "libgodot-python{}{}".format(env["suffix"], env["SHLIBSUFFIX"]) +binary_name = f"{env.subst('$SHLIBPREFIX')}{lib_name}.{env['platform']}.{env['arch']}{env.subst('$SHLIBSUFFIX')}" library = env.SharedLibrary( - target = f"bin/{env['platform']}-{env['arch']}/{library_name}", + target = f"build/addons/{lib_name}/{env['platform']}-{env['arch']}/{binary_name}", source = sources, ) diff --git a/build/addons/godot-python/godot-python.gdextension b/build/addons/godot-python/godot-python.gdextension new file mode 100644 index 0000000..0b4a8b0 --- /dev/null +++ b/build/addons/godot-python/godot-python.gdextension @@ -0,0 +1,19 @@ +[configuration] + +compatibility_minimum = 4.2 +entry_symbol = "python_extension_init" + +[libraries] + +macos.x86_64 = "macos-x86_64/libgodot-python.macos.x86_64.dylib" +macos.arm64 = "macos-arm64/libgodot-python.macos.arm64.dylib" + +windows.x86_32 = "windows-x86_32/godot-python.windows.x86_32.dll" +windows.x86_64 = "windows-x86_64/godot-python.windows.x86_64.dll" + +linux.x86_64 = "linux-x86_64/libgodot-python.linux.x86_64.so" +linux.arm64 = "linux-arm64/libgodot-python.linux.arm64.so" +linux.rv64 = "linux-rv64/libgodot-python.linux.rv64.so" + +android.x86_64 = "android-x86_64/libgodot-python.android.x86_64.so" +android.arm64 = "android-arm64/libgodot-python.android.arm64.so" diff --git a/docs/usage/installation.md b/docs/usage/installation.md index 755faf6..0999077 100644 --- a/docs/usage/installation.md +++ b/docs/usage/installation.md @@ -21,7 +21,7 @@ _godot-python is in early development and does not yet have an official release. ## From nightly builds (GitHub Actions) -You can download nightly builds from [GitHub Actions](https://github.com/maiself/godot-python-extension/actions). Keep in mind nightly builds may be unstable and are not recommended for production setups. Right now, they are also not packaged like regular release builds, and may not be usable out of the box. +You can download nightly builds from [GitHub Actions](https://github.com/maiself/godot-python-extension/actions). Keep in mind nightly builds may be unstable and are not recommended for production setups. ## As a git submodule diff --git a/test/addons b/test/addons new file mode 120000 index 0000000..cd7536f --- /dev/null +++ b/test/addons @@ -0,0 +1 @@ +../build/addons \ No newline at end of file diff --git a/test/bin b/test/bin deleted file mode 120000 index 19f285a..0000000 --- a/test/bin +++ /dev/null @@ -1 +0,0 @@ -../bin \ No newline at end of file diff --git a/test/python.gdextension b/test/python.gdextension deleted file mode 100644 index dc81dcd..0000000 --- a/test/python.gdextension +++ /dev/null @@ -1,19 +0,0 @@ -[configuration] - -compatibility_minimum = 4.2 -entry_symbol = "python_extension_init" - -[libraries] - -macos.x86_64 = "res://bin/macos-x86_64/libgodot-python.macos.x86_64.dylib" -macos.arm64 = "res://bin/macos-arm64/libgodot-python.macos.arm64.dylib" - -windows.x86_32 = "res://bin/windows-x86_32/libgodot-python.windows.x86_32.dll" -windows.x86_64 = "res://bin/windows-x86_64/libgodot-python.windows.x86_64.dll" - -linux.x86_64 = "res://bin/linux-x86_64/libgodot-python.linux.x86_64.so" -linux.arm64 = "res://bin/linux-arm64/libgodot-python.linux.arm64.so" -linux.rv64 = "res://bin/linux-rv64/libgodot-python.linux.rv64.so" - -android.x86_64 = "res://bin/android-x86_64/libgodot-python.android.x86_64.so" -android.arm64 = "res://bin/android-arm64/libgodot-python.android.arm64.so" diff --git a/tools/build/prepare_python.py b/tools/build/prepare_python.py index 651f36f..ca664bc 100644 --- a/tools/build/prepare_python.py +++ b/tools/build/prepare_python.py @@ -133,13 +133,9 @@ def prepare_for_platform(platform: str, arch: str, shutil.make_archive(dest_dir / 'python312', 'zip', root_dir=src / config.python_lib_dir, base_dir='') -def get_python_for_platform(platform: str, arch: str, src_dir: pathlib.Path) -> pathlib.Path: +def get_python_for_platform(platform: str, arch: str, python_dir: pathlib.Path) -> pathlib.Path: config = platform_configs[(platform, arch)] - - src = src_dir / 'python' - - return src / config.executable - + return python_dir / config.executable def main():