Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt a build/addons-based file structure #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -78,17 +78,17 @@ 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)
if: matrix.os == 'macos-latest'
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
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ from tools.build import build_utils

EnsureSConsVersion(4, 0)

lib_name = "godot-python"


try:
Import("env")
Expand Down Expand Up @@ -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__,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)

Expand Down
19 changes: 19 additions & 0 deletions build/addons/godot-python/godot-python.gdextension
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion docs/usage/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/addons
1 change: 0 additions & 1 deletion test/bin

This file was deleted.

19 changes: 0 additions & 19 deletions test/python.gdextension

This file was deleted.

8 changes: 2 additions & 6 deletions tools/build/prepare_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down