Skip to content

Commit 0999e79

Browse files
authored
Merge pull request #181 from Notenlish/main
add warning for pep 723
2 parents e69395b + 220aca5 commit 0999e79

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/pygbag/app.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from . import pack
3232
from . import web
3333
from .config_types import Config
34+
from .support.cross.aio.pep0723 import read_dependency_block_723
3435

3536

3637
from .config_to_object import load_config
@@ -87,6 +88,9 @@
8788
DEFAULT_WIDTH = 1280
8889
DEFAULT_HEIGHT = 720
8990

91+
def warn(msg):
92+
print(f"WARNING! {msg}")
93+
9094

9195
def set_args(program):
9296
global DEFAULT_SCRIPT
@@ -195,7 +199,25 @@ def make_cache_dirs():
195199

196200
async def main_run(app_folder, mainscript, cdn=DEFAULT_CDN):
197201
global DEFAULT_PORT, DEFAULT_SCRIPT, APP_CACHE, required
198-
202+
203+
# Checks for existance of PEP 723 header on main.py https://peps.python.org/pep-0723/
204+
main_file = Path(app_folder, mainscript)
205+
with open(main_file, "r") as f:
206+
src_code = f.read()
207+
208+
has_pep723 = False
209+
deps = {"pygame-ce"}
210+
for dep in read_dependency_block_723(src_code):
211+
has_pep723 = True
212+
if dep == "pygame-ce":
213+
pass
214+
elif dep == "pygame":
215+
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'.")
216+
else:
217+
deps.add(dep)
218+
if not has_pep723:
219+
warn("Couldn't find PEP 723 Header. See this: https://pygame-web.github.io/wiki/pygbag/#complex-packages")
220+
199221
DEFAULT_SCRIPT = mainscript or DEFAULT_SCRIPT
200222

201223
build_dir, cache_dir = cache_check(app_folder, devmode)

0 commit comments

Comments
 (0)