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

Add a briefcase template to pygame-ce #2862

Merged
merged 5 commits into from
May 26, 2024
Merged
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
1 change: 1 addition & 0 deletions buildconfig/stubs/mypy_allow_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pygame\.tests.*

# don't look for stubs for pyinstaller hook
pygame\.__pyinstaller.*
pygame\.__briefcase.*

# don't look for stubs for these private modules either
pygame\.ftfont
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ classifiers = [
[project.entry-points.pyinstaller40]
hook-dirs = 'pygame.__pyinstaller:get_hook_dirs'

[project.entry-points."briefcase.bootstraps"]
pygame_ce = 'pygame.__briefcase.pygame_ce:PygameCEGuiBootstrap'

[build-system]
requires = ["meson-python", "ninja", "cython"]
build-backend = 'mesonpy'
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ commands =
[options.entry_points]
pyinstaller40 =
hook-dirs = pygame.__pyinstaller:get_hook_dirs
briefcase.boostraps =
pygame_ce = pygame.__briefcase.pygame_ce:PygameCEGuiBootstrap

[isort]
include_trailing_comma = True
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,13 +857,15 @@ def run(self):
'pygame.tests.test_utils',
'pygame.docs',
'pygame.examples',
'pygame.__pyinstaller'],
'pygame.__pyinstaller',
'pygame.__briefcase'],
"package_dir": {'pygame': 'src_py',
'pygame._sdl2': 'src_py/_sdl2',
'pygame.tests': 'test',
'pygame.docs': 'docs',
'pygame.examples': 'examples',
'pygame.__pyinstaller': 'src_py/__pyinstaller'},
'pygame.__pyinstaller': 'src_py/__pyinstaller',
'pygame.__briefcase': 'src_py/__briefcase'},
"headers": headers,
"ext_modules": extensions,
"data_files": data_files,
Expand Down
Empty file.
6 changes: 6 additions & 0 deletions src_py/__briefcase/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pure python sources
python_sources = files(
'__init__.py',
'pygame_ce.py',
)
py.install_sources(python_sources, subdir: pg / '__briefcase')
148 changes: 148 additions & 0 deletions src_py/__briefcase/pygame_ce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
from briefcase.bootstraps.base import BaseGuiBootstrap


class PygameCEGuiBootstrap(BaseGuiBootstrap):
display_name_annotation = "does not support iOS/Android deployment"

def app_source(self):
return """\
import importlib.metadata
import os
import sys

import pygame


SCREEN_WIDTH, SCREEN_HEIGHT = 800, 600
BGCOLOR = (255, 255, 255)


def main():
# Linux desktop environments use an app's .desktop file to integrate the app
# in to their application menus. The .desktop file of this app will include
# the StartupWMClass key, set to app's formal name. This helps associate the
# app's windows to its menu item.
#
# For association to work, any windows of the app must have WMCLASS property
# set to match the value set in app's desktop file. For pygame_ce, this is
# set using the SDL_VIDEO_X11_WMCLASS environment variable.

# Find the name of the module that was used to start the app
app_module = sys.modules["__main__"].__package__
# Retrieve the app's metadata
metadata = importlib.metadata.metadata(app_module)

os.environ["SDL_VIDEO_X11_WMCLASS"] = metadata["Formal-Name"]

pygame.init()
pygame.display.set_caption(metadata["Formal-Name"])
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
break

screen.fill(BGCOLOR)
pygame.display.flip()

pygame.quit()
"""

def pyproject_table_briefcase_app_extra_content(self):
return """
requires = [
"pygame-ce",
Starbuck5 marked this conversation as resolved.
Show resolved Hide resolved
]
"""

def pyproject_table_macOS(self):
return """\
universal_build = true
requires = [
"std-nslog~=1.0.0",
Starbuck5 marked this conversation as resolved.
Show resolved Hide resolved
]
"""

def pyproject_table_linux(self):
return """\
requires = [
]
"""

def pyproject_table_linux_system_debian(self):
return """\
system_requires = [
]

system_runtime_requires = [
]
"""

def pyproject_table_linux_system_rhel(self):
return """\
system_requires = [
]

system_runtime_requires = [
]
"""

def pyproject_table_linux_system_suse(self):
return """\
system_requires = [
]

system_runtime_requires = [
]
"""

def pyproject_table_linux_system_arch(self):
return """\
system_requires = [
]

system_runtime_requires = [
]
"""

def pyproject_table_linux_appimage(self):
return """\
manylinux = "manylinux_2_28"

system_requires = [
]

linuxdeploy_plugins = [
]
"""

def pyproject_table_linux_flatpak(self):
return """\
flatpak_runtime = "org.freedesktop.Platform"
flatpak_runtime_version = "23.08"
flatpak_sdk = "org.freedesktop.Sdk"
"""

def pyproject_table_windows(self):
return """\
requires = [
]
"""

def pyproject_table_iOS(self):
return """\
supported = false
"""

def pyproject_table_android(self):
return """\
supported = false
"""

def pyproject_table_web(self):
return """\
supported = false
"""
1 change: 1 addition & 0 deletions src_py/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ install_data(data_files, install_dir: pg_dir, install_tag: 'pg-tag')

subdir('_sdl2')
subdir('__pyinstaller')
subdir('__briefcase')
Loading