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 warning for pep 723 #181

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 25 additions & 1 deletion src/pygbag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from . import pack
from . import web
from .config_types import Config
from .support.cross.aio.pep0723 import read_dependency_block_723


from config_to_object import load_config
Expand Down Expand Up @@ -87,6 +88,11 @@
DEFAULT_WIDTH = 1280
DEFAULT_HEIGHT = 720

from colorama import Fore

def warn(msg):
print(f"{Fore.RED}WARNING!{Fore.RESET} ${msg}")


def set_args(program):
global DEFAULT_SCRIPT
Expand Down Expand Up @@ -195,7 +201,25 @@ def make_cache_dirs():

async def main_run(app_folder, mainscript, cdn=DEFAULT_CDN):
global DEFAULT_PORT, DEFAULT_SCRIPT, APP_CACHE, required


# Checks for existance of PEP 723 header on main.py https://peps.python.org/pep-0723/
main_file = Path(app_folder, mainscript)
with open(main_file, "r") as f:
src_code = f.read()

has_pep723 = False
deps = {"pygame-ce"}
for dep in read_dependency_block_723(src_code):
has_pep723 = True
if dep == "pygame-ce":
pass
elif dep == "pygame":
warn("Pygbag uses pygame-ce for running on web. If you're using pygame, you should probably upgrade to pygame-ce, it is backwards compatible so your code will still work. If you're using pygame-ce already, specify 'pygame-ce' instead of 'pygame'.")
else:
deps.add(dep)
if not has_pep723:
warn("Couldn't find PEP 723 Header. See this: https://pygame-web.github.io/wiki/pygbag/#complex-packages")

DEFAULT_SCRIPT = mainscript or DEFAULT_SCRIPT

build_dir, cache_dir = cache_check(app_folder, devmode)
Expand Down