Skip to content

Commit b03497b

Browse files
committed
Adapt a build/addons-based file structure that makes releases suitable for direct deployment, and prevents multiple binaries from being loaded in test if multiple subsequent builds are made.
1 parent 74eaeea commit b03497b

File tree

9 files changed

+41
-38
lines changed

9 files changed

+41
-38
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
uses: actions/upload-artifact@v4
7070
with:
7171
name: godot-python-${{ matrix.platform }}-${{ matrix.arch }}
72-
path: bin/**/*
72+
path: ${{ github.workspace }}/build/**
7373
retention-days: 30
7474

7575
- name: Upload artifacts (Windows)
@@ -78,17 +78,17 @@ jobs:
7878
with:
7979
name: godot-python-${{ matrix.platform }}-${{ matrix.arch }}
8080
path: |
81-
bin/**/*
82-
!bin/**/*.lib
83-
!bin/**/*.exp
81+
${{ github.workspace }}/build/**
82+
!${{ github.workspace }}/build/**/*.lib
83+
!${{ github.workspace }}/build/**/*.exp
8484
retention-days: 30
8585

8686
- name: Upload artifacts (macOS)
8787
if: matrix.os == 'macos-latest'
8888
uses: actions/upload-artifact@v4
8989
with:
9090
name: godot-python-${{ matrix.platform }}-${{ matrix.arch }}
91-
path: bin/**/*
91+
path: ${{ github.workspace }}/build/**/*
9292
retention-days: 30
9393

9494
- name: Release artifact

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
*.so
55

6-
/bin/
6+
/build/addons/godot-python/**/*
7+
!/build/addons/godot-python/*
8+
!/build/addons/godot-python/**/
9+
!/build/addons/godot-python/**/*.plist
710

811
gdextension_interface.h
912
extension_api.json

SConstruct

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ from tools.build import build_utils
1616

1717
EnsureSConsVersion(4, 0)
1818

19+
lib_name = "godot-python"
20+
1921

2022
try:
2123
Import("env")
@@ -322,7 +324,7 @@ def _prepare_python(target, source, env):
322324
prepare_python_alias = env.Alias("prepare_python", [
323325
Builder(action = Action(_prepare_python, "Preparing Python"))(
324326
env,
325-
target = f'bin/{prepared_python_config.name}/python312.zip', # XXX: version
327+
target = f'build/addons/{lib_name}/{prepared_python_config.name}/python312.zip', # XXX: version
326328
source = [
327329
fetch_python_alias[0].children(),
328330
prepare_python.__file__,
@@ -366,8 +368,10 @@ env.Append(CPPDEFINES = [f'PYGODOT_ARCH=\\"{env["arch"]}\\"'])
366368

367369

368370
def _append_python_config(env, target, **kwargs):
369-
src_dir = generated_path / 'python' / prepared_python_config.name
370-
env['python'] = os.fspath(prepare_python.get_python_for_platform(env['platform'], env['arch'], src_dir))
371+
python_dir = generated_path / 'python' / prepared_python_config.name / 'python'
372+
env['python'] = os.fspath(prepare_python.get_python_for_platform(
373+
env['platform'], env['arch'], python_dir=python_dir
374+
))
371375

372376
from tools.build import python_config
373377
_config_vars = python_config.get_python_config_vars(env)
@@ -407,10 +411,10 @@ env["suffix"] = suffix
407411

408412
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
409413

410-
library_name = "libgodot-python{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
414+
binary_name = f"{env.subst('$SHLIBPREFIX')}{lib_name}.{env['platform']}.{env['arch']}{env.subst('$SHLIBSUFFIX')}"
411415

412416
library = env.SharedLibrary(
413-
target = f"bin/{env['platform']}-{env['arch']}/{library_name}",
417+
target = f"build/addons/{lib_name}/{env['platform']}-{env['arch']}/{binary_name}",
414418
source = sources,
415419
)
416420

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[configuration]
2+
3+
compatibility_minimum = 4.2
4+
entry_symbol = "python_extension_init"
5+
6+
[libraries]
7+
8+
macos.x86_64 = "macos-x86_64/libgodot-python.macos.x86_64.dylib"
9+
macos.arm64 = "macos-arm64/libgodot-python.macos.arm64.dylib"
10+
11+
windows.x86_32 = "windows-x86_32/godot-python.windows.x86_32.dll"
12+
windows.x86_64 = "windows-x86_64/godot-python.windows.x86_64.dll"
13+
14+
linux.x86_64 = "linux-x86_64/libgodot-python.linux.x86_64.so"
15+
linux.arm64 = "linux-arm64/libgodot-python.linux.arm64.so"
16+
linux.rv64 = "linux-rv64/libgodot-python.linux.rv64.so"
17+
18+
android.x86_64 = "android-x86_64/libgodot-python.android.x86_64.so"
19+
android.arm64 = "android-arm64/libgodot-python.android.arm64.so"

docs/usage/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _godot-python is in early development and does not yet have an official release.
2121

2222
## From nightly builds (GitHub Actions)
2323

24-
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.
24+
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.
2525

2626
## As a git submodule
2727

test/addons

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../build/addons

test/bin

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/python.gdextension

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

tools/build/prepare_python.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,9 @@ def prepare_for_platform(platform: str, arch: str,
133133
shutil.make_archive(dest_dir / 'python312', 'zip', root_dir=src / config.python_lib_dir, base_dir='')
134134

135135

136-
def get_python_for_platform(platform: str, arch: str, src_dir: pathlib.Path) -> pathlib.Path:
136+
def get_python_for_platform(platform: str, arch: str, python_dir: pathlib.Path) -> pathlib.Path:
137137
config = platform_configs[(platform, arch)]
138-
139-
src = src_dir / 'python'
140-
141-
return src / config.executable
142-
138+
return python_dir / config.executable
143139

144140

145141
def main():

0 commit comments

Comments
 (0)