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

Migrate Briefcase to PPB #722

Open
wants to merge 13 commits into
base: canon
Choose a base branch
from
40 changes: 39 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ task:
fi
- >-
apt-get update || true;
apt-get install -qq -y libsdl2-2.0-0 libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-gfx-1.0-0 libsdl2-ttf-2.0-0

script:
- command -v pypy3 >/dev/null && export PY=pypy3
Expand All @@ -90,6 +89,34 @@ task:

use_compute_credits: $CIRRUS_BRANCH == 'staging'

linux_briefcase_task:
name: "Linux Briefcase"
alias: Tests
skip: $CIRRUS_BRANCH =~ '.*\.tmp'

container:
image: debian:latest

depends_on:
- build

install_script:
- >-
apt-get update || true;
apt-get install -qq -y git python3 python3-pip python3-venv
- python3 -m venv /py
- source /py/bin/activate; python3 .ci/install-wheels.py
- /py/bin/pip install briefcase

info_script:
- /py/bin/python --version
- /py/bin/pip list

script:
- /py/bin/briefcase new --no-input -Q bootstrap=PursuedPyBear
- cd helloworld && /py/bin/briefcase package --no-input

use_compute_credits: $CIRRUS_BRANCH == 'staging'

macOS_task:
alias: Tests
Expand Down Expand Up @@ -123,6 +150,11 @@ macOS_task:
- pip list
- pytest

briefcase_script:
- pip install briefcase
- briefcase new --no-input -Q bootstrap=PursuedPyBear
- cd helloworld && briefcase package --no-input --adhoc-sign


macOS_version_task:
skip: $CIRRUS_BRANCH =~ '.*\.tmp'
Expand Down Expand Up @@ -164,6 +196,12 @@ task:
- C:\Python\python.exe -m pip list
- C:\Python\python.exe -m pytest

# briefcase_script:
# FIXME: Install git
# - C:\Python\python.exe -m pip install briefcase
# - C:\Python\python.exe -m briefcase new --no-input -Q bootstrap=PursuedPyBear
# - cd helloworld && C:\Python\python.exe -m briefcase package --no-input
#

upload_task:
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_RELEASE != ''
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ authors = [
{name = "Piper Thunstrom", email="pathunstrom@gmail.com"}
]
maintainers = [
{name = "Piper Thunstrom", email="pathunstrom@gmail.com"}
{name = "Piper Thunstrom", email="pathunstrom@gmail.com"},
{name = "Jamie Bliss", email="jamie@ivyleav.es"}
]
description = "An Event Driven Python Game Engine"
readme = "README.md"
Expand Down Expand Up @@ -47,3 +48,7 @@ Issues = "https://github.com/ppb/pursuedpybear/issues"

[tool.setuptools_scm]
local_scheme = "dirty-tag"

[project.entry-points."briefcase.bootstraps"]
PursuedPyBear = "ppb.briefcase:PursuedPyBearGuiBootstrap"

151 changes: 151 additions & 0 deletions src/ppb/briefcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
try:
from briefcase.bootstraps.base import BaseGuiBootstrap
except ImportError:
import warnings
warnings.warn("Briefcase not installed, briefcase integration unavailable")

class BaseGuiBootstrap: pass


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

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

import ppb


class {{ cookiecutter.class_name }}(ppb.Scene):
def __init__(self, **props):
super().__init__(**props)

# Add sprites and details to your scene here


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 PPB, 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"]

ppb.run(
starting_scene={{ cookiecutter.class_name }},
title=metadata["Formal-Name"],
)
"""

def pyproject_table_briefcase_app_extra_content(self):
return """
requires = [
"ppb~=3.2.0",
]
test_requires = [
{% if cookiecutter.test_framework == "pytest" %}
"pytest",
{% endif %}
]
"""

def pyproject_table_macOS(self):
return """\
universal_build = true
requires = [
"std-nslog~=1.0.0",
]
"""

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
"""